nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
741 stars 523 forks source link

BET interface produces wrong and in_file and command which fails silently without an error #3355

Open ChristianHinge opened 2 years ago

ChristianHinge commented 2 years ago

I have implemented a BET node in my workflow as I wish to use the binary brain mask for intensity normalization.

_bet = fsl.BET()
_bet.inputs.mask = True
_bet.inputs.out_file = "test.nii.gz"
_bet.inputs.frac=0.5
bet = Node(_bet, name="bet1")

wf.connect([
   ...
    (reg_mr_atlas,bet, [('warped_image','in_file')]),
     (bet,normalization_pet, [("inskull_mask_file","inputnode.mask")]),
   ...
])
...

The warped_image from reg_mr_atlas is listed as follows in the report.rst for reg_mr_atlas:

Execution Outputs
-----------------

* composite_transform : <undefined>
* elapsed_time : <undefined>
* forward_invert_flags : <undefined>
* forward_transforms : ['/home/hinge/MRI-to-PET/data/interim/HUK/pipeline_5/_session_2_subject_NC0020/reg_mr_atlas/transform0GenericAffine.mat']
* inverse_composite_transform : <undefined>
* inverse_warped_image : <undefined>
* metric_value : <undefined>
* reverse_forward_invert_flags : <undefined>
* reverse_forward_transforms : <undefined>
* reverse_invert_flags : <undefined>
* reverse_transforms : <undefined>
* save_state : <undefined>
* warped_image : /home/hinge/MRI-to-PET/data/interim/HUK/pipeline_5/_session_2_subject_NC0020/reg_mr_atlas/transform_Warped.nii.gz

However, when looking at the in_file in the report.rst for bet1, it is different:

Original Inputs
---------------

* args : <undefined>
* center : <undefined>
* environ : {'FSLOUTPUTTYPE': 'NIFTI'}
* frac : 0.5
* functional : <undefined>
* in_file : /home/hinge/MRI-to-PET/data/interim/HUK/pipeline_5/_session_2_subject_NC0020/bet1/transform_Warped.nii.gz
* mask : True
* mesh : <undefined>
* no_output : <undefined>
* out_file : test.nii.gz
* outline : <undefined>
* output_type : NIFTI
* padding : <undefined>
* radius : <undefined>
* reduce_bias : <undefined>
* remove_eyes : <undefined>
* robust : <undefined>
* skull : <undefined>
* surfaces : <undefined>
* t2_guided : <undefined>
* threshold : <undefined>
* vertical_gradient : <undefined>

Execution Inputs
----------------

* args : <undefined>
* center : <undefined>
* environ : {'FSLOUTPUTTYPE': 'NIFTI'}
* frac : 0.5
* functional : <undefined>
* in_file : /home/hinge/MRI-to-PET/data/interim/HUK/pipeline_5/_session_2_subject_NC0020/bet1/transform_Warped.nii.gz
* mask : True
* mesh : <undefined>
* no_output : <undefined>
* out_file : test.nii.gz
* outline : <undefined>
* output_type : NIFTI
* padding : <undefined>
* radius : <undefined>
* reduce_bias : <undefined>
* remove_eyes : <undefined>
* robust : <undefined>
* skull : <undefined>
* surfaces : <undefined>
* t2_guided : <undefined>
* threshold : <undefined>
* vertical_gradient : <undefined>

Execution Outputs
-----------------

* inskull_mask_file : <undefined>
* inskull_mesh_file : <undefined>
* mask_file : <undefined>
* meshfile : <undefined>
* out_file : <undefined>
* outline_file : <undefined>
* outskin_mask_file : <undefined>
* outskin_mesh_file : <undefined>
* outskull_mask_file : <undefined>
* outskull_mesh_file : <undefined>
* skull_file : <undefined>
* skull_mask_file : <undefined>

Runtime info
------------

* cmdline : bet transform_Warped.nii.gz test.nii.gz -f 0.50 -m
* duration : 8.357276
* hostname : LAPTOP-BBTJV5NL
* prev_wd : /home/hinge/MRI-to-PET
* working_dir : /home/hinge/MRI-to-PET/data/interim/HUK/pipeline_5/_session_2_subject_NC0020/bet1

This filepath for in_file is different from the one provided by reg_mr_atlas. Furthermore, the generated command strips of the most of the already incorrect in_file filepath, (making it even more incorrect). When running the command as is in a sepperate terminal using the specified working directory, I get an error since the file obviously does not exist. However, when run in the workflow, no error is thrown and no mask file is generated. Have I missed something very obvious?

ChristianHinge commented 2 years ago

Since submitting this issue, I have learned a few things. For anyone else having similar trouble: several FSL commands automatically copy some of the input files (e.g. in_file) to the working directory of the current node (the node belonging to the fsl command). While doing this, nipype automatically changes the in_file parameter from the file you specified, to the copied version of said file. Upon completing the node (either fail or success), the copied file is deleted from the fsl Node directory. This is why I thought it failed "silently". While the node was running, the cmdline did in fact NOT fail as the transform_Warped.nii.gz file existed.

I am still trying to figure out why the mask_file of the execution outputs remains undefined