-
Notifications
You must be signed in to change notification settings - Fork 533
[FIX] fix afni.allineate interface #2502
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
Changes from 6 commits
234893e
34f67b4
ef25d15
32cd9b8
4179f5c
78f68ae
cda56e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,7 +218,9 @@ class AllineateInputSpec(AFNICommandInputSpec): | |
out_file = File( | ||
desc='output file from 3dAllineate', | ||
argstr='-prefix %s', | ||
genfile=True, | ||
name_template='%s_allineate', | ||
name_source='in_file', | ||
hash_files=False, | ||
xor=['allcostx']) | ||
out_param_file = File( | ||
argstr='-1Dparam_save %s', | ||
|
@@ -424,11 +426,11 @@ class AllineateInputSpec(AFNICommandInputSpec): | |
_dirs = ['X', 'Y', 'Z', 'I', 'J', 'K'] | ||
nwarp_fixmot = traits.List( | ||
traits.Enum(*_dirs), | ||
argstr='-nwarp_fixmot%s', | ||
argstr='-nwarp_fixmot%s...', | ||
desc='To fix motion along directions.') | ||
nwarp_fixdep = traits.List( | ||
traits.Enum(*_dirs), | ||
argstr='-nwarp_fixdep%s', | ||
argstr='-nwarp_fixdep%s...', | ||
desc='To fix non-linear warp dependency along directions.') | ||
verbose = traits.Bool( | ||
argstr='-verb', desc='Print out verbose progress reports.') | ||
|
@@ -465,31 +467,29 @@ class Allineate(AFNICommand): | |
'3dAllineate -source functional.nii -prefix functional_allineate.nii -1Dmatrix_apply cmatrix.mat' | ||
>>> res = allineate.run() # doctest: +SKIP | ||
|
||
>>> from nipype.interfaces import afni | ||
>>> allineate = afni.Allineate() | ||
>>> allineate.inputs.in_file = 'functional.nii' | ||
>>> allineate.inputs.reference = 'structural.nii' | ||
>>> allineate.inputs.allcostx = 'out.allcostX.txt' | ||
>>> allineate.cmdline | ||
'3dAllineate -source functional.nii -base structural.nii -allcostx |& tee out.allcostX.txt' | ||
>>> res = allineate.run() # doctest: +SKIP | ||
|
||
>>> allineate = afni.Allineate() | ||
>>> allineate.inputs.in_file = 'functional.nii' | ||
>>> allineate.inputs.reference = 'structural.nii' | ||
>>> allineate.inputs.nwarp_fixmot = ['X', 'Y'] | ||
>>> allineate.cmdline | ||
'3dAllineate -source functional.nii -nwarp_fixmotX -nwarp_fixmotY -prefix functional_allineate -base structural.nii' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question: Is @tsalo @salma1601 You might also be good people to chime in here. |
||
>>> res = allineate.run() # doctest: +SKIP | ||
""" | ||
|
||
_cmd = '3dAllineate' | ||
input_spec = AllineateInputSpec | ||
output_spec = AllineateOutputSpec | ||
|
||
def _format_arg(self, name, trait_spec, value): | ||
if name == 'nwarp_fixmot' or name == 'nwarp_fixdep': | ||
arg = ' '.join([trait_spec.argstr % v for v in value]) | ||
return arg | ||
return super(Allineate, self)._format_arg(name, trait_spec, value) | ||
|
||
def _list_outputs(self): | ||
outputs = self.output_spec().get() | ||
|
||
if self.inputs.out_file: | ||
outputs['out_file'] = op.abspath(self.inputs.out_file) | ||
outputs = super(Allineate, self)._list_outputs() | ||
|
||
if self.inputs.out_weight_file: | ||
outputs['out_weight_file'] = op.abspath( | ||
|
@@ -512,16 +512,10 @@ def _list_outputs(self): | |
outputs['out_param_file'] = op.abspath( | ||
self.inputs.out_param_file) | ||
|
||
if isdefined(self.inputs.allcostx): | ||
outputs['allcostX'] = os.path.abspath( | ||
os.path.join(os.getcwd(), self.inputs.allcostx)) | ||
if self.inputs.allcostx: | ||
outputs['allcostX'] = os.path.abspath(self.inputs.allcostx) | ||
return outputs | ||
|
||
def _gen_filename(self, name): | ||
if name == 'out_file': | ||
return self._list_outputs()[name] | ||
return None | ||
|
||
|
||
class AutoTcorrelateInputSpec(AFNICommandInputSpec): | ||
in_file = File( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1072,6 +1072,12 @@ def _filename_from_source(self, name, chain=None): | |
if not isdefined(retval) or "%s" in retval: | ||
if not trait_spec.name_source: | ||
return retval | ||
|
||
# Do not generate filename when excluded by other inputs | ||
if trait_spec.xor and any(isdefined(getattr(self.inputs, field)) | ||
for field in trait_spec.xor): | ||
return retval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right. I had it kind of backwards, but a similar fix to this should resolve #2506. I'll merge and propose a quick PR for that one. |
||
|
||
if isdefined(retval) and "%s" in retval: | ||
name_template = retval | ||
else: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.