{ "cells": [ { "cell_type": "markdown", "id": "208da207", "metadata": {}, "source": [ "# Using RecoBundles for bundle recognition\n", "\n", "For bundle recognition, pyAFQ defaults to use the waypoint ROI approach\n", "described in [^Yeatman2012]. However, as an alternative approach, pyAFQ also\n", "supports using the RecoBundles algorithm [^Garyfallidis2017], which uses an\n", "atlas of bundles in streamlines. This example shows how to\n", "use RecoBundles for bundle recognition.\n", "\n", "The code closely resembles the code used in the GroupAFQ tutorial." ] }, { "cell_type": "code", "execution_count": null, "id": "e343b254", "metadata": {}, "outputs": [], "source": [ "import os.path as op\n", "import AFQ.data.fetch as afd\n", "from AFQ.api.group import GroupAFQ\n", "import AFQ.api.bundle_dict as abd\n", "\n", "afd.organize_stanford_data(clear_previous_afq=\"track\")\n", "\n", "tracking_params = dict(n_seeds=25000,\n", " random_seeds=True,\n", " rng_seed=42)" ] }, { "cell_type": "markdown", "id": "696ede38", "metadata": {}, "source": [ "## Defining the segmentation params\n", "We also refer to bundle recognition as the \"segmentation\" of the tractogram.\n", "Parameters of this process are set through a dictionary input to the\n", "`segmentation_params` argument of the GroupAFQ object. In this case, we\n", "use `abd.reco_bd(16)`, which tells pyAFQ to use the RecoBundles\n", "algorithm for bundle recognition. This uses 16 bundles, there is also\n", "an atlas `abd.reco_bd(80)` which uses 80 bundles." ] }, { "cell_type": "code", "execution_count": null, "id": "0a8437a3", "metadata": {}, "outputs": [], "source": [ "myafq = GroupAFQ(\n", " output_dir=op.join(afd.afq_home, 'stanford_hardi', 'derivatives',\n", " 'recobundles'),\n", " bids_path=op.join(afd.afq_home, 'stanford_hardi'),\n", " # Set the algorithm to use RecoBundles for bundle recognition:\n", " bundle_info=abd.reco_bd(16),\n", " dwi_preproc_pipeline='vistasoft',\n", " t1_preproc_pipeline='freesurfer',\n", " tracking_params=tracking_params,\n", " viz_backend_spec='plotly_no_mp4')\n", "\n", "fig_files = myafq.export_all()" ] }, { "cell_type": "markdown", "id": "b36f3f1f", "metadata": {}, "source": [ "## References\n", "\n", "[^Garyfallidis2017]: Garyfallidis, Eleftherios, Marc-Alexandre Côté,\n", " Francois Rheault, Jasmeen Sidhu, Janice Hau, Laurent\n", " Petit, David Fortin, Stephen Cunanne, and Maxime\n", " Descoteaux. 2017. “Recognition of White Matter Bundles\n", " Using Local and Global Streamline-Based Registration and\n", " Clustering.” NeuroImage 170: 283-295.\n", "\n", ":::{only} html\n", "{download}`Download as Jupyter Notebook `\n", ":::" ] } ], "metadata": { "file_format": "mystnb", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "pygments_lexer": "ipython3" }, "mystnb": { "execution_mode": "off" } }, "nbformat": 4, "nbformat_minor": 5 }