-
Notifications
You must be signed in to change notification settings - Fork 4
/
23_GO_FS
executable file
·156 lines (96 loc) · 2.88 KB
/
23_GO_FS
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/tcsh -ef
# add 'x' to '-ef' to trace code as it is executed
##### GO_FS2 - The "Easy" button #####
##### Usage: GO_FS <subjects directory name>
##### Feeds multiple subjects into autorecon2
##### Requires that original scan data be placed in $SUBJECTS_DIR/_orig_
##### (Place each subject's anat series in separate folders)
if ( $#argv == 0 ) then
echo "Usage: $0 <subject dir> <additional params to pass to auto-recon> "
exit 1
endif
echo "\n <><><><><><><><><><><>< GO FreeSurfer! ><><><><><><><><><><><> \n"
### Check if subjects directory specified ###
if ( "$1" != "" ) then
set subjdir = $1
else
echo "\n ERROR: No subjects directory specified \n"
exit 1
endif
### Set FREESURFER_HOME and SUBJECTS_DIR ###
source fshome.csh
if ( -e $SUBJECTS_DIR/$subjdir) then
setenv SUBJECTS_DIR $SUBJECTS_DIR/$subjdir
else
echo "\n ERROR: Specified subjects directory does not exist \n"
exit 1
endif
### Check if original scan data exists ###
if ( ! -e $SUBJECTS_DIR/_orig_ ) then
echo "\n ERROR: Original scan data not found. \n"
exit 1
endif
### disable functional tools ###
setenv NO_FSFAST
##### (To enable functional tools, disable the above line, enable the following:)
##### (HAVE NOT TESTED THIS YET) (MAYBE BETTER IF NO_FSFAST ANYWAYS)
#setenv FUNCTIONALS_DIR $FREESURFER_HOME/sessions
# echo "FUNCTIONALS_DIR = $FUNCTIONALS_DIR"
##### (and add the following to ~/matlab/startup.m)
#fsfasthome = getenv('FSFAST_HOME');
#fsfasttoolbox = sprintf('%s/toolbox',fsfasthome');
#path(path,fsfasttoolbox);
### Set up FreeSurfer ###
setenv prompt
source $FREESURFER_HOME/FreeSurferEnv.csh
echo ""
### List out directories in _orig_ , set subj array, prompt to continue ###
echo "Found the following subjects: \n"
set i = 0
set subjID
foreach d ($SUBJECTS_DIR/_orig_/*)
@ i++
set subjID = ($subjID $d:t)
echo " Subject "$i": " $subjID[$i]
end
set subjCount = $i
set response
while ($response != "n" && $response != "y")
echo -n "\n Process these $subjCount subjects? [y/n] > "
set response = $<
end
if ($response == "n") then
echo "\n Program ended by user \n"
exit 1
endif
### Run autorecon2 for each subject ###
cd $SUBJECTS_DIR
if ($#argv > 1) then
set nargs = $argv[2-$#argv]
else
set nargs = ""
endif
set i = 0
while ($i < $subjCount)
@ i++
echo "\n<><><><><><><><><><><><| NOW PROCESSING <"$subjID[$i]"> |><><><><><><><><><><><>\n"
recon-all -autorecon2 -autorecon3 -s $subjID[$i] $nargs
end
echo ""
date +"Finished $0 without error at %T on %a %b %d %Y"
echo ""
exit 0
#######################
### Simple working loop
#set i = 0
#while ($i < 10)
# echo $i
# @ i++
#end
#######################
#############
### TO DO ###
#############
# why don't env's remain 'set' after running this? (they do after running SetUpFreeSurfer.csh or FreeSurferEnv.csh)
# why can't FS_FAST be set up?
# eliminate _orig_ checks? (replace with SUBJECTS_DIR checks)