Skip to content

Commit fbeba07

Browse files
committed
Merge pull request #1475 from BRAINSia/FIXRobustTemplate
FIX: Fixes createTemplate function
2 parents 925d94f + f00ae36 commit fbeba07

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nipype/workflows/smri/freesurfer/autorecon1.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def createTemplate(in_files, out_file):
167167
import os
168168
import shutil
169169
if len(in_files) == 1:
170+
# if only 1 T1 scan given, no need to run RobustTemplate
170171
print("WARNING: only one run found. This is OK, but motion correction " +
171172
"cannot be performed on one run, so I'll copy the run to rawavg " +
172173
"and continue.")
@@ -175,7 +176,7 @@ def createTemplate(in_files, out_file):
175176
transforms = None
176177
else:
177178
from nipype.interfaces.freesurfer import RobustTemplate
178-
# if multiple T1 scans are given
179+
# if multiple T1 scans are given run RobustTemplate
179180
intensity_scales = [os.path.basename(f.replace('.mgz', '-iscale.txt')) for f in in_files]
180181
transforms = [os.path.basename(f.replace('.mgz', '.lta')) for f in in_files]
181182
robtemp = RobustTemplate()
@@ -190,10 +191,11 @@ def createTemplate(in_files, out_file):
190191
robtemp.inputs.transform_outputs = transforms
191192
robtemp.inputs.subsample_threshold = 200
192193
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]
197199
out_file = os.path.abspath(out_file)
198200
return out_file, intensity_scales, transforms
199201

0 commit comments

Comments
 (0)