-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaal_roi.sh
More file actions
executable file
·39 lines (25 loc) · 1.62 KB
/
aal_roi.sh
File metadata and controls
executable file
·39 lines (25 loc) · 1.62 KB
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
#!/bin/bash
# This script aligns the MNI brain to functional image space then uses this transform to register the AAL atlas to the funcitonal image. Masks are created from the atlas and the functional image is masked. The output files can be found in $caseDir/images_masked and $caseDir/masks.
topDir=$1
dataPath=$2
dataFile=$(basename $dataPath)
# extract filename from data
filename=${dataFile%.nii*}
for caseDir in $(ls -d $topDir/*CVRTRT8P*); do
# transformation from MNI to functional space
flirt -in "$caseDir/output/mean_baselineCBF.nii" -ref /usr/local/fsl/data/standard/MNI152_T1_2mm_brain -omat "$caseDir/temp/func2MNI.mat" -dof 12 -interp trilinear
convert_xfm -omat "$caseDir/temp/MNI2func.mat" -inverse "$caseDir/temp/func2MNI.mat"
flirt -in aal_MNI_V4.nii -ref "$caseDir/output/mean_baselineCBF.nii" -applyxfm -init "$caseDir/temp/MNI2func.mat" -out "$caseDir/temp/aal_func.nii" -dof 12 -interp nearestneighbour
# make subdirectories to store ROI data
if [ ! -e $caseDir/masks ]; then mkdir $caseDir/masks; fi
#if [ ! -e $caseDir/images_masked ]; then mkdir $caseDir/images_masked; fi
if [ ! -e $caseDir/output/mean_baselineCBF_images_masked ]; then mkdir $caseDir/output/mean_baselineCBF_images_masked; fi
# create a mask for each ROI
IFS=$'\n'
for line in $(tail -n +2 aal_MNI_V4.txt); do
i=$(echo $line | awk '{print $1}')
label=$(echo $line | awk '{print $2}')
fslmaths $caseDir/temp/aal_func.nii.gz -thr $i -uthr $i -bin $caseDir/masks/${label}_func
fslmaths $caseDir/$dataPath -mas $caseDir/masks/${label}_func.nii.gz $caseDir/output/mean_baselineCBF_images_masked/${filename}_${label}
done
done