You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ants.ConvertScalarImageToRGB wraps the cmdline tool ConvertScalarImageToRGB, which takes mainly positional arguments. Some of the positional arguments are optional, such as the mask file, so to omit the mask_file, a string value of "none" must be formatted as the 3rd argument.
The inputspec is correct in setting mask_file as an optional argument with a default_value of "none":
However, if the optional mask_image is not specified, nipype will in some cases throw a traits.trait_errors.TraitError, since the file "none" does not exist. Interestingly, this error is only thrown in some cases such as when incoorporating and running the node in a multiprocess workflow (see provided snippet).
Actual behavior
Running the provided snippet:
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/nipype/pipeline/plugins/multiproc.py", line 148, in __init__
mp_context=mp_context,
TypeError: __init__() got an unexpected keyword argument 'initializer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.6/concurrent/futures/process.py", line 169, in _process_worker
call_item = call_queue.get(block=True)
File "/usr/lib/python3.6/multiprocessing/queues.py", line 113, in get
return _ForkingPickler.loads(res)
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/traits/has_traits.py", line 1341, in __setstate__
self.trait_set(trait_change_notify=trait_change_notify, **state)
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/traits/has_traits.py", line 1434, in trait_set
setattr(self, name, value)
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/traits/trait_types.py", line 1397, in validate
self.error(object, name, value)
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/traits/base_trait_handler.py", line 75, in error
object, name, self.full_info(object, name, value), value
traits.trait_errors.TraitError: The 'mask_image' trait of a ConvertScalarImageToRGBInputSpec instance must be a filename or object implementing the os.PathLike interface, but a value of 'none' <class 'str'> was specified.
exception calling callback for <Future at 0x7f589b682c88 state=finished raised BrokenProcessPool>
Traceback (most recent call last):
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 324, in _invoke_callbacks
callback(self)
File "/homes/hinge/venv/MRI-to-PET/lib/python3.6/site-packages/nipype/pipeline/plugins/multiproc.py", line 159, in _async_callback
result = args.result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
210806-19:25:59,298 nipype.workflow INFO:
[MultiProc] Running 1 tasks, and 0 jobs ready. Free memory (GB): 6.69/6.89, Free processors: 3/4.
Currently running:
* visualizations.test_node
Expected behavior
I expected this snippet to run without any errors
How to replicate the behavior
See below
Script/Workflow details
fromnipype.interfaces.utility.baseimportIdentityInterfacefromnipype.pipelineimportNode, Workflowfromnipype.interfacesimportantsinputnode=Node(IdentityInterface(fields=("test_file")),name="inputnode")
## Supply a nifti file as inputinputnode.inputs.test_file="/homes/hinge/MRI-to-PET/data/processed/TEST/NC0005_001/mr.nii.gz"_im_to_rgb=ants.ConvertScalarImageToRGB()
_im_to_rgb.inputs.dimension=3_im_to_rgb.inputs.colormap="jet"_im_to_rgb.inputs.minimum_input=0_im_to_rgb.inputs.maximum_input=1im_to_rgb=Node(_im_to_rgb, name="test_node")
workflow=Workflow("visualizations")
workflow.connect([
(inputnode,im_to_rgb,[("test_file","input_image")]),
])
## Calling workflow.inputs will yield a similar error#workflow.inputsworkflow.run(plugin='MultiProc')
## Workflow.run() works fine#workflow.run()
Summary
The
ants.ConvertScalarImageToRGB
wraps the cmdline toolConvertScalarImageToRGB
, which takes mainly positional arguments. Some of the positional arguments are optional, such as themask file,
so to omit themask_file
, a string value of"none"
must be formatted as the 3rd argument.The inputspec is correct in setting mask_file as an optional argument with a default_value of
"none"
:However, if the optional
mask_image
is not specified, nipype will in some cases throw atraits.trait_errors.TraitError
, since the file"none"
does not exist. Interestingly, this error is only thrown in some cases such as when incoorporating and running the node in a multiprocess workflow (see provided snippet).Actual behavior
Running the provided snippet:
Expected behavior
I expected this snippet to run without any errors
How to replicate the behavior
See below
Script/Workflow details
Platform details:
Execution environment
Choose one
The text was updated successfully, but these errors were encountered: