In this practical, you will discover how to use bench
to investigate changes in brain microstructure between two subject groups using diffusion MRI.
For an introduction to the fundamental concepts of change models, please refer to the BENCH paper or BENCH trainig tutorial.
Briefly, each trained change model estimates the likelihood that a change in each parameter of the biophysical model can account for observed differences in the diffusion data between datasets.
Here we will employ BENCH to compare brain microstructures in 4 young subjects against 4 older subjects. Our goal is to identify regions in the brain where microstructural differences in terms of the paramaters of the standard model of diffusion through aging are likely to exist.
To conduct inference using BENCH, you'll need to follow these steps:
The first step in using BENCH is to train machine learning models known as "change models." These models aim to predict how changes in parameters of a biophysical forward model will affect diffusion MRI data. To train these models, BENCH utilizes simulations to generate the necessary training data. Once these change models are trained, they can be applied to investigate whether a specific parameter change can account for observed differences between groups. It's important to highlight that running this initial step does not require any diffusion data and only requires knowing the acquisition protocol and the forward biophysical model. To train a change model, you can execute the following command:
bench diff-train --model standard_model --bvals dataset/001/Diffusion/bvals --summarytype dt --output standard_model_dt
In this command:
diff-train
: Specifies the sub-command, indicating that the action is to train a change model.--model standard_model
: Sets the microstructural forward model according to those available in the BENCH library. The choice of forward model depends on the tissue type and parameters of interest. --bvals dataset/001/Diffusion/bvals
: Specifies the diffusion protocol using the b-values file from one subject. This is assumed to be consistent across all subjects.--summarytype dt
: Indicates that the change model should be trained on diffusion tensor metrics (MD and FA per shell) as summary measurements.--output std_dt
: Defines the location where the weights for the trained models will be saved.For an in-depth explanation of these options or to learn how to implement your own specific forward model, please look at the BENCH training tutorial. Training a change model can be a time-consuming process, potentially taking several hours. The duration depends on factors such as available computational resources, the specifics of the diffusion protocol, and the number of samples used for training, etc. However, once the model is trained, it can be reused on any dataset that employs the same diffusion acquisition protocol, saving time in future analyses. To save time, we provide a pre-trained model for this acquisition that you can use for this tutorial.
Using diffusion MRI signals pre se to investigate brain microstructural changes presents two main challenges: the large data size and the complexity arising from tissue orientation and acquisition protocol. BENCH addresses these issues by employing signal representation models like Diffusion Tensor or Spherical Harmonics. These models condense the large dataset into summary measurements and provide metrics that are invariant to tissue orientation, thus simplifying analysis.
For example, metrics such as mean diffusivity and fractional anisotropy can be used to summarize the diffusion data within each shell. These metrics offer the advantage of being rotationally invariant, meaning they remain consistent regardless of the tissue orientation or the orientation of the acquisition.
To extract summary measurements from the diffusion MRI data, use the following command:
bench diff-summary --data dataset/001/Diffusion/data.nii.gz \ --bvecs dataset/001/Diffusion/bvecs \ --bvals dataset/001/Diffusion/bvals \ --mask wm_mask_2mm.nii.gz \ --xfm dataset/001/xfms/diff2standard_warp.nii.gz \ --summarytype dt \ --output summaries/001
In this command:
diff-summary
: Specifies the sub-command for extracting summary measurements from diffusion MRI data.--data, --bvals, --bvecs
: Identify the diffusion MRI dataset and its associated acquisition protocol. The data must have been pre-processed (e.g., using eddy/topup) --xfm
: Provides the transformation for mapping the diffusion data to a common space. Here we use MNI space.--mask wm_mask_2mm.nii.gz
: Specifies which regions of the brain to target for summary measurement extraction. It should be provided in the common space. In our example, we focus on white matter by providing a white matter mask.--summarytype dt
: Indicates the types of summary measurements to extract. For this tutorial, it will be diffusion tensor measurements that are mean diffusivity and fractional anisotropy per shell.--output
: Defines where the summary results will be saved.It is worth mentioning that BENCH uses nearest-neighbor sampling to compute summary measurements for each voxel in the mask from the diffusion data. This approach avoids the need for spatial transformations, which can be costly for diffusion data, and also eliminates the need to adjust b-vectors.
Now open one of the subject's summary measurement files in FSLEYES using the following command:
fsleyes summaries/001/* &What are each of these summary measurements presenting?
For single-subject processing, you would execute the above command. However, to compute summaries for all 8 subjects in our example, you can utilize a bash for
loop:
for i in $(seq 1 8); do bench diff-summary --data dataset/00$i/Diffusion/data.nii.gz \ --bvecs dataset/00$i/Diffusion/bvecs \ --bvals dataset/00$i/Diffusion/bvals \ --mask wm_mask_2mm.nii.gz \ --xfm dataset/00$i/xfms/diff2standard_warp.nii.gz \ --summarytype dt \ --output summaries/00$i done
If you have access to a computing cluster, you can employ the submit-summary
sub-command to batch-submit these jobs for more efficient processing. This sub-command uses file-tree
to parse the input for all subjects.
After extracting these rotationally invariant summary measurements for each subject ensuring they're all in the template space you can proceed to run a General Linear Model (GLM) analysis. This will allow you to calculate the baseline signal, the differences between the two groups, and the covariance of the noise. Armed with this information, you're equipped to quantify how the microstructural changes have changed the diffusion data between the groups.
To perform a GLM analysis, use the following command:
bench glm --summarydir summaries \ --mask wm_mask_2mm.nii.gz \ --designmat design.mat \ --designcon design.con \ --subjectlist subjlist.txt \ --output Glm
In this command:
glm
: Specifies that a GLM analysis will be run.--summarydir summaries
: Points to the directory containing summary measurements for all subjects, organized into subdirectories per subject that contain all summary measurement images.--mask wm_mask_2mm.nii.gz
: Defines the regions of interest for the GLM.--designmat design.mat
: Provide the design matrix in FSL format. The design matrix should have one row per subject and can have multiple columns.--designcon design.con
: In the design contrast the first contrast should represent the group mean and the second contrast should indicate the group difference.--subjectlist subjlist.txt
: Lists the subjects involved in the analysis one per line, the names must match to the subdirectories in the summary dir and the order must match with the design matrix.--output Glm
: Specifies where the GLM results will be saved.Now you can explore the changes in summary measurements across the brain attributed to group differences using the following command:
fsleyes Glm/change.nii.gz --cmap red-yellow --negativeCmap blue-lightblue --useNegativeCmap -dr 0 .1
Change the volume number and modify the data range as needed to examine how each summary measurement has changed. The corresponding names of the summary measurements can be found in the text file ./Glm/summarynames.txt
.
bench glm
?When training the change models, we generate simulated diffusion data. However, this simulation process doesn't account for the data's scale, which can be influenced by factors such as the scanner, bias field, etc. Therefore, it's essential to normalize the baseline measurements to align with the scale of the training data. Similarly, we must also normalize the change and the estimated noise covariance matrix. For diffusion tensor summary measurements, this process entails dividing the change's b0_mean by the baseline b0_mean. This normalization is automatically carried out during the inference step.
Now, we're set for the main analysis. We have estimates of how the diffusion data varies between our two groups, namely old versus young. Additionally, we have trained machine-learning models using simulations to understand how changes in microstructural parameters can influence the data. By combining these elements, we can explore which types of changes in our data across the brain best align with which of these trained change models.
To execute the inference step, use the following command:
bench inference --changemodel standard_model_dt --glmdir ./Glm --mask ./dataset/masks/slice_mask.nii.gz --output ./Results
In this command:
inference
: Specifies that inference will be conducted.--model standard_model_dt
: Points to the file containing the change models that were trained in the first stage.--glmdir ./Glm
: Provides the directory containing GLM results, including group means, group differences, and noise covariance for all summary measurements.--mask ./dataset/masks/slice_mask.nii.gz
: Provides the brain mask to specify voxels that are included inference step. Here we use a slice mask for time considerataions.--output ./Results
: Points out the location where the resulting probability maps will be saved.This step generates two key outputs for each parameter of the forward model:
These outputs help to quantify and localize where specific microstructural changes could be accounted for observed group differences.
Now you can look at the final probability maps to see to what extent each parameter can explain the group differences in the summary measurements from diffusion MRI data using the following command:
fsleyes ./Results/*_probability.nii.gz --cmap red-yellow -dr 0 1
It is also possible to check the most likely amount of change in each parameter using the following command:
fsleyes ./Results/*_amount.nii.gz --cmap red-yellow --negativeCmap blue-lightblue --useNegativeCmapHowever, keep in mind that these estimates are only meaningful if the model can confidently explain the change. Also, they are mutually exclusive; i.e. only one can be true at each voxel.
Moreover, in order to see what parameter change can best explain differences between the groups you can run the following command:
fsleyes ./Results/inferred_change.nii.gz --cmap randomThe labels for each number are based on the order of parameters in
./Results/model_names.txt
s_iso_probability.nii.gz
file represent?"param_name"_prob.nii.gz
files?The End.