-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrainextraction.sh
executable file
·54 lines (41 loc) · 1.2 KB
/
brainextraction.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
#!/bin/bash
startDirectory=/flush2/andek67/Data/MPI
MaximumThreads=40
threads=0
# Loop over all subjects and segment brain
for i in /flush2/andek67/Data/MPI/ds000221_R1.0.0/* ; do
# Go to current directory
cd $i
# Get subject name
Subject=${PWD##*/}
echo "Processing" $Subject
# Go back to original directory
cd $startDirectory
if [ -e ${i}/ses-01 ]; then
bet ${i}/ses-01/fmap/${Subject}_ses-01_acq-GEfmap_run-01_magnitude1.nii.gz ${i}/ses-01/fmap/${Subject}_ses-01_acq-GEfmap_run-01_magnitude1_brain.nii.gz -m &
((threads++))
fi
if [ $threads -eq "$MaximumThreads" ]; then
wait
threads=0
fi
done
threads=0
# Now erode brain masks to get rid of noise voxels
for i in /flush2/andek67/Data/MPI/ds000221_R1.0.0/* ; do
# Go to current directory
cd $i
# Get subject name
Subject=${PWD##*/}
echo "Processing" $Subject
# Go back to original directory
cd $startDirectory
if [ -e ${i}/ses-01 ]; then
fslmaths ${i}/ses-01/fmap/${Subject}_ses-01_acq-GEfmap_run-01_magnitude1_brain_mask.nii.gz -ero ${i}/ses-01/fmap/${Subject}_ses-01_acq-GEfmap_run-01_magnitude1_brain_mask_e.nii.gz &
((threads++))
fi
if [ $threads -eq "$MaximumThreads" ]; then
wait
threads=0
fi
done