Plotting the Optic RadiationsΒΆ

pyAFQ is designed to be customizable. This example shows how you can customize it to define a new bundle based on both waypoint ROIs of your design, as well as endpoint ROIs of your design.

For now, this is a hypothetical example, as we do not yet provide these ROIs as part of the software.

Out:

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2420.26 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1227.48 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1948.12 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2043.01 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2637.93 MB/s]

  0%|          | 0/19 [00:00<?, ? MB/s]
 21%|##1       | 4/19 [00:00<00:00, 22.42 MB/s]
 58%|#####7    | 11/19 [00:00<00:00, 32.30 MB/s]
100%|##########| 19/19 [00:00<00:00, 52.99 MB/s]

  0%|          | 0/19 [00:00<?, ? MB/s]
 16%|#5        | 3/19 [00:00<00:00, 17.23 MB/s]
 47%|####7     | 9/19 [00:00<00:00, 27.30 MB/s]
100%|##########| 19/19 [00:00<00:00, 43.52 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2326.29 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2321.14 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2664.74 MB/s]

  0%|          | 0/19 [00:00<?, ? MB/s]
 21%|##1       | 4/19 [00:00<00:00, 22.62 MB/s]
 63%|######3   | 12/19 [00:00<00:00, 35.85 MB/s]
100%|##########| 19/19 [00:00<00:00, 53.43 MB/s]

  0%|          | 0/19 [00:00<?, ? MB/s]
 21%|##1       | 4/19 [00:00<00:00, 22.94 MB/s]
 79%|#######8  | 15/19 [00:00<00:00, 46.42 MB/s]
100%|##########| 19/19 [00:00<00:00, 54.20 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2410.52 MB/s]

  0%|          | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2167.60 MB/s]
Downloading https://templateflow.s3.amazonaws.com/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_T2w.nii.gz

  0%|          | 0.00/13.0k [00:00<?, ?B/s]
 29%|##9       | 3.77k/13.0k [00:00<00:00, 37.7kB/s]
 65%|######5   | 8.47k/13.0k [00:00<00:00, 43.1kB/s]
13.0kB [00:00, 44.5kB/s]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]
Optimizing level 2 [max iter: 10000]
Optimizing level 1 [max iter: 1000]
Optimizing level 0 [max iter: 100]

  0%|          | 0/16900 [00:00<?, ?it/s]
  0%|          | 4/16900 [00:05<6:59:19,  1.49s/it]
  0%|          | 6/16900 [00:06<4:12:36,  1.11it/s]
  1%|          | 144/16900 [00:06<06:09, 45.31it/s]
  5%|4         | 784/16900 [00:06<00:53, 303.46it/s]
  6%|6         | 1040/16900 [00:06<00:40, 395.14it/s]
  9%|9         | 1552/16900 [00:07<00:26, 581.86it/s]
 11%|#         | 1808/16900 [00:07<00:30, 501.25it/s]
 14%|#3        | 2320/16900 [00:08<00:21, 685.39it/s]
 15%|#5        | 2576/16900 [00:08<00:19, 719.31it/s]
 17%|#6        | 2832/16900 [00:08<00:17, 804.13it/s]
 18%|#8        | 3088/16900 [00:08<00:15, 898.41it/s]
 20%|#9        | 3344/16900 [00:09<00:15, 892.74it/s]
 21%|##1       | 3600/16900 [00:09<00:16, 783.59it/s]
 24%|##4       | 4112/16900 [00:10<00:13, 925.94it/s]
 26%|##5       | 4368/16900 [00:10<00:13, 951.41it/s]
 27%|##7       | 4624/16900 [00:10<00:12, 1019.06it/s]
 29%|##8       | 4880/16900 [00:10<00:11, 1071.02it/s]
 30%|###       | 5136/16900 [00:10<00:09, 1220.97it/s]
 32%|###1      | 5392/16900 [00:10<00:08, 1429.49it/s]
 33%|###3      | 5648/16900 [00:11<00:08, 1349.24it/s]
 35%|###4      | 5904/16900 [00:11<00:08, 1337.85it/s]
 36%|###6      | 6160/16900 [00:11<00:07, 1469.89it/s]
 38%|###7      | 6416/16900 [00:11<00:08, 1214.52it/s]
 39%|###9      | 6672/16900 [00:11<00:08, 1267.02it/s]
 43%|####2     | 7184/16900 [00:12<00:06, 1532.55it/s]
 46%|####5     | 7696/16900 [00:12<00:05, 1677.52it/s]
 47%|####7     | 7952/16900 [00:12<00:05, 1767.66it/s]
 49%|####8     | 8208/16900 [00:12<00:04, 1861.33it/s]
 62%|######2   | 10512/16900 [00:12<00:01, 5910.81it/s]
 80%|########  | 13584/16900 [00:13<00:00, 9954.67it/s]
 92%|#########2| 15632/16900 [00:13<00:00, 9503.82it/s]
100%|##########| 16900/16900 [00:13<00:00, 1276.66it/s]

  0%|          | 0/16900 [00:00<?, ?it/s]
  0%|          | 8/16900 [00:00<04:17, 65.64it/s]
  6%|6         | 1020/16900 [00:00<00:02, 5468.70it/s]
 18%|#8        | 3068/16900 [00:00<00:01, 10990.90it/s]
 25%|##4       | 4165/16900 [00:00<00:01, 10218.41it/s]
 36%|###6      | 6140/16900 [00:00<00:00, 12312.87it/s]
 48%|####8     | 8188/16900 [00:00<00:00, 12785.95it/s]
 61%|######    | 10236/16900 [00:00<00:00, 12378.77it/s]
 73%|#######2  | 12284/16900 [00:01<00:00, 5280.39it/s]
 85%|########4 | 14332/16900 [00:03<00:01, 2248.40it/s]
 97%|#########6| 16380/16900 [00:05<00:00, 1709.36it/s]
100%|##########| 16900/16900 [00:05<00:00, 3079.07it/s]

  0%|          | 0/2 [00:00<?, ?it/s]
 50%|#####     | 1/2 [00:00<00:00,  3.97it/s]
100%|##########| 2/2 [00:00<00:00,  3.96it/s]
100%|##########| 2/2 [00:00<00:00,  3.96it/s]

  0%|          | 0/2 [00:00<?, ?it/s]
 50%|#####     | 1/2 [00:00<00:00,  4.03it/s]
100%|##########| 2/2 [00:00<00:00,  4.12it/s]
100%|##########| 2/2 [00:00<00:00,  4.11it/s]

import os.path as op
from AFQ import api
import AFQ.data as afd
from AFQ.definitions.mask import LabelledMaskFile, RoiMask

afd.organize_stanford_data(clear_previous_afq=True)

or_rois = afd.read_or_templates()

bundles = api.BundleDict({
    "L_OR": {
        "ROIs": [or_rois["left_OR_1"],
                 or_rois["left_OR_2"],
                 or_rois["left_OP_MNI"],
                 or_rois["left_TP_MNI"],
                 or_rois["left_pos_thal_MNI"]],
        "rules": [True, True, False, False, False],
        "cross_midline": False,
        "uid": 1
        },
    "R_OR": {
        "ROIs": [or_rois["right_OR_1"],
                 or_rois["right_OR_2"],
                 or_rois["right_OP_MNI"],
                 or_rois["right_TP_MNI"],
                 or_rois["right_pos_thal_MNI"]],
        "rules": [True, True, False, False, False],
        "cross_midline": False,
        "uid": 2
        }
    }
)

endpoint_info = {
    "L_OR": {
        "startpoint": or_rois['left_thal_MNI'],
        "endpoint": or_rois['left_V1_MNI']},
    "R_OR": {
        "startpoint": or_rois['right_thal_MNI'],
        "endpoint": or_rois['right_V1_MNI']}}

brain_mask = LabelledMaskFile("seg",
                              {"scope": "freesurfer"},
                              exclusive_labels=[0])

my_afq = api.AFQ(
    bids_path=op.join(afd.afq_home,
                     'stanford_hardi'),
    brain_mask=brain_mask,
    tracking_params={"n_seeds": 3,
                     "directions": "prob",
                     "odf_model": "CSD",
                     "seed_mask": RoiMask()},
    segmentation_params=dict(endpoint_info=endpoint_info),
    bundle_info=bundles)

my_afq.export_all()

Total running time of the script: ( 18 minutes 57.036 seconds)

Gallery generated by Sphinx-Gallery