nipype
nipype copied to clipboard
Nipype does not set all inputs of a Function Node if this node was used previously
Summary
Nipype does not set all inputs of a Function Node if this node was used previously
Actual behavior
The function Node has two inputs (Graph correctly shows the two inputs). However, in execution, only 1 input is set in the std log. This is only true when the same function is used previously (different node with different name; but the same function to execute). The function uses the previously set input for the absent input and continues.
Graph for the node with two inputs properly identified.
STD log for the Node (One with the issue):
231213-18:34:28,582 nipype.workflow INFO:
[Node] Setting-up "main_wf.mk_wf.pet_refval_refmask" in "/gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet_refval_refmask".
231213-18:34:28,582 nipype.workflow DEBUG:
[Node] Setting 1 connected inputs of node "pet_refval_refmask" from 1 previous nodes.
231213-18:34:28,582 nipype.utils DEBUG:
Loading pkl: /gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet_t12template/result_pet_t12template.pklz
231213-18:34:28,583 nipype.workflow DEBUG:
Resolving paths in outputs loaded from results file.
231213-18:34:28,583 nipype.workflow DEBUG:
output: output_image
231213-18:34:28,583 nipype.workflow DEBUG:
[Node] pet_refval_refmask - setting input input_file = /gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet_t12template/transform_Warped_trans.nii.gz
Previous Node (same function, but different node). As expected; both mask_file and input_file are correctly set.
[Node] Setting-up "main_wf.mk_wf.pet_refval_refmask_t1Native" in "/gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet_refval_refmask_t1Native".
231213-18:34:27,887 nipype.workflow DEBUG:
[Node] Setting 2 connected inputs of node "pet_refval_refmask_t1Native" from 2 previous nodes.
231213-18:34:27,888 nipype.utils DEBUG:
Loading pkl: /gcp_shared_work/E035_PET_PiB/temporary/main_wf/t1_wf/ref_res2native/result_ref_res2native.pklz
231213-18:34:27,888 nipype.workflow DEBUG:
Resolving paths in outputs loaded from results file.
231213-18:34:27,888 nipype.workflow DEBUG:
output: output_image
231213-18:34:27,888 nipype.workflow DEBUG:
[Node] pet_refval_refmask_t1Native - setting input mask_file = /gcp_shared_work/E035_PET_PiB/temporary/main_wf/t1_wf/ref_res2native/cent_voi_WhlCbl_1mm_res_trans.nii
231213-18:34:27,888 nipype.utils DEBUG:
Loading pkl: /gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet2t1_wf/pet2t1_reg/result_pet2t1_reg.pklz
231213-18:34:27,888 nipype.workflow DEBUG:
Resolving paths in outputs loaded from results file.
231213-18:34:27,888 nipype.workflow DEBUG:
output: warped_image
231213-18:34:27,889 nipype.workflow DEBUG:
[Node] pet_refval_refmask_t1Native - setting input input_file = /gcp_shared_work/E035_PET_PiB/temporary/main_wf/mk_wf/pet2t1_wf/pet2t1_reg/transform_Warped.nii.gz
The report.rst file for the failing node (pet_refval_refmask) however shows the mask_file value that was passed for the node that was run previously (pet_refval_refmask_t1Native).
Expected behavior
The inputs need to be properly set.
Resolution: Deepcopy the Function Interface before creating the Node solves this issue.
func_interface = copy.deepcopy(image_stats)
node = Node(func_interface, name=name)
I don't know if the other devs have encountered this issue. Any explanations?
Generally interfaces are not reusable. Glad you solved your problem.