BENCH Practical

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.

Contents:

To conduct inference using BENCH, you'll need to follow these steps:

Training Change Models
Using simulations to train machine learning models that can predict change in diffusion data
Extract Summary Measurements
Estimating rotationally invariant features from cleaned diffusion MRI data
Runing GLM
Running a GLM to estimate the baseline and the change in the summary measurements
Runing Inference
Running the inference to estimate the probablity of change in each parameter as well as the amount of change
digraph G { rankdir=LR node [shape=box]; 1 [label="Clean diffusion data (data)"]; 2 [label="White matter (ROI) mask in template space(mask)"]; 3 [label="List of b-values (bvals)"]; 4 [label="List of gradient orientations (bvecs)"]; 5 [label="Transformations from diffusion to template space(xfm)"]; 6 [label="bench diff-summary"]; 7 [label="Forward model (model)"]; 9 [label="bench diff-train "]; 10 [label="Summary measurmenets per subject"]; 11 [label="bench glm"]; 12 [label="Change models"]; 13 [label="bench inference"]; 14 [label="Baseline"]; 15 [label="Group differencce"]; 16 [label="Design matrix and design contrast"]; 17 [label="Change probability maps"]; 18 [label="Noise covariance"] 19 [label="Estimated amount of change maps"]; 1 -> 6; 2 -> 6; 3 -> 6; 4 -> 6; 5 -> 6; 3 -> 9; 7 -> 9; 6 -> 10; 9 -> 12; 10 -> 11; 16 -> 11; 2 -> 11; 11 -> 14; 11 -> 15; 14 -> 13; 15 -> 13; 12 -> 13; 13 -> 17; 11 -> 18; 18 -> 13; 13 -> 19 }

Training Change Models

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:

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.

What are the parameters of the `standard model` of diffusion? What each parameter represents?


What does a change model estimate?
Incorrect!
Incorrect!
Correct! Bench estimates the regression weights that predict how the diffusion data may change as a result of change in each of the parameters. This includes the average and also uncertainty of change.

Extracting summary measurements

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:

An alternative option for the summary measurements is to use spherical harmonics deconvolution that is analogous to a fourier transform for signals defined on the surface of a uint sphere. To try this option you can use --summarytype flag both in the training and in summary extraction section.

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?




How many summary measurements are extracted in total?
Incorrect!
Incorrect!
Correct! There are mean diffusivity and fractional anisotropy per shell of diffusion data as well as the mean b0 signal.

Summary Extraction for Multiple Subjects

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
Using a Cluster for Batch Processing:

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.

Running GLM

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:

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.

What are the main outputs of bench glm?
Wrong!
Correct!
Wrong!

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.

Running Inference

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:

This step generates two key outputs for each parameter of the forward model:

  1. A probability map that displays, for each voxel, the normalized likelihood that the parameter can explain the observed differences in the diffusion MRI data between the groups.
  2. An estimate of the most likely amount of change for that parameter.

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 --useNegativeCmap

However, 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 random 

The labels for each number are based on the order of parameters in ./Results/model_names.txt

What do the numbers in the s_iso_probability.nii.gz file represent?
Incorrect! The possible estimated change in the parameters are given in the s_iso_amount.nii.gz file.
Correct!
How dare you!


Is there any relationship between the numbers in "param_name"_prob.nii.gz files?

The End.