-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSAP_hippodeep_seg.sh
79 lines (44 loc) · 3.83 KB
/
SAP_hippodeep_seg.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
#!/bin/bash
set -e
# Function: 1) Run hippodeep segmentation to segment hippocampal masks, 2) Place hippocampal masks in appropriate folders
# NOTE: Can be done in Unix or Windows environment, but: 1) change paths to '/home/...' instead of '/c/...',
# and 2) change escape characters to LF (instead of CRLF) if executing in Unix (e.g., on P920).
########################################################################################################################################################################################################
# User defined variables
#PROJECT_DIR='/Windows/path/to/project/directory' # Choose directory in which to place the study
PROJECT_DIR='/Unix/path/to/project/directory' # P920 path
########################################################################################################################################################################################################
echo -e "\n\n####################################################################################################"
echo -e "\nStarting program..."
echo -e "\n####################################################################################################"
########################################################################################################################################################################################################
# Begin hippodeep_pytorch segmentation
echo -e "\n\n####################################################################################################"
echo -e "\nBeginning hippodeep_pytorch segmentation..."
echo -e "\n####################################################################################################"
for i in $PROJECT_DIR/T1_images/*; do
if [[ "$(ls -A $i/)" ]]; then
echo -e "\n\nBeginning hippodeep_pytorch segmentation on all T1 subject files for $i.\n\n"
#sh /c/Users/kmadi/hippodeep_pytorch/deepseg1.sh $i/*.nii.gz # Initiate hippodeep_pytorch segmentation on subject T1 scans
sh /path/to/hippodeep_pytorch/deepseg1.sh $i/*.nii # Initiate hippodeep_pytorch segmentation on subject T1 scans
mkdir -p $i/masks_L/hippo; mv $i/*mask_L.nii.gz $i/masks_L/hippo # Move mask_L .nii files to respective folder
mkdir -p $i/masks_R/hippo; mv $i/*mask_R.nii.gz $i/masks_R/hippo # Move mask_R .nii files to respective folder
mkdir -p $i/hippodeep_scratch_seg/ # Make folder to dump all extraneous hippodeep files into
mv $i/*brain_mask* $i/hippodeep_scratch_seg/ # Dump all extraneous hippodeep files into folder
mv $i/*cerebrum_mask* $i/hippodeep_scratch_seg/ # Dump all extraneous hippodeep files into folder
mv $i/*volumes* $i/hippodeep_scratch_seg/ # Dump all extraneous hippodeep files into folder
mv $i/*report* $i/hippodeep_scratch_seg/ # Dump all extraneous hippodeep files into folder
echo -e "\n\nSegmentation of subject T1 scans are completed. Left and right hippocampal masks can be found in the respective 'masks_L' or 'masks_R' folder."
else
echo "\nERROR: No .nii files located in $i directory. Segmentation cannot begin."
exit 1
fi
done
echo -e "\n\n####################################################################################################"
echo -e "\nAll segmentations complete."
echo -e "\n####################################################################################################"
########################################################################################################################################################################################################
# Program is complete
echo -e "\n\n####################################################################################################"
echo -e "\nNOTICE: The hippodeep_pytorch segmentation program has completed."
echo -e "\n####################################################################################################"