-
Notifications
You must be signed in to change notification settings - Fork 533
ENH: Add interpolation order parameter to NiftyReg's RegTools #2471
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
Conversation
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.
Thanks for the PR! Just a single comment
'CUB', | ||
'SINC', | ||
desc='Interpolation order to use to warp the floating image', | ||
argstr='-interp %d') |
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.
you'll want to change this to %s
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.
Thanks for the feedback. I've checked the source code and this parameter (of the command line tool) expects 0
, 1
, 3
or 4
, as in RegResample
:
nipype/nipype/interfaces/niftyreg/regutils.py
Lines 61 to 68 in 045b28e
# Interpolation type | |
inter_val = traits.Enum( | |
'NN', | |
'LIN', | |
'CUB', | |
'SINC', | |
desc='Interpolation type', | |
argstr='-inter %d') |
So I basically copied that section from RegResample
. Should anything be modified for both interfaces? I don't know much about traits, but it feels like the current code can only produce 0
, 1
, 2
or 3
.
Also, I'm a bit new to PRs. To change something, should I just commit in my local fork and push to the same branch normally?
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.
You'll need to copy this part as well:
nipype/nipype/interfaces/niftyreg/regutils.py
Lines 123 to 128 in 045b28e
def _format_arg(self, name, spec, value): | |
if name == 'inter_val': | |
inter_val = {'NN': 0, 'LIN': 1, 'CUB': 3, 'SINC': 5} | |
return spec.argstr % inter_val[value] | |
else: | |
return super(RegResample, self)._format_arg(name, spec, value) |
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.
I see. Although shouldn't line 124 be
inter_val = {'NN': 0, 'LIN': 1, 'CUB': 3, 'SINC': 4}
instead of
inter_val = {'NN': 0, 'LIN': 1, 'CUB': 3, 'SINC': 5}
?
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.
I'm not sure why 2 and 4 are skipped, perhaps @mmodat has some input.
# If change is needed, it should look something like this
inter_val = {'NN': 0, 'LIN': 1, 'CUB': 2, 'SINC': 3}
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.
Looks like it. https://cmiclab.cs.ucl.ac.uk/mmodat/niftyreg/blob/master/reg-apps/reg_resample.cpp#L65
Their documentation could certainly be clearer on the point.
Codecov Report
@@ Coverage Diff @@
## master #2471 +/- ##
==========================================
- Coverage 66.66% 66.66% -0.01%
==========================================
Files 328 328
Lines 42551 42557 +6
Branches 5276 5277 +1
==========================================
+ Hits 28366 28369 +3
- Misses 13505 13507 +2
- Partials 680 681 +1
Continue to review full report at Codecov.
|
# Need this overload to properly constraint the interpolation type input | ||
def _format_arg(self, name, spec, value): | ||
if name == 'inter_val': | ||
inter_val = {'NN': 0, 'LIN': 1, 'CUB': 3, 'SINC': 5} |
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.
Can you go ahead and change 5
to 4
here and in RegResample
?
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.
Sure
According to NiftyReg source code: https://cmiclab.cs.ucl.ac.uk/mmodat/niftyreg/blob/master/reg-apps/reg_resample.cpp#L65
Can you |
@effigies I don't know what those are. Could you please point me to an example or reference? |
In the source directory, run:
Add and commit those. |
Done, but only test_auto_RegTools.py was updated. Btw |
Yup, you're right. We didn't change the spec on the other one.
|
|
Ah. That can be resolved with |
@fepegar - this https://github.com/nipy/nipype/blob/master/nipype/info.py#L134 clarifies how bits and pieces are installed. the basic install is intended for running, not developing nipype.
we hope to clarify user/developer documentation on testing in the next update (end of march). |
I'd expect anything needed by |
We should probably update that recommendation. Everything I've read for a few years has recommended using |
@fepegar - unfortunately that's not how @effigies - we can create a |
Fixes #2470
Note: I ran
make check-before-commit
and got the following:I fixed it with
pip install yapf
.