BabyAFQ : tractometry for infant dMRI data¶

Infant brains are by no means just smaller versions of a grownup brain. Although many of the structures -- including major white matter tracts -- are present at birth, the infant brain differs substantially in its anatomy and physical composition relative to the adult brain. For example, the degree of myelination in the newborn brain is much smaller than in the adult brain. This is apparent when examining a newborn infants T1-weighted MRI, where gray matter appears brighter than the white matter. As the brain white matter myelinates in the first few months of life, this contrast inverts with a point of roughly equal brightness around 6 months of age (for a review see Gilmore, 2018).

Therefore, tractometry of neonates requires methods that are substantially different than the methods that are used for adult brains. The principles are similar, but the details vary. For example, instead of using the MNI152 template that is used in adults, we use an infant-oriented template Shi et al, 2021.

Furthermore, the waypoint ROIs that are used in infant data differ in their position from the adult. These waypoint ROIs were first defined and integrated into the Matlab version of AFQ in Grotheer, 2022, and and validated against expert-delineated tracts. The infant template and ROIs were subsequently integrated into pyAFQ in Grotheer, 2023 and the Python implementation was again validated with respect to these expert-delineated manual tracts.

In this example, an example of babyAFQ is presented with data from one of the subjects whose data was first presented in Grotheer, 2022.

In [1]:
import os.path as op
from paths import afq_home
In [2]:
import plotly
from AFQ.api.group import GroupAFQ
import AFQ.api.bundle_dict as abd
import AFQ.data.fetch as afd
In [3]:
baby_example_folder = op.join(afq_home, "baby_example")

Initialize a GroupAFQ object¶

Now that the data is downloaded and organized in a BIDS-compliant structure, we can start running pyAFQ on it. We start by initializing a GroupAFQ object.

In [4]:
myafq = GroupAFQ(
    bids_path=op.join(baby_example_folder,
                      "example_bids_subject"),
    preproc_pipeline="vistasoft", # These data were preprocessed with the vistasoft pipeline
    reg_template_spec=afd.read_pediatric_templates(
    )["UNCNeo-withCerebellum-for-babyAFQ"], # Note the use of a different template
    reg_subject_spec="b0",
    bundle_info=abd.baby_bd(), # Note use of the baby BundleDict object, which over-rides the default
    import_tract={
        "suffix": "tractography", "scope": "mrtrix"}, #Tractography was executed in advance with the mrtrix software
)
Loading pediatric templates...
Loading pediatric templates...
Loading pediatric templates...
/Users/john/miniconda3/envs/afq11/lib/python3.11/site-packages/bids/layout/validation.py:124: UserWarning: The PipelineDescription field was superseded by GeneratedBy in BIDS 1.4.0. You can use ``pybids upgrade`` to update your derivative dataset.
  warnings.warn("The PipelineDescription field was superseded "
INFO:AFQ:No seed mask given, using FA (or first scalar if none are FA)thresholded to 0.2
INFO:AFQ:No stop mask given, using FA (or first scalar if none are FA)thresholded to 0.2

Running the pipeline¶

A call to the export function will trigger the pyAFQ pipeline. This will run tractography, bundle segmentation, and bundle cleaning.

In [5]:
viz = myafq.export("all_bundles_figure")
INFO:AFQ:Loading Volume...
INFO:AFQ:Loading Volume...
INFO:AFQ:Loading Stateful Tractogram...
/Users/john/pyAFQ/AFQ/utils/streamlines.py:93: UserWarning:

Pass ['to_space'] as keyword args. From version 2.0.0 passing these as positional arguments will result in an error. 

INFO:AFQ:Generating colorful lines from tractography...
WARNING:AFQ:Failed to write HTML file: ../data_/tractometry/baby_example/example_bids_subject/derivatives/afq/sub-01/ses-01.html

Viewing the results¶

One way to view the results is to open the file named sub-01_ses-01_dwi_space-RASMM_model-probCSD_algo-AFQ_desc-viz_dwi.html in your browser.

In [6]:
plotly.io.show(viz["01"][0])