{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# How to segment out only some bundles\n\nThe pyAFQ software can be configured to find all of its default set of white\nmatter pathways, or bundles. Alternatively, it can be configured to find only\nsome bundles. This example shows how to track and recognize only certain\nbundles that you are interested in, though note that ARC, pARC and VOF are all\nalso part of the set of bundles that are segmented per default.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import AFQ.api.bundle_dict as abd\nimport AFQ.data.fetch as afd\nfrom AFQ.api.group import GroupAFQ\nfrom AFQ.definitions.image import RoiImage\nimport AFQ.utils.streamlines as aus\n\nimport os.path as op\n\nafd.organize_stanford_data(clear_previous_afq=\"track\")\n\nbundle_names = [\n \"Left Arcuate\", \"Right Arcuate\",\n \"Left Posterior Arcuate\", \"Right Posterior Arcuate\",\n \"Left Vertical Occipital\", \"Right Vertical Occipital\"]\nbundle_dict = abd.default_bd()[bundle_names]\n\n\nmyafq = GroupAFQ(\n op.join(afd.afq_home, 'stanford_hardi'),\n bundle_info=bundle_dict,\n dwi_preproc_pipeline='vistasoft',\n t1_preproc_pipeline='freesurfer',\n tracking_params={\n \"n_seeds\": 50000,\n \"random_seeds\": True,\n \"seed_mask\": RoiImage(use_waypoints=True, use_endpoints=True),\n }\n)\n\nfor b_name in bundle_names:\n b_len = len(aus.SegmentedSFT.fromfile(myafq.export(\"bundles\")[\n \"01\"]).get_bundle(b_name))\n\n if b_len < 1:\n raise ValueError(f\"{b_name} not found\")\n\nmyafq.export(\"all_bundles_figure\")[\"01\"][0]" ] } ], "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 }