-
Notifications
You must be signed in to change notification settings - Fork 533
antsRegistrationSyNQuick (continuation of #1392 and #2347) #2453
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
…_OF_THREADS env var as num_threads
@satra, I'm not sure if I used environmental variables as I decided to check if a user have |
@djarecka - that particular interface overwrites the environment variables, so setting them has no effect. you should just keep your implementation as before with creating a new num_threads field in the inputspec, effectively overwriting the base num_threads. or, more elegantly, you can keep the base num_threads, but override the parse function and the num_threads sync function. |
try: | ||
LOCAL_DEFAULT_NUMBER_OF_THREADS = int(os.getenv("LOCAL_DEFAULT_NUMBER_OF_THREADS")) | ||
except TypeError: | ||
LOCAL_DEFAULT_NUMBER_OF_THREADS = 1 |
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.
Let's just import from .base import LOCAL_DEFAULT_NUMBER_OF_THREADS
.
Also, I think in general this variable is kind of pointless, unless somebody's using a fork of nipype where it's defined as something other than 1. This isn't something that needs to be fixed in this PR, but just to flag it for others' attention.
@satra If you override |
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.
Saw a few things (in addition to earlier comment about importing LOCAL_DEFAULT_NUMBER_OF_THREADS
) that could use updating.
@satra Please chime in if I'm making suggestions that are out of line with your thoughts on the interface.
Also, please merge master to fix tests.
>>> reg.inputs.num_threads = 2 | ||
>>> reg.cmdline | ||
'antsRegistrationSynQuick.sh -d 3 -f fixed1.nii -m moving1.nii -n 2 -o transform -p d -t s' | ||
>>> reg.run() # doctest: +SKIP |
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.
From the help:
NB: Multiple image pairs can be specified for registration during the SyN stage.
Specify additional images using the '-m' and '-f' options. Note that image
pair correspondence is given by the order specified on the command line.
Only the first fixed and moving image pair is used for the linear resgitration
stages.
We should add a doctest to make sure that if fixed_image
and moving_image
are lists, that we see -f fixed1.nii -f fixed2.nii -m moving1.nii -m moving2.nii
(or similar).
It may be more trouble than it's worth to verify that the lists are of the same length.
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.
it gives -f fixed1.nii fixed2.nii -m moving1.nii moving2.nii
, but i haven't checked if it is properly propagated to the main Registration (couldn't find also examples that confirms that this is a proper command)
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.
Okay, then I think we want to change the argstr
s for fixed_image
and moving_image
to -f %s...
and -m %s...
, respectively. (The ...
will change -f A B
to -f A -f B
.)
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 pushed before reading this comment.
But do you know this is correct syntax of command line? If yes, I can change it, but just wasn't sure what is the correct syntax
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.
Yes. -f A B
will fail, while -f A -f B
will succeed.
self.inputs.output_prefix + 'InverseWarped.nii.gz') | ||
outputs['out_matrix'] = os.path.abspath(self.inputs.output_prefix + '0GenericAffine.mat') | ||
|
||
# todo in the case of linear transformation-only there won't be fields. is there a more elegant way to specify that? |
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.
What you have seems like a reasonable approach to me.
outputs = self.output_spec().get() | ||
outputs['warped_image'] = os.path.abspath(self.inputs.output_prefix + 'Warped.nii.gz') | ||
outputs['inverse_warped_image'] = os.path.abspath( | ||
self.inputs.output_prefix + 'InverseWarped.nii.gz') |
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.
Just to be a little more concise, maybe we can do the following:
out_base = os.path.abspath(self.inputs.output_prefix)
outputs['warped_image'] = out_base + 'Warped.nii.gz'
outputs['inverse_warped_image'] = out_base + 'InverseWarped.nii.gz'
and so on...
Examples | ||
-------- | ||
|
||
>>> import copy, pprint |
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're not using these imports
-------- | ||
|
||
>>> import copy, pprint | ||
>>> from nipype.interfaces.ants import Registration |
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.
RegistrationSynQuick
_cmd = 'antsRegistrationSynQuick.sh' | ||
input_spec = RegistrationSynQuickInputSpec | ||
output_spec = RegistrationSynQuickOutputSpec | ||
|
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.
Just to avoid being affected by upstream changes, we should override _num_threads_update()
to do nothing.
def _num_threads_update(self):
"""antsRegistrationSynQuick.sh ignores environment variables, so override environment update"""
|
||
class RegistrationSynQuick(ANTSCommand): | ||
""" | ||
Reistration using a symmetric image normalization method (SyN). |
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.
"Registration" (you're missing a "g").
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 :)
@djarecka Can you "Rerun failed jobs" (in the "Rerun" drop down)? https://circleci.com/workflow-run/6fb99ca4-98b4-4585-92f2-03db3046b4ae |
Need to |
sorry, forgot to update. should be better now |
Had to close #2347 after miscommunication with github...