Skip to content

ANTS Registration interface crashes when wrapped in a Nipype1Task #596

@NicolasGensollen

Description

@NicolasGensollen

What version of Pydra are you using?

0.20

What were you trying to do?

I'm trying to use the Nipype ANTS Registration interface by wrapping it into a Nipype1Task.

The problem comes when settings the input parameters of this task, more precisely transform_parameters.

This parameter should be a list of tuples when using SyN as defined here:

https://github.com/nipy/nipype/blob/5d436ba45ad9a567c9aa3c94f54f970f7b681da3/nipype/interfaces/ants/registration.py#L492-L501

So, I am creating this interface in the following way:

ants_registration_t1w_to_mni = Nipype1Task(
         name="ants_registration_t1w_to_mni",
         interface=Registration(),
)
ants_registration_t1w_to_mni.inputs.transform_parameters = [(0.1, 3, 0)]
# ... other configuration

When running the pipeline, I get the following error:

traits.trait_errors.TraitError: Each element of the 'transform_parameters' trait of a RegistrationInputSpec
instance must be a tuple of the form: (a float) or a tuple of the form: (a float, a float, a float) or a tuple of the form:
(a float, an integer, an integer, an integer) or a tuple of the form: (a float, an integer, a float, a float, a float, a float)
or a tuple of the form: (a float, a float, a float, an integer) or a tuple of the form: (a float, an integer, an integer,
an integer, an integer), but a value of [0.1, 3, 0] <class 'list'> was specified.

What did you expect will happen?

I expected the pipeline to run without error.

When using this interface, configured in the exact same way, through Nipype, it works fine. This is implemented for example in Clinica here:

https://github.com/aramis-lab/clinica/blob/d098dd64f3ded1729b8bd7816fb316733bebc768/clinica/pipelines/pet_linear/pet_linear_pipeline.py#L311

What actually happened?

The error makes me think that the tuples inside the list get casted to lists silently somewhere inside the Nipype1Task code.

Can you replicate the behavior?

Yes, here is a dummy MWE:

from pydra.tasks.nipype1.utils import Nipype1Task
from nipype.interfaces.ants import Registration
from pathlib import Path

task = Nipype1Task(name="antsRegistration_Pydra", interface=Registration())

def configure_task(task):
    """Configure Registration task."""
    task.inputs.transform_parameters = [(0.1, 3, 0)]  # This will raise an error
    task.inputs.metric = ["MI"]
    task.inputs.metric_weight = [1.0]
    task.inputs.transforms = ["SyN"]
    task.inputs.dimension = 3
    task.inputs.shrink_factors = [[8, 4, 2]]
    task.inputs.smoothing_sigmas = [[3, 2, 1]]
    task.inputs.sigma_units = ["vox"]
    task.inputs.number_of_iterations = [[200, 50, 10]]
    task.inputs.convergence_threshold = [1e-05]
    task.inputs.convergence_window_size = [10]
    task.inputs.radius_or_number_of_bins = [32]
    task.inputs.winsorize_lower_quantile = 0.005
    task.inputs.winsorize_upper_quantile = 0.995
    task.inputs.collapse_output_transforms = True
    task.inputs.use_histogram_matching = False
    task.inputs.verbose = True
    # Dummy inputs here
    task.inputs.fixed_image = Path(__file__)
    task.inputs.moving_image = Path(__file__)

configure_task(task)
task._run_task()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions