@@ -167,6 +167,7 @@ def createTemplate(in_files, out_file):
167
167
import os
168
168
import shutil
169
169
if len (in_files ) == 1 :
170
+ # if only 1 T1 scan given, no need to run RobustTemplate
170
171
print ("WARNING: only one run found. This is OK, but motion correction " +
171
172
"cannot be performed on one run, so I'll copy the run to rawavg " +
172
173
"and continue." )
@@ -175,7 +176,7 @@ def createTemplate(in_files, out_file):
175
176
transforms = None
176
177
else :
177
178
from nipype .interfaces .freesurfer import RobustTemplate
178
- # if multiple T1 scans are given
179
+ # if multiple T1 scans are given run RobustTemplate
179
180
intensity_scales = [os .path .basename (f .replace ('.mgz' , '-iscale.txt' )) for f in in_files ]
180
181
transforms = [os .path .basename (f .replace ('.mgz' , '.lta' )) for f in in_files ]
181
182
robtemp = RobustTemplate ()
@@ -190,10 +191,11 @@ def createTemplate(in_files, out_file):
190
191
robtemp .inputs .transform_outputs = transforms
191
192
robtemp .inputs .subsample_threshold = 200
192
193
robtemp .inputs .intensity_scaling = True
193
- robtemp .run ()
194
- intensity_scales = [os .path .abspath (f ) for f in robtemp .outputs .scaled_intensity_outputs ]
195
- transforms = [os .path .abspath (f ) for f in robtemp .outputs .transform_outputs ]
196
- out_file = robtemp .outputs .out_file
194
+ robtemp_result = robtemp .run ()
195
+ # collect the outputs from RobustTemplate
196
+ out_file = robtemp_result .outputs .out_file
197
+ intensity_scales = [os .path .abspath (f ) for f in robtemp_result .outputs .scaled_intensity_outputs ]
198
+ transforms = [os .path .abspath (f ) for f in robtemp_result .outputs .transform_outputs ]
197
199
out_file = os .path .abspath (out_file )
198
200
return out_file , intensity_scales , transforms
199
201
0 commit comments