Nipype with optional connections?

Hi there,
I’ve a dataset with 30 subjects and want to run some nipype-workflows. My problem is that some of my subjects are missing masks. Is there a way to avoid running some nodes if their input is empty - e.G. some kind of if-node?

My first attempt was to use MapNode but this works only if I have at least one or more files. If my DataGrabber cannot provide any mask the whole Workflow interrupts.

Thanks for any suggestions.

There isn’t currently a way to encode this in the workflow, but if you can peek at your data and know which ones won’t have masks, you can put an if statement in the workflow construction function to avoid putting those nodes into the workflow. As an example, see https://github.com/nipreps/niworkflows/blob/6488ef7/niworkflows/anat/coregistration.py#L150-L156.