Skip to content

Afni nwarpadjust #2450

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 7 commits into from
Mar 23, 2018
Merged

Afni nwarpadjust #2450

merged 7 commits into from
Mar 23, 2018

Conversation

salma1601
Copy link
Contributor

add interface for AFNI 3dNwarpAdjust

@codecov-io
Copy link

codecov-io commented Feb 18, 2018

Codecov Report

Merging #2450 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2450      +/-   ##
==========================================
- Coverage   66.86%   66.86%   -0.01%     
==========================================
  Files         328      328              
  Lines       42560    42586      +26     
  Branches     5282     5287       +5     
==========================================
+ Hits        28457    28474      +17     
- Misses      13405    13412       +7     
- Partials      698      700       +2
Flag Coverage Δ
#smoketests 50.79% <ø> (ø) ⬆️
#unittests 64.21% <50%> (-0.04%) ⬇️
Impacted Files Coverage Δ
nipype/interfaces/afni/__init__.py 100% <ø> (ø) ⬆️
nipype/interfaces/afni/utils.py 81.55% <50%> (-1.29%) ⬇️
nipype/pipeline/plugins/multiproc.py 82.14% <0%> (+2.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04b440a...3a27625. Read the comment docs.

name_source='in_files',
name_template='%s_NwarpAdjust',
keep_extension=True,
xand=['in_files'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this since in_files is mandatory. also there is no xand in the current spec. so make specs would have returned a violation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I am trying to make in_files not mandatory, because what is needed here is only the warps

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe what you want is requires=['in_files']. See https://nipype.readthedocs.io/en/latest/devel/interface_specs.html.

'The output dataset will be on the common grid shared by the '
'source datasets.',
argstr='-prefix %s',
mandatory=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and in the previous input field mandatory=False is not necessary.

input_spec = NwarpAdjustInputSpec
output_spec = AFNICommandOutputSpec

def _parse_inputs(self, skip=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this function can be skipped as well.

@effigies effigies added this to the 1.0.2 milestone Feb 23, 2018
@effigies
Copy link
Member

effigies commented Mar 2, 2018

Hi @salma1601 do you have some time to address @satra's comments? If you have any questions, please let us know.

@salma1601
Copy link
Contributor Author

@effigies when I remove the _parse_inputs function, the command line has -prefix so I think it should be maintained no ?

@effigies
Copy link
Member

effigies commented Mar 9, 2018

Please merge master to fix the tests.

I'm not very familiar with _parse_inputs, so I can't say without trying with and without your _parse_inputs method whether it's required. Have you tried removing it and verifying that your interface no longer works?

Copy link
Member

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @salma1601, I think we can reduce the amount of boilerplate on this interface. Could you try out the suggested changes and see if things are still running okay?

@@ -1516,6 +1516,90 @@ def _list_outputs(self):
return outputs


class NwarpAdjustInputSpec(CommandLineInputSpec):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(AfniCommandInputSpec)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

skip += ['out_file']
return super(NwarpAdjust, self)._parse_inputs(skip=skip)

def _gen_filename(self, name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably isn't necessary either since you're calling name_source in the inputspec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


def _list_outputs(self):
outputs = self.output_spec().get()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this can be cleaned up to just

...
if self.inputs.in_files:
    outputs['out_file'] = os.path.abspath(self.inputs.out_file)
return outputs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't work when I don't give exactly how to build outputs['out_file'] from in_files: the command line is correct but it fails at returning the outputs and I have an error

@salma1601
Copy link
Contributor Author

I'm not very familiar with _parse_inputs, so I can't say without trying with and without your _parse_inputs method whether it's required. Have you tried removing it and verifying that your interface no longer works?

Yes I tried, the command line is wrong without _parse_inputs
3dNwarpAdjust -prefix <undefined>_NwarpAdjust -nwarp /tmp/out_warp.nii.gz /tmp/out_warp.nii.gz /tmp/out_warp.nii.gz /tmp/out_warp.nii.gz /tmp/out_warp.nii.gz

@oesteban
Copy link
Contributor

@satra I think @salma1601 just discovered a bug here: if a trait with name_source points to an undefined input, then it is replaced anyways. We should address that first.

@satra
Copy link
Member

satra commented Mar 13, 2018

@oesteban - yes we should track this, but since the out_file has requires, it should fail without in_files being present. the mandatory inputs check is passing, which it shouldn't or out_file shouldn't be generated.

@oesteban
Copy link
Contributor

maybe the ordering: filling the name_template is triggered before the requires?

@oesteban
Copy link
Contributor

Actually, the requires should be independent (and not used in this case: I should be able to overwrite the out_file field myself without providing in_files)

@satra
Copy link
Member

satra commented Mar 13, 2018

we should figure out the logic here.

if requires is present then setting or using out_file to generate out_file needs in_files.

otherwise the logic here is stating,

if out_file use out_file
if undefined(out_file) and in_files then use name_source
else (currently not defined)

perhaps in this scenario, there should be a default out_file (using usedefault=True) and no namesource.

@effigies
Copy link
Member

@satra @oesteban Is this something likely to be resolved this week? And should this hold up the current PR, or should we merge and create an issue for fixing this bug that's being worked around?

@effigies
Copy link
Member

Just a bump on this. My vote is to fix the name_source issues in a separate PR (probably next release). Any objections? @satra @oesteban

@effigies
Copy link
Member

Two thumbs up, so in it goes. I'll create an issue for 1.0.3.

@effigies effigies merged commit 8e25ba7 into nipy:master Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants