{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Using RecoBundles for bundle recognition\n\nFor bundle recognition, pyAFQ defaults to use the waypoint ROI approach\ndescribed in [Yeatman2012]_. However, as an alternative approach, pyAFQ also\nsupports using the RecoBundles algorithm [Garyfallidis2017]_, which uses an\natlas of bundles in streamlines. This example shows how to\nuse RecoBundles for bundle recognition.\n\nThe code closely resembles the code used in `sphx_glr_tutorial_examples_plot_001-plot_afq_api.py`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import os.path as op\nimport AFQ.data.fetch as afd\nfrom AFQ.api.group import GroupAFQ\nimport AFQ.api.bundle_dict as abd\n\nafd.organize_stanford_data(clear_previous_afq=\"track\")\n\ntracking_params = dict(n_seeds=25000,\n random_seeds=True,\n rng_seed=42)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Defining the segmentation params\nWe also refer to bundle recognition as the \"segmentation\" of the tractogram.\nParameters of this process are set through a dictionary input to the\n`segmentation_params` argument of the GroupAFQ object. In this case, we\nuse `abd.reco_bd(16)`, which tells pyAFQ to use the RecoBundles\nalgorithm for bundle recognition. This uses 16 bundles, there is also\nan atlas `abd.reco_bd(80)` which uses 80 bundles.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "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_gif')\n\nfig_files = myafq.export_all()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## References:\n .. [Garyfallidis2017] Garyfallidis, Eleftherios, Marc-Alexandre C\u00f4t\u00e9,\n Francois Rheault, Jasmeen Sidhu, Janice Hau, Laurent\n Petit, David Fortin, Stephen Cunanne, and Maxime\n Descoteaux. 2017.\u201cRecognition of White Matter Bundles\n Using Local and Global Streamline-Based Registration and\n Clustering.\u201dNeuroImage 170: 283-295.\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.13" } }, "nbformat": 4, "nbformat_minor": 0 }