overview

Table of Contents

1 DTI Processing

1.1 Deterministic (CMTK Analogue)

1.1.1 Pre-processing

Extract first b0 volume - this will be used later in registration.

fslroi NIFTI/dwi-orig.nii.gz NIFTI/b0.nii.gz 0 1

Remove skull from first b0 volume.

bet NIFTI/b0.nii.gz NIFTI/b0-brain.nii.gz -f 0.2

Remove skull from T1 volume.

bet NIFTI/t1.nii.gz NIFTI/t1-brain.nii.gz

Binarize brain-extracted b0 image.

fslmaths NIFTI/b0-brain.nii.gz -bin NIFTI/b0-brain-mask.nii.gz

Apply motion correction to diffusion volumes, registering each volume of the dwi to the first b0 volume.

eddy_correct NIFTI/dwi-orig.nii.gz NIFTI/dwi.nii.gz 0

1.1.2 Registration

Register b0 to T1 using a 12-parameter linear transformation. This may also be done as a 6-parameter, rigid transform, but we feel the 12-parameter is more appropriate.

flirt -in NIFTI/b0-brain.nii.gz -ref NIFTI/t1-brain.nii.gz -o NIFTI/b0-to-t1.nii.gz -omat NIFTI/transformations/b0-to-t1.mat -usesqform

1.1.3 Segmentation / Parcellation

Use freesurfer to segment and parcellate the T1 image. This process may take up to a full day depending upon computing resources.

recon-all -sd `pwd` -s FREESURFER -i NIFTI/t1.nii.gz

Use muscip to map segmentation to 83 regions of interest, overlayed on our native T1 image space. To accomplish this, first load ipython

ipython

Then, after ipython has initialized, procede mapping using muscip.

# use muscip to map processed freesurfer directory to expected roi and wm images
import muscip.atlas.freesurfer as mfree
fs = mfree.load('FREESURFER')
roi_image = fs.roi_img()
white_matter_mask_image = fs.wm_mask()
# use nibabel to save images in memory to disk
import nibabel as nib
nib.save(roi_image, 'NIFTI/roi.nii.gz')
nib.save(white_matter_mask_image, 'NIFTI/wm.nii.gz')

1.1.4 Streamline Generation (Fiber Tracking)

Reconstruct tensors using Diffusion Toolkit.

dti_recon NIFTI/dwi.nii.gz DIFFUSION/dti -gm bvecs-dtk -b 1000 -axial -p 3 -sn 1 -ot nii.gz

Generate streamlines using Diffusion Toolkit. We typically use the FACT (Fiber Assignment by Continuous Tracking) algorithm. We constrain our tacking voxels by applying the reconstructed FA image with a threshold typically between 0.1 and 0.2 depending upon application, the lower thresholds being more lenient. We feel we can afford to be lenient in this step because we will later be filtering streamlines by our overlayed ROIs.

dti_tracker DIFFUSION/dti DIFFUSION/fibers.trk -at 45 -m DIFFUSION/dti_fa.nii.gz 0.15 2.0 -it nii.gz -rseed 24
spline_filter DIFFUSION/fibers.trk 0.5 DIFFUSION/fibers.trk

Register streamlines to native T1 space using Diffusion Toolkit.

track_transform DIFFUSION/fibers.trk DIFFUSION/fibers.trk -src NIFTI/b0.nii.gz -ref NIFTI/t1.nii.gz -reg NIFTI/transformations/b0-to-t1.mat

1.1.5 Connectome Creation

Use muscip to select streamlines that meet our critera, most importantly that the endpoints of kept streamlines reside inside the volumes of distint regions of interest. This will again be done inside ipython

ipython

…wait for ipython to initialize…

import muscip.connectome as mcon
# load connectome and extract network
connectome = mcon.TNDtkConnectome(fibers='DIFFUSION/fibers.trk', min_fiber_length=20.0, max_fiber_length=300.0, roi_image='NIFTI/roi.nii.gz')
connectome.generate_network()
# write connectome to file
connectome.write('CTOME')

While still in the same ipython session, use muscip to generate hagmann densities.

# assuming we are still in ipython and have same connectome object in memory...
# set our white matter mask image
connectome.wm_image = 'NIFTI/wm.nii.gz'
connectome.populate_hagmann_density()
# write connectome to file
connectome.write('CTOME')

While still in the same ipython session, use muscip to add scalars such as FA to our connectome.

# assuming we are still in ipython and have same connectome object in memory...
# add a scalar image
connectome.add_scalar('DIFFUSION/dti_fa.nii.gz', 'fa', aff='NIFTI/transformations/b0-to-t1.mat')
# set subject ID and write connectome to file
connectome.subject_id = 'SUBID' # replace w/ actual subject ID (string)
connectome.write('CTOME')

1.2 Probabilistic

1.2.1 Pre-processing

Extract first b0 volume - this will be used later in registration.

fslroi NIFTI/dwi-orig.nii.gz NIFTI/b0.nii.gz 0 1

Remove skull from first b0 volume.

bet NIFTI/b0.nii.gz NIFTI/b0-brain.nii.gz -f 0.2

Remove skull from T1 volume.

bet NIFTI/t1.nii.gz NIFTI/t1-brain.nii.gz

Binarize brain-extracted b0 image.

fslmaths NIFTI/b0-brain.nii.gz -bin NIFTI/b0-brain-mask.nii.gz

Apply motion correction to diffusion volumes, registering each volume of the dwi to the first b0 volume.

eddy_correct NIFTI/dwi-orig.nii.gz NIFTI/dwi.nii.gz 0

1.2.2 Registration

Register b0 to T1 using a 12-parameter linear transformation. This may also be done as a 6-parameter, rigid transform, but we feel the 12-parameter is more appropriate.

flirt -in NIFTI/b0-brain.nii.gz -ref NIFTI/t1-brain.nii.gz -o NIFTI/b0-to-t1.nii.gz -omat NIFTI/transformations/b0-to-t1.mat -usesqform

1.2.3 Segmentation / Parcellation

Use freesurfer to segment and parcellate the T1 image. This process may take up to a full day depending upon computing resources.

recon-all -sd `pwd` -s FREESURFER -i NIFTI/t1.nii.gz

Use muscip to map segmentation to 83 regions of interest, overlayed on our native T1 image space. To accomplish this, first load ipython

ipython

Then, after ipython has initialized, procede mapping using muscip.

# use muscip to map processed freesurfer directory to expected roi and wm images
import muscip.atlas.freesurfer as mfree
fs = mfree.load('FREESURFER')
roi_image = fs.roi_img()
white_matter_mask_image = fs.wm_mask()
# use nibabel to save images in memory to disk
import nibabel as nib
nib.save(roi_image, 'NIFTI/roi.nii.gz')
nib.save(white_matter_mask_image, 'NIFTI/wm.nii.gz')

Create individual mask images for each label in ROIs.

# create a directory to contain seed masks
mkdir DIFFUSION/seed_masks
# get min and max values for labels.. we will assume
#  we are dealing with integers
min_i=`fslstats NIFTI/roi.nii.gz -l 0.1 -R | cut -d ' ' -f1`
max_i=`fslstats NIFTI/roi.nii.gz -l 0.1 -R | cut -d ' ' -f2`
# create masks for each region (removing any .0's from the values if
# needed, akin to casting as int)
for i in `seq ${min_i/.0*/} ${max_i/.0*/}`; do
  fslmaths roi.nii.gz -thr $i -uthr $i -bin "DIFFUSION/seed_masks/"${i}.nii.gz
done

1.2.4 Streamline Generation (Fiber Tracking)

Model crossing fibers using bedpostx.

# stage input files
cp NIFTI/dwi.nii.gz DIFFUSION/data.nii.gz
cp NIFTI/b0-brain-mask.nii.gz DIFFUSION/nodif_brain_mask.nii.gz
# run bedpostx (this will take a long time to run)
bedpostx DIFFUSION

Generate streamlines using probtrackx. For this we will use mostly default parameters: 2000 seeds per voxel, 5000 steps per streamline.

# for each seed mask, use probtrackx to create
# a fiber distribution
for seed_mask in DIFFUSION/seed_masks/*.nii.gz; do
  mask_file=`basename "$seed_mask"`
  mask_name=${mask_file%.nii*}
  echo -e "Starting tracking for region: $mask_name..."
  probtrackx --mode=seedmask -x "$seed_mask" -l -c 0.2 -S 2000 \
    --steplength=0.5 -P 5000 --forcedir --opd --pd -s \ 
    DIFFUSION.bedpostX/merged -m DIFFUSION/nodif_brain_mask.nii.gz \
    --xfm=NIFTI/transformations/b0-to-t1.nii.gz --dir \
     DIFFUSION/fdt_paths --out=${mask_name}.nii.gz
done

Merge individual streamline distributions into a single 4-dimensional stack.

cd DIFFUSION/fdt_paths
fslmerge -t fdt.nii.gz `ls . | sort -h`

1.2.5 Connectome Creation

Use muscip to generate connectomes. With fiber distributions in the same space as our image containing regions of interest, for each fiber distribution corresponding to a given seed region extract fiber density inside all other regions of interest. This will be done in an ipython session…

ipython

…wait for ipython to load.

import muscip.connectome as mcon
# load connectome and extract network
connectome = mcon.TNProbtackxConnectome(fdt_image='DIFFUSION/fdt.nii.gz', roi_image='NIFTI/roi.nii.gz')
connectome.generate_network()
# set subject ID and write connectome to file
connectome.subject_id = 'SUBID' # replace w/ actual subject ID (string)
connectome.write('CTOME')

Date: 2012-11-20 01:08:25 EST

Author: Travis Nesland

Org version 7.7 with Emacs version 23

Validate XHTML 1.0