|
41 | 41 | # and does not attempt any further processing.
|
42 | 42 | set -e
|
43 | 43 |
|
44 |
| -# Load function libraries |
45 |
| -source ${HCPPIPEDIR}/global/scripts/log.shlib # Logging related functions |
46 |
| -source ${HCPPIPEDIR}/global/scripts/opts.shlib # Command line option funtions |
47 |
| - |
48 |
| -# Establish tool name for logging |
49 |
| -log_SetToolName "TaskfMRIAnalysis.sh" |
50 |
| - |
51 |
| -# Other utility functions |
52 | 44 |
|
53 |
| -get_fsl_version() |
54 |
| -{ |
55 |
| - local fsl_version_file |
56 |
| - local fsl_version |
57 |
| - local __functionResultVar=${1} |
| 45 | +########################################## PREPARE FUNCTIONS ########################################## |
58 | 46 |
|
59 |
| - fsl_version_file="${FSLDIR}/etc/fslversion" |
60 |
| - |
61 |
| - if [ -f ${fsl_version_file} ] |
62 |
| - then |
63 |
| - fsl_version=`cat ${fsl_version_file}` |
64 |
| - log_Msg "INFO: Determined that the FSL version in use is ${fsl_version}" |
65 |
| - else |
66 |
| - log_Msg "ERROR: Cannot tell which version of FSL you are using." |
67 |
| - exit 1 |
68 |
| - fi |
| 47 | +# Load function libraries |
| 48 | +source ${HCPPIPEDIR}/global/scripts/log.shlib # Logging related functions |
| 49 | +source ${HCPPIPEDIR}/global/scripts/opts.shlib # Command line option functions |
| 50 | +source ${HCPPIPEDIR}/global/scripts/fsl_version.shlib # Function for getting FSL version |
69 | 51 |
|
70 |
| - eval $__functionResultVar="'${fsl_version}'" |
71 |
| -} |
72 | 52 |
|
73 |
| -# |
74 |
| -# NOTE: |
75 |
| -# Don't echo anything in this function other than the last echo |
76 |
| -# that outputs the return value |
77 |
| -# |
| 53 | +# function to test FSL versions |
78 | 54 | determine_old_or_new_fsl()
|
79 | 55 | {
|
| 56 | + # NOTE: |
| 57 | + # Don't echo anything in this function other than the last echo |
| 58 | + # that outputs the return value |
| 59 | + # |
80 | 60 | local fsl_version=${1}
|
81 | 61 | local old_or_new
|
82 | 62 | local fsl_version_array
|
@@ -130,135 +110,122 @@ determine_old_or_new_fsl()
|
130 | 110 | }
|
131 | 111 |
|
132 | 112 |
|
| 113 | +########################################## READ_ARGS ################################## |
| 114 | + |
| 115 | +# Explcitly set tool name for logging |
| 116 | +log_SetToolName "TaskfMRIAnalysis.sh" |
| 117 | + |
133 | 118 | # Show version of HCP Pipeline Scripts in use if requested
|
134 | 119 | opts_ShowVersionIfRequested $@
|
135 | 120 |
|
136 |
| -log_Msg "Parsing Command Line Options" |
137 |
| - |
| 121 | +# Parse expected arguments from command-line array |
| 122 | +log_Msg "READ_ARGS: Parsing Command Line Options" |
138 | 123 | Path=`opts_GetOpt1 "--path" $@`
|
139 |
| -log_Msg "Path: ${Path}" |
140 |
| - |
141 | 124 | Subject=`opts_GetOpt1 "--subject" $@`
|
142 |
| -log_Msg "Subject: ${Subject}" |
143 |
| - |
144 | 125 | LevelOnefMRINames=`opts_GetOpt1 "--lvl1tasks" $@`
|
145 |
| -log_Msg "LevelOnefMRINames: ${LevelOnefMRINames}" |
146 |
| - |
147 | 126 | LevelOnefsfNames=`opts_GetOpt1 "--lvl1fsfs" $@`
|
148 |
| -log_Msg "LevelOnefsfNames: ${LevelOnefsfNames}" |
149 |
| - |
150 | 127 | LevelTwofMRIName=`opts_GetOpt1 "--lvl2task" $@`
|
151 |
| -log_Msg "LevelTwofMRIName: ${LevelTwofMRIName}" |
152 |
| - |
153 | 128 | LevelTwofsfNames=`opts_GetOpt1 "--lvl2fsf" $@`
|
154 |
| -log_Msg "LevelTwofsfNames: ${LevelTwofsfNames}" |
155 |
| - |
156 | 129 | LowResMesh=`opts_GetOpt1 "--lowresmesh" $@`
|
157 |
| -log_Msg "LowResMesh: ${LowResMesh}" |
158 |
| - |
159 | 130 | GrayordinatesResolution=`opts_GetOpt1 "--grayordinatesres" $@`
|
160 |
| -log_Msg "GrayordinatesResolution: ${GrayordinatesResolution}" |
161 |
| - |
162 | 131 | OriginalSmoothingFWHM=`opts_GetOpt1 "--origsmoothingFWHM" $@`
|
163 |
| -log_Msg "OriginalSmoothingFWHM: ${OriginalSmoothingFWHM}" |
164 |
| - |
165 | 132 | Confound=`opts_GetOpt1 "--confound" $@`
|
166 |
| -log_Msg "Confound: ${Confound}" |
167 |
| - |
168 | 133 | FinalSmoothingFWHM=`opts_GetOpt1 "--finalsmoothingFWHM" $@`
|
169 |
| -log_Msg "FinalSmoothingFWHM: ${FinalSmoothingFWHM}" |
170 |
| - |
171 | 134 | TemporalFilter=`opts_GetOpt1 "--temporalfilter" $@`
|
172 |
| -log_Msg "TemporalFilter: ${TemporalFilter}" |
173 |
| - |
174 | 135 | VolumeBasedProcessing=`opts_GetOpt1 "--vba" $@`
|
175 |
| -log_Msg "VolumeBasedProcessing: ${VolumeBasedProcessing}" |
176 |
| - |
177 | 136 | RegName=`opts_GetOpt1 "--regname" $@`
|
178 |
| -log_Msg "RegName: ${RegName}" |
179 |
| - |
180 | 137 | Parcellation=`opts_GetOpt1 "--parcellation" $@`
|
181 |
| -log_Msg "Parcellation: ${Parcellation}" |
182 |
| - |
183 | 138 | ParcellationFile=`opts_GetOpt1 "--parcellationfile" $@`
|
184 |
| -log_Msg "ParcellationFile: ${ParcellationFile}" |
185 | 139 |
|
186 |
| -# Determine the version of FSL that is in use |
187 |
| -get_fsl_version fsl_ver |
188 |
| -log_Msg "FSL version: ${fsl_ver}" |
189 |
| - |
190 |
| -# Determine whether to invoke the "OLD" (v1.0) or "NEW" (v2.0) version of Task fMRI Analysis |
| 140 | +# Write command-line arguments to log file |
| 141 | +log_Msg "READ_ARGS: Path: ${Path}" |
| 142 | +log_Msg "READ_ARGS: Subject: ${Subject}" |
| 143 | +log_Msg "READ_ARGS: LevelOnefMRINames: ${LevelOnefMRINames}" |
| 144 | +log_Msg "READ_ARGS: LevelOnefsfNames: ${LevelOnefsfNames}" |
| 145 | +log_Msg "READ_ARGS: LevelTwofMRIName: ${LevelTwofMRIName}" |
| 146 | +log_Msg "READ_ARGS: LevelTwofsfNames: ${LevelTwofsfNames}" |
| 147 | +log_Msg "READ_ARGS: LowResMesh: ${LowResMesh}" |
| 148 | +log_Msg "READ_ARGS: GrayordinatesResolution: ${GrayordinatesResolution}" |
| 149 | +log_Msg "READ_ARGS: OriginalSmoothingFWHM: ${OriginalSmoothingFWHM}" |
| 150 | +log_Msg "READ_ARGS: Confound: ${Confound}" |
| 151 | +log_Msg "READ_ARGS: FinalSmoothingFWHM: ${FinalSmoothingFWHM}" |
| 152 | +log_Msg "READ_ARGS: TemporalFilter: ${TemporalFilter}" |
| 153 | +log_Msg "READ_ARGS: VolumeBasedProcessing: ${VolumeBasedProcessing}" |
| 154 | +log_Msg "READ_ARGS: RegName: ${RegName}" |
| 155 | +log_Msg "READ_ARGS: Parcellation: ${Parcellation}" |
| 156 | +log_Msg "READ_ARGS: ParcellationFile: ${ParcellationFile}" |
| 157 | + |
| 158 | + |
| 159 | +########################################## MAIN ######################################### |
| 160 | + |
| 161 | +# Determine if required FSL version is present |
| 162 | +fsl_version_get fsl_ver |
191 | 163 | old_or_new_version=$(determine_old_or_new_fsl ${fsl_ver})
|
192 |
| - |
193 | 164 | if [ "${old_or_new_version}" == "OLD" ]
|
194 | 165 | then
|
195 | 166 | # Need to exit script due to incompatible FSL VERSION!!!!
|
196 |
| - log_Msg "ERROR: Detected pre-5.0.7 version of FSL is in use. Task fMRI Analysis not invoked." |
| 167 | + log_Msg "MAIN: TEST_FSL_VERSION: ERROR: Detected pre-5.0.7 version of FSL in use (version ${fsl_ver}). Task fMRI Analysis not invoked. Exiting." |
197 | 168 | exit 1
|
198 | 169 | else
|
199 |
| - log_Msg "INFO: Detected version 5.0.7 or newer of FSL is in use. Invoking Level1 and Level2 scripts." |
200 |
| - |
201 |
| - #Naming Conventions |
202 |
| - AtlasFolder="${Path}/${Subject}/MNINonLinear" |
203 |
| - ResultsFolder="${AtlasFolder}/Results" |
204 |
| - ROIsFolder="${AtlasFolder}/ROIs" |
205 |
| - DownSampleFolder="${AtlasFolder}/fsaverage_LR${LowResMesh}k" |
206 |
| - |
207 |
| - #Run Level One Analysis for Both Phase Encoding Directions |
208 |
| - log_Msg "Run Level One Analysis for Both Phase Encoding Directions" |
209 |
| - |
210 |
| - LevelOnefMRINames=`echo $LevelOnefMRINames | sed 's/@/ /g'` |
211 |
| - LevelOnefsfNames=`echo $LevelOnefsfNames | sed 's/@/ /g'` |
212 |
| - |
213 |
| - i=1 |
214 |
| - for LevelOnefMRIName in $LevelOnefMRINames ; do |
215 |
| - log_Msg "LevelOnefMRIName: ${LevelOnefMRIName}" |
216 |
| - LevelOnefsfName=`echo $LevelOnefsfNames | cut -d " " -f $i` |
217 |
| - log_Msg "Issued command: ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel1.sh $Subject $ResultsFolder $ROIsFolder $DownSampleFolder $LevelOnefMRIName $LevelOnefsfName $LowResMesh $GrayordinatesResolution $OriginalSmoothingFWHM $Confound $FinalSmoothingFWHM $TemporalFilter $VolumeBasedProcessing $RegName $Parcellation $ParcellationFile" |
218 |
| - ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel1.sh \ |
219 |
| - $Subject \ |
220 |
| - $ResultsFolder \ |
221 |
| - $ROIsFolder \ |
222 |
| - $DownSampleFolder \ |
223 |
| - $LevelOnefMRIName \ |
224 |
| - $LevelOnefsfName \ |
225 |
| - $LowResMesh \ |
226 |
| - $GrayordinatesResolution \ |
227 |
| - $OriginalSmoothingFWHM \ |
228 |
| - $Confound \ |
229 |
| - $FinalSmoothingFWHM \ |
230 |
| - $TemporalFilter \ |
231 |
| - $VolumeBasedProcessing \ |
232 |
| - $RegName \ |
233 |
| - $Parcellation \ |
234 |
| - $ParcellationFile |
235 |
| - i=$(($i+1)) |
236 |
| - done |
237 |
| - |
238 |
| - if [ "$LevelTwofMRIName" != "NONE" ] |
239 |
| - then |
240 |
| - LevelOnefMRINames=`echo $LevelOnefMRINames | sed 's/ /@/g'` |
241 |
| - LevelOnefsfNames=`echo $LevelOnefMRINames | sed 's/ /@/g'` |
| 170 | + log_Msg "MAIN: TEST_FSL_VERSION: Beginning analyses with FSL version ${fsl_ver}" |
| 171 | +fi |
242 | 172 |
|
243 |
| - #Combine Data Across Phase Encoding Directions in the Level Two Analysis |
244 |
| - log_Msg "Combine Data Across Phase Encoding Directions in the Level Two Analysis" |
245 |
| - log_Msg "Issued command: ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel2.sh $Subject $ResultsFolder $DownSampleFolder $LevelOnefMRINames $LevelOnefsfNames $LevelTwofMRIName $LevelTwofsfNames $LowResMesh $FinalSmoothingFWHM $TemporalFilter $VolumeBasedProcessing $RegName $Parcellation" |
246 |
| - ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel2.sh \ |
247 |
| - $Subject \ |
248 |
| - $ResultsFolder \ |
249 |
| - $DownSampleFolder \ |
250 |
| - $LevelOnefMRINames \ |
251 |
| - $LevelOnefsfNames \ |
252 |
| - $LevelTwofMRIName \ |
253 |
| - $LevelTwofsfNames \ |
254 |
| - $LowResMesh \ |
255 |
| - $FinalSmoothingFWHM \ |
256 |
| - $TemporalFilter \ |
257 |
| - $VolumeBasedProcessing \ |
258 |
| - $RegName \ |
259 |
| - $Parcellation |
260 |
| - fi |
| 173 | +# Determine locations of necessary directories (using expected naming convention) |
| 174 | +AtlasFolder="${Path}/${Subject}/MNINonLinear" |
| 175 | +ResultsFolder="${AtlasFolder}/Results" |
| 176 | +ROIsFolder="${AtlasFolder}/ROIs" |
| 177 | +DownSampleFolder="${AtlasFolder}/fsaverage_LR${LowResMesh}k" |
| 178 | + |
| 179 | + |
| 180 | +# Run Level 1 analyses for each phase encoding direction (from command line arguments) |
| 181 | +log_Msg "MAIN: RUN_LEVEL1: Running Level 1 Analysis for Both Phase Encoding Directions" |
| 182 | +i=1 |
| 183 | +# Level 1 analysis names were delimited by '@' in command-line; change to space in for loop |
| 184 | +for LevelOnefMRIName in $( echo $LevelOnefMRINames | sed 's/@/ /g' ) ; do |
| 185 | + log_Msg "MAIN: RUN_LEVEL1: LevelOnefMRIName: ${LevelOnefMRIName}" |
| 186 | + # Get corresponding fsf name from $LevelOnefsfNames list |
| 187 | + LevelOnefsfName=`echo $LevelOnefsfNames | cut -d "@" -f $i` |
| 188 | + log_Msg "MAIN: RUN_LEVEL1: Issuing command: ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel1.sh $Subject $ResultsFolder $ROIsFolder $DownSampleFolder $LevelOnefMRIName $LevelOnefsfName $LowResMesh $GrayordinatesResolution $OriginalSmoothingFWHM $Confound $FinalSmoothingFWHM $TemporalFilter $VolumeBasedProcessing $RegName $Parcellation $ParcellationFile" |
| 189 | + ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel1.sh \ |
| 190 | + $Subject \ |
| 191 | + $ResultsFolder \ |
| 192 | + $ROIsFolder \ |
| 193 | + $DownSampleFolder \ |
| 194 | + $LevelOnefMRIName \ |
| 195 | + $LevelOnefsfName \ |
| 196 | + $LowResMesh \ |
| 197 | + $GrayordinatesResolution \ |
| 198 | + $OriginalSmoothingFWHM \ |
| 199 | + $Confound \ |
| 200 | + $FinalSmoothingFWHM \ |
| 201 | + $TemporalFilter \ |
| 202 | + $VolumeBasedProcessing \ |
| 203 | + $RegName \ |
| 204 | + $Parcellation \ |
| 205 | + $ParcellationFile |
| 206 | + i=$(($i+1)) |
| 207 | +done |
| 208 | + |
| 209 | +if [ "$LevelTwofMRIName" != "NONE" ] |
| 210 | +then |
| 211 | + # Combine Data Across Phase Encoding Directions in the Level 2 Analysis |
| 212 | + log_Msg "MAIN: RUN_LEVEL2: Combine Data Across Phase Encoding Directions in the Level 2 Analysis" |
| 213 | + log_Msg "MAIN: RUN_LEVEL2: Issuing command: ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel2.sh $Subject $ResultsFolder $DownSampleFolder $LevelOnefMRINames $LevelOnefsfNames $LevelTwofMRIName $LevelTwofsfNames $LowResMesh $FinalSmoothingFWHM $TemporalFilter $VolumeBasedProcessing $RegName $Parcellation" |
| 214 | + ${HCPPIPEDIR_tfMRIAnalysis}/TaskfMRILevel2.sh \ |
| 215 | + $Subject \ |
| 216 | + $ResultsFolder \ |
| 217 | + $DownSampleFolder \ |
| 218 | + $LevelOnefMRINames \ |
| 219 | + $LevelOnefsfNames \ |
| 220 | + $LevelTwofMRIName \ |
| 221 | + $LevelTwofsfNames \ |
| 222 | + $LowResMesh \ |
| 223 | + $FinalSmoothingFWHM \ |
| 224 | + $TemporalFilter \ |
| 225 | + $VolumeBasedProcessing \ |
| 226 | + $RegName \ |
| 227 | + $Parcellation |
261 | 228 | fi
|
262 | 229 |
|
263 |
| -log_Msg "Completed" |
| 230 | +log_Msg "MAIN: Completed" |
264 | 231 |
|
0 commit comments