Skip to content

WIP: antsRegistrationSyNQuick.sh wrapper #1392

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

Closed
wants to merge 2 commits into from
Closed

Conversation

fliem
Copy link
Contributor

@fliem fliem commented Mar 3, 2016

Hi guys,

I created a wrapper for antsRegistrationSyNQuick.sh. It's my first interface, so it would be great if you had suggestions for improvements (I marked a couple of issues in the code with # todo).

Additionally, I'd like to create a wrapper for antsRegistrationSyN.sh.
antsRegistrationSyNQuick.sh and antsRegistrationSyN.sh do not have completely identical input arguments:
-t (transform type) has different valid values in SyN and SyNQuick.
-r is setting a different variable
SyNQuick: -r: histogram bins for mutual information in SyN stage (default = 32);
Syn: -r: radius for cross correlation metric used during SyN stage (default = 4)
What would be the most elegant way to have interfaces for both? Two separat interfaces?

@djarecka
Copy link
Collaborator

@fliem - thanks for your work!

@oesteban - can you please check this pr when you find some time? do you have any suggestions regarding antsRegistrationSyN.sh

Copy link
Contributor

@oesteban oesteban left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this contribution, looks good in general. I left some (mostly stylistic) comments.

Beyond style, there are a couple of things that need attention:

  • It would be necessary to add the auto_test:

    1. make check-before-commit at the root folder of the repo.
    2. git add nipype/interfaces/ants/tests/test_auto_RegistrationSynQuick.py
  • Also, a better description of the interface and a doctest are missing.





Copy link
Contributor

Choose a reason for hiding this comment

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

too many empty spaces (only 2 necessary)

desc='Fixed image or source image or reference image')
moving_image = InputMultiPath(File(exists=True), mandatory=True, argstr='-m %s',
desc='Moving image or target image')
output_prefix = traits.Str("transform", usedefault=True, argstr='-o %s',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use Str from nipype base. (add from ..base import Str on the top, and then use Str instead of traits.Str here).

desc="A prefix that is prepended to all output files")

# todo ANTSCommandInputSpec already has this, but I can't figure out how to set it without defining it again
num_threads = traits.Int(default_value=1, desc='Number of threads (default = 1)', argstr='-n %d')
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure, but I think you can do traits.Int(1, desc ... here.

num_threads = traits.Int(default_value=1, desc='Number of threads (default = 1)', argstr='-n %d')

transform_type = traits.Enum('s', 't', 'r', 'a', 'sr', 'b', 'br', argstr='-t %s',
desc='transform type\n\
Copy link
Contributor

Choose a reason for hiding this comment

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

please use block strings:

transform_type = traits.Enum('s', 't', 'r', 'a', 'sr', 'b', 'br', argstr='-t %s',
                             usedefault=True, desc="""\
transform type -
t:  translation
r:  rigid
a: rigid + affine
s:  rigid + affine + deformable syn (default)
sr: rigid + deformable syn
b:  rigid + affine + deformable b-spline syn
br: rigid + deformable b-spline syn""")

br: rigid + deformable b-spline syn',
usedefault=True)

use_histogram_matching = traits.Bool(default=False, argstr='-j %s',
Copy link
Contributor

Choose a reason for hiding this comment

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

traits.Bool(False, argstr ...)

additionally: you may remove the _format_arg for this input setting argstr='-j %d'

"""
Examples
--------

Copy link
Contributor

Choose a reason for hiding this comment

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

missing doctest



class RegistrationSynQuick(ANTSCommand):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

missing brief summary

output_spec = RegistrationSynQuickOutputSpec

def _format_arg(self, name, spec, value):
if name == 'use_histogram_matching':
Copy link
Contributor

Choose a reason for hiding this comment

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

please use argstr='-j %d' and remove this


elif name == 'precision_type':
if isdefined(self.inputs.precision_type):
return spec.argstr % {'float': 'f', 'double': 'd'}[value]
Copy link
Contributor

Choose a reason for hiding this comment

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

                return spec.argstr % value[0]

return spec.argstr % {False: '0', True: '1'}[value]

elif name == 'precision_type':
if isdefined(self.inputs.precision_type):
Copy link
Contributor

Choose a reason for hiding this comment

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

this is always True since this trait has usedefault=True

@djarecka
Copy link
Collaborator

@fliem - are you planning to finish this PR. Please let us know if you need help?

@fliem
Copy link
Contributor Author

fliem commented Dec 18, 2017

Hi @djarecka. I won't have time to work on that. It would be great if you could continue. Thanks.

@djarecka djarecka self-assigned this Dec 18, 2017
@djarecka
Copy link
Collaborator

@fliem - I understand. Thank you for your contribution!

@djarecka
Copy link
Collaborator

continuation in #2347

@djarecka djarecka closed this Dec 22, 2017
effigies added a commit that referenced this pull request Feb 23, 2018
antsRegistrationSyNQuick (continuation of #1392 and #2347)
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.

3 participants