How to run `niworkflows.interfaces.norm.SpatialNormalization` of sMRIPrep in local machine?

Hello NeuroStars Community,

I am trying to run niworkflows.interfaces.norm.SpatialNormalization in my local machine.

In fMRIPrep after Brain extraction and brain tissue segmentation, Spatial Normalization is performed. I was able to do Brain Extraction and Brain tissue Segmentation using ANT’s BrainExtraction module and FSL FAST module respectively in my local machine. Now I want to perform Spatial Normalization the way fMRIPrep is doing it. Based on the documentation all the structural preprocessing is being handled by init_anat_preproc_wf which is sMRIPrep pipeline. When I ran this niworkflows spatial normalization module it threw me this error. The outputs from BrainSegementation and BrainExtraction will be used as inputs for Spatial Normalization. It would be great learning experience for me is anyone can guide me thank you

---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
/tmp/ipykernel_159/2883818317.py in <module>
      1 registration = SpatialNormalization(float=True, flavor="precise", moving_mask = moving_mask, template=template, template_spec=template_spec, moving_image = moving_image)
----> 2 registration.run()

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/base/core.py in run(self, cwd, ignore_exception, **inputs)
    396             # Run interface
    397             runtime = self._pre_run_hook(runtime)
--> 398             runtime = self._run_interface(runtime)
    399             runtime = self._post_run_hook(runtime)
    400             # Collect outputs

~/anaconda3/lib/python3.9/site-packages/niworkflows/interfaces/norm.py in _run_interface(self, runtime)
    208             NIWORKFLOWS_LOG.info("Loading settings from file %s.", ants_settings)
    209             # Configure an ANTs run based on these settings.
--> 210             self.norm = Registration(from_file=ants_settings, **ants_args)
    211             self.norm.resource_monitor = False
    212             self.norm.terminal_output = self.terminal_output

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/ants/registration.py in __init__(self, **inputs)
   1013 
   1014     def __init__(self, **inputs):
-> 1015         super(Registration, self).__init__(**inputs)
   1016         self._elapsed_time = None
   1017         self._metric_value = None

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/ants/base.py in __init__(self, **inputs)
     75 
     76     def __init__(self, **inputs):
---> 77         super(ANTSCommand, self).__init__(**inputs)
     78         self.inputs.on_trait_change(self._num_threads_update, "num_threads")
     79 

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/base/core.py in __init__(self, command, terminal_output, write_cmdline, **inputs)
    628         self, command=None, terminal_output=None, write_cmdline=False, **inputs
    629     ):
--> 630         super(CommandLine, self).__init__(**inputs)
    631         self._environ = None
    632         # Set command. Input argument takes precedence

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/base/core.py in __init__(self, from_file, resource_monitor, ignore_exception, **inputs)
    208 
    209         if from_file is not None:
--> 210             self.load_inputs_from_json(from_file, overwrite=True)
    211 
    212             for name, value in list(inputs.items()):

~/anaconda3/lib/python3.9/site-packages/nipype/interfaces/base/core.py in load_inputs_from_json(self, json_file, overwrite)
    487         for key in new_inputs:
    488             if hasattr(self.inputs, key):
--> 489                 setattr(self.inputs, key, inputs_dict[key])
    490 
    491     def save_inputs_to_json(self, json_file):

~/anaconda3/lib/python3.9/site-packages/traits/trait_types.py in validate(self, object, name, value)
   2693                 return value
   2694 
-> 2695             return TraitListObject(self, object, name, value)
   2696 
   2697         self.error(object, name, value)

~/anaconda3/lib/python3.9/site-packages/traits/trait_list_object.py in __init__(self, trait, object, name, value)
    582         self._validate_length(len(value))
    583 
--> 584         super().__init__(
    585             value,
    586             item_validator=self._item_validator,

~/anaconda3/lib/python3.9/site-packages/traits/trait_list_object.py in __init__(self, iterable, item_validator, notifiers)
    211         if item_validator is not None:
    212             self.item_validator = item_validator
--> 213         super().__init__(self.item_validator(item) for item in iterable)
    214         if notifiers is not None:
    215             self.notifiers = list(notifiers)

~/anaconda3/lib/python3.9/site-packages/traits/trait_list_object.py in <genexpr>(.0)
    211         if item_validator is not None:
    212             self.item_validator = item_validator
--> 213         super().__init__(self.item_validator(item) for item in iterable)
    214         if notifiers is not None:
    215             self.notifiers = list(notifiers)

~/anaconda3/lib/python3.9/site-packages/traits/trait_list_object.py in _item_validator(self, value)
    865 
    866         try:
--> 867             return trait_validator(object, self.name, value)
    868         except TraitError as excp:
    869             excp.set_prefix("Each element of the")

~/anaconda3/lib/python3.9/site-packages/traits/base_trait_handler.py in error(self, object, name, value)
     72             The proposed new value for the attribute.
     73         """
---> 74         raise TraitError(
     75             object, name, self.full_info(object, name, value), value
     76         )

TraitError: Each element of the 'transform_parameters' trait of a _FixHeaderRegistrationInputSpec 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.05] <class 'list'> was specified.

Hi,

A few questions to see the best way to help:

  1. Would it be easier for you if you just ran sMRIPrep as a containered workflow instead of running these modules by themselves?
  2. What are the commands you ran that prompted this error?

Best,
Steven

Hello,
The only reason I am running the standalone modules from sMRIPrep is because I wanted to get the extra outputs generated from BrainExtraction module of ANTs. But I was able to run full sMRIPrep. So this is solved. Thanks