-
Notifications
You must be signed in to change notification settings - Fork 61
Description
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:
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:
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()