Skip to content

Commit 0b3a116

Browse files
authored
Merge pull request #2069 from effigies/enh/single_flirt_log
ENH: Only write FLIRT log if not previously written
2 parents 0cbe5f5 + 6b08c27 commit 0b3a116

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

nipype/interfaces/fsl/preprocess.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,27 +549,30 @@ class FLIRT(FSLCommand):
549549
_cmd = 'flirt'
550550
input_spec = FLIRTInputSpec
551551
output_spec = FLIRTOutputSpec
552+
_log_written = False
552553

553554
def aggregate_outputs(self, runtime=None, needed_outputs=None):
554555
outputs = super(FLIRT, self).aggregate_outputs(
555556
runtime=runtime, needed_outputs=needed_outputs)
556-
if isdefined(self.inputs.save_log) and self.inputs.save_log:
557+
if self.inputs.save_log and not self._log_written:
557558
with open(outputs.out_log, "a") as text_file:
558559
text_file.write(runtime.stdout + '\n')
560+
self._log_written = True
559561
return outputs
560562

561563
def _parse_inputs(self, skip=None):
562-
skip = []
563-
if isdefined(self.inputs.save_log) and self.inputs.save_log:
564-
if not isdefined(self.inputs.verbose) or self.inputs.verbose == 0:
565-
self.inputs.verbose = 1
566-
if isdefined(self.inputs.apply_xfm) and self.inputs.apply_xfm:
567-
if not self.inputs.in_matrix_file and not self.inputs.uses_qform:
568-
raise RuntimeError('Argument apply_xfm requires in_matrix_file '
569-
'or uses_qform arguments to run')
564+
if skip is None:
565+
skip = []
566+
if self.inputs.save_log and not self.inputs.verbose:
567+
self.inputs.verbose = 1
568+
if self.inputs.apply_xfm and not (self.inputs.in_matrix_file or
569+
self.inputs.uses_qform):
570+
raise RuntimeError('Argument apply_xfm requires in_matrix_file or '
571+
'uses_qform arguments to run')
570572
skip.append('save_log')
571573
return super(FLIRT, self)._parse_inputs(skip=skip)
572574

575+
573576
class ApplyXFMInputSpec(FLIRTInputSpec):
574577
apply_xfm = traits.Bool(
575578
True, argstr='-applyxfm',

0 commit comments

Comments
 (0)