This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Structural Imaging

Tutorials about processing structural MRI data

1 - FreeSurfer

Example workflow for FreeSurfer

This tutorial was created by Steffen Bollmann.

Github: @stebo85 Web: mri.sbollmann.net Twitter: @sbollmann_MRI

FreeSurfer Example using module load (e.g. on an HPC)

Download data:

osf -p bt4ez fetch osfstorage/TOMCAT_DIB/sub-01/ses-01_7T/anat/sub-01_ses-01_7T_T1w_defaced.nii.gz ./sub-01_ses-01_7T_T1w_defaced.nii.gz

Setup FreeSurfer:

ml freesurfer/7.3.2
mkdir ~/freesurfer-output
export SINGULARITYENV_SUBJECTS_DIR=~/freesurfer-output
export APPTAINERENV_SUBJECTS_DIR=~/freesurfer-output

Run Recon all pipeline:

recon-all -subject test-subject -i ~/sub-01_ses-01_7T_T1w_defaced.nii.gz -all

Alternative instructions for using Freesurfer via the Neurodesk application menu

Download demo data

Open a terminal and run:

pip install osfclient
osf -p bt4ez fetch TOMCAT_DIB/sub-01/ses-01_7T/anat/sub-01_ses-01_7T_T1w_defaced.nii.gz /neurodesktop-storage/sub-01_ses-01_7T_T1w_defaced.nii.gz

FreeSurfer License file:

Before using Freesurfer you need to request a license here (https://surfer.nmr.mgh.harvard.edu/registration.html) and store it in your homedirectory as ~/.license

FreeSurfer Example

Open FreeSurfer (Neurodesk -> Image Segmentation -> Freesurfer -> Freesurfer 7.1.1)

Setup FreeSurfer license (for example - replace with your license):

echo "Steffen.Bollmann@cai.uq.edu.au
> 21029
>  *Cqyn12sqTCxo
>  FSxgcvGkNR59Y" >> ~/.license

export FS_LICENSE=~/.license 

Setup FreeSurfer:

mkdir /neurodesktop-storage/freesurfer-output
source /opt/freesurfer-7.1.1/SetUpFreeSurfer.sh
export SUBJECTS_DIR=/neurodesktop-storage/freesurfer-output

Run Recon all pipeline:

recon-all -subject test-subject -i /neurodesktop-storage/sub-01_ses-01_7T_T1w_defaced.nii.gz -all

2 - Structural connectivity dMRI

Example workflow for constructing strutural connectivity (Human connectome project: Single subject)

This tutorial was created by Joan Amos.

Email: joan@std.uestc.edu.cn Github: @Joanone

References:

The steps used for this tutorial were from:

Data Description

Reference:

The single subject data (T1w structural and diffusion) used in this tutorial has been minimally preprocessed and was downloaded from the open available source:

db.humanconnectome.org

Download demo data:

Demo data can also be downloaded using these links below.

Assumptions:

  • You have neurodesk already running from your chrome browser.
  • You have sufficient disk space to successfully implement the structural connectivity.
  • The structural and diffusion sample data have been unzipped in the mounted storage directory.

Sample Subject (100307) directory tree structure should include these input files:

  • aparc+aseg.nii.gz
  • T1w_acpc_dc_restore_brain.nii.gz
  • bvals
  • bvecs
  • data.nii.gz

N/B: The subfolder used in this tutorial was tagged “Test”

Open a terminal in neurodesk and confirm your input files:

structuralconnectivity

Activate mrtrix3, fsl and afni software versions of your choice in the neurodesk terminal

N/B: mrtrix3 (3.0.3), afni (21.2.00), fsl(6.0.5.1) versions were used in this tutorial. For reproducibility, the same versions can be maintained.

structuralconnectivity

Step 1: Further pre-processing

Extract data.nii.gz to enable memory-mapping. The extracted files are about 4.5GB:

structuralconnectivity

Perform mrconvert:

structuralconnectivity

Extract the response function. Uses stride 0,0,0,1:

structuralconnectivity

structuralconnectivity

Generate mask:

structuralconnectivity

Generate Fibre Orientation Distributions (FODs):

structuralconnectivity

Perform normalization:

structuralconnectivity

Generate a 5 tissue image:

structuralconnectivity

Convert the B0 and 5TT image to a compressed format:

structuralconnectivity

Use “fslroi” to extract the first volume of the segmented dataset which corresponds to the Grey Matter Segmentation:

structuralconnectivity

Use “flirt” command to perform coregisteration:

structuralconnectivity

Convert the transformation matrix to a format readable by MRtrix3:

structuralconnectivity

Coregister the anatomical image to the diffusion image:

structuralconnectivity

Create the seed boundary which separates the grey from the white matter. The command “5tt2gmwmi” denotes (5 tissue type(segmentation) to grey matter/white matter interface):

structuralconnectivity

Step 2: Tractogram construction

The probabilistic tractography which is the default in MRtrix is used in this tutorial. The default method is the iFOD2 algorithm. The number of streamlines used is 10 million, this was chosen to save computational time:

structuralconnectivity

Proceed to Step 3 when the process above is completed (100%).

Step 3: SIFT2 construction

The generated streamlines can be refined with tcksift2 to counterbalance the overfitting. This creates a text file containing weights for each voxel in the brain:

structuralconnectivity

Step 4: Connectome construction

In constructing the connectome, the desikan-killany atlas which includes the cortical and sub-cortical regions (84 regions) was used.

Copy the “FreeSurferColorLUT.txt” file from the ml freesurfer 7.2.0 singularity container to the subject’s folder:

structuralconnectivity structuralconnectivity

Copy the “fs_default.txt” file from the ml mrtrix3 3.0.3 singularity container to the subject’s folder:

structuralconnectivity

The command labelconvert uses the parcellation and segmentation output of FreeSurfer to create a new parcellated file in .mif format:

structuralconnectivity

Perform nodes co-registeration:

structuralconnectivity

Create a whole-brain connectome which denotes the streamlines between each parcellation pair in the atlas. The “symmetric” option makes the lower and upper diagonal the same, the “scale_invnodevol” option scales the connectome by the inverse of the size of the node:

structuralconnectivity

Viewing the connectome

The generated nodes.csv file can be viewed outside neurodesk as a matrix in Matlab.

connectome=importdata('nodes.csv');
imagesc(connectome,[0 1])

structuralconnectivity

Congratulations on constructing a single subject’s structural connectome with neurodesk! Running multiple subjects would require scripting. Kindly consult the references above.