-
Notifications
You must be signed in to change notification settings - Fork 0
/
tractseg
47 lines (37 loc) · 2.51 KB
/
tractseg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/sh
# use TractSeg to segment region-of-interest tracts
# load required modules
module load mrtrix
module load anaconda3/5.0.0
# source activate pytorch
# define user directories
TEMPLATE_DIR=/project/3022028.01/fixel_based_analysis/fba_w2/template
TRACTSEG_DIR=/project/3022028.01/fixel_based_analysis/tractseg_w2
mkdir $TRACTSEG_DIR
cd $TRACTSEG_DIR
# use existing peaks: To avoid generating the MRtrix CSD peaks every time you run TractSeg you can also provide them directly by skipping the option --raw_diffusion_input`; input image must be a peak image (nifti 4D image with dimensions [x,y,z,9])
# extract peak image from population template
# https://github.com/MIC-DKFZ/TractSeg
source activate trix
sh2peaks $TEMPLATE_DIR/wmfod_template.mif -threshold 0.1 peaks.nii.gz -force
# run TractSeg on population FOD template peak image in cluster
# https://github.com/MIC-DKFZ/TractSeg/blob/master/resources/Tutorial.md
# output is dir 'tractseg_output' containing subdir 'bundle_segmentations' containing one binary nifti image for each segmented bundle (N=72)
# Blobs made up of only a few voxels are removed; deactivate this option by using --no_postprocess
source activate pytorch
echo "TractSeg -i $TRACTSEG_DIR/peaks.nii.gz" | qsub -N bundle_seg -V -l walltime=00:10:00,mem=15gb
# segment beginning and end of bundles
echo "TractSeg -i $TRACTSEG_DIR/peaks.nii.gz -o $TRACTSEG_DIR/tractseg_output --output_type endings_segmentation" | qsub -N endings_seg -V -l walltime=00:10:00,mem=20gb
# extract tract orientation maps
echo "TractSeg -i $TRACTSEG_DIR/peaks.nii.gz -o $TRACTSEG_DIR/tractseg_output --output_type TOM" | qsub -N tract_maps -V -l walltime=00:10:00,mem=15gb
# probabilistic tractography on specific tract
echo "Tracking -i $TRACTSEG_DIR/peaks.nii.gz -o $TRACTSEG_DIR/tractseg_output --tracking_format tck --bundles CG_right,CST_left,SLF_I_left,SLF_II_left,SLF_III_left" | qsub -N TOM_tracking -V -l walltime=00:40:00,mem=15gb
# convert to a fixel map to segment fixels corresponding to tract
# https://community.mrtrix.org/t/segmenting-white-matter-tracts-for-fba-metric-computation/3746/5
# https://community.mrtrix.org/t/mapping-segmented-tracts-back-to-fixels/4202
source activate trix
for tract in CST_left SLF_I_left SLF_II_left SLF_III_left;do
tck2fixel $TRACTSEG_DIR/tractseg_output/TOM_trackings/${tract}.tck $TEMPLATE_DIR/fdc_smooth $TRACTSEG_DIR/tck2fixel_out ${tract}.mif
done
# view fixel map of tract by opening index file in fixel plot overlay and threshold >0.95
# use tract.mif for fixelcfestats option -mask