This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
/
dti_pre_prep_legion.sh
executable file
·93 lines (74 loc) · 2.59 KB
/
dti_pre_prep_legion.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
ROOT="/home/rmjlns1/Scratch/shared"
RAW="dti_354" # The raw directory
PREP="dti_250" # The output directory
filename='/home/rmjlns1/Scratch/shared/bashscripts/ntag.txt' # Load NTAGS
filelines=`cat $filename` #Get each line
nfilename='/home/rmjlns1/Scratch/shared/bashscripts/ntag_nodti.txt' # Load NTAGS
nfilelines=`cat $nfilename` #Get each line
cd $ROOT
counter=1
for REM in $filelines ; do # Loop through at the subject level using N-tag
if [ "$filelines" -eq "$nfilelines" ]; then # If there are no DTI files it skips it.
counter=$((counter+1))
else
cd $ROOT/$RAW/$REM*/scans/ #
#dcm2niix ./ # This needs to be ran once.
# checks to see if b2000 exists. If it does NOT then it renames it
if [ -e dti_${counter}_b2000.nii ]
then
echo "file exist"
else
#dcm2niix ./ # This needs to be ran once.
cp -fr ./*_b2000_*.nii ./dti_${counter}_b2000.nii
cp -fr *_b2000_*.bval dti_${counter}_b2000.bval
cp -fr *_b2000_*.bvec dti_${counter}_b2000.bvec
fi
# checks to see if b700 exists. If it does NOT then it renames it
if [ -e dti_${counter}_b700.nii ]
then
echo "file exist"
else
cp -fr ./*_b700*.nii ./dti_${counter}_b700.nii
cp -fr *_b700*.bval dti_${counter}_b700.bval
cp -fr *_b700*.bvec dti_${counter}_b700.bvec
fi
# Combines the two data sets as multishell
fslmerge -a combo_dti_data dti_${counter}_b700.nii dti_${counter}_b2000.nii
paste -d"\0" dti_${counter}_b700.bval dti_${counter}_b2000.bval >> bvals
paste -d"\0" dti_${counter}_b700.bvec dti_${counter}_b2000.bvec >> bvecs
# creates the directory if it doesnt exist
if [ -d "$ROOT/$PREP/${counter}_dti" ]
then
echo "directory exists"
else
mkdir $ROOT/$PREP/${counter}_dti
fi
# copies over the data to the directory
cp -fr combo_dti_data.nii.gz $ROOT/$PREP/${counter}_dti
cp -fr bvals $ROOT/$PREP/${counter}_dti
cp -fr bvecs $ROOT/$PREP/${counter}_dti
# cd and creates the other files required
cd $ROOT/$PREP/${counter}_dti
# bet
bet combo_dti_data bet_combo_dti_data -m
# generates the index file needed for eddy
if [ -e index.txt ]
then
echo "file exist"
else
indx=""
for ((i=0; i<37; ++i)); do indx="$indx 1\n"; done
for ((i=0; i<72; ++i)); do indx="$indx 1\n"; done
echo $indx > index.txt
fi
# generates the acqparams file needed for eddy
if [ -e acqparams.txt ]
then
echo "file exist"
else
printf "0 -1 0 0.06\n0 -1 0 0.06" > acqparams.txt # I have checked and this is the same for both b700 & b2000
fi
counter=$((counter+1))
fi
done