Skip to content

ENH: Only write FLIRT log if not previously written #2069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions nipype/interfaces/fsl/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,27 +549,30 @@ class FLIRT(FSLCommand):
_cmd = 'flirt'
input_spec = FLIRTInputSpec
output_spec = FLIRTOutputSpec
_log_written = False

def aggregate_outputs(self, runtime=None, needed_outputs=None):
outputs = super(FLIRT, self).aggregate_outputs(
runtime=runtime, needed_outputs=needed_outputs)
if isdefined(self.inputs.save_log) and self.inputs.save_log:
if self.inputs.save_log and not self._log_written:
with open(outputs.out_log, "a") as text_file:
text_file.write(runtime.stdout + '\n')
self._log_written = True
return outputs

def _parse_inputs(self, skip=None):
skip = []
if isdefined(self.inputs.save_log) and self.inputs.save_log:
if not isdefined(self.inputs.verbose) or self.inputs.verbose == 0:
self.inputs.verbose = 1
if isdefined(self.inputs.apply_xfm) and self.inputs.apply_xfm:
if not self.inputs.in_matrix_file and not self.inputs.uses_qform:
raise RuntimeError('Argument apply_xfm requires in_matrix_file '
'or uses_qform arguments to run')
if skip is None:
skip = []
if self.inputs.save_log and not self.inputs.verbose:
self.inputs.verbose = 1
if self.inputs.apply_xfm and not (self.inputs.in_matrix_file or
self.inputs.uses_qform):
raise RuntimeError('Argument apply_xfm requires in_matrix_file or '
'uses_qform arguments to run')
skip.append('save_log')
return super(FLIRT, self)._parse_inputs(skip=skip)


class ApplyXFMInputSpec(FLIRTInputSpec):
apply_xfm = traits.Bool(
True, argstr='-applyxfm',
Expand Down