Okay, the only workaround so far that I’ve found is to raise an Error inside the file_getter node like this:
# define a node that gets data
def get_files(data_df,subject,task,session):
from nipype.interfaces.base.support import NipypeInterfaceError
# query dataframe for a specific subject, specific task and specific session
subject_df = data_df.query("subject==@subject & task==@task & session==@session")
subject_df = subject_df.set_index('suffix')
if not subject_df.empty:
func = subject_df.at['bold','path']
return func
else:
raise NipypeInterfaceError('No files found for this subject')
return
file_getter = Node(Function(input_names=['data_df','subject','task','session'],
output_names='func',
function=get_files),
name='file_getter')
Only then, then workflow doesn’t get stuck at the gunzipper node. This will produce this output after the workflow has run:
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ~/.conda/envs/csp_wiesner_johannes_new/lib/python3.8/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)
File ~/work/projects/project_indicate/code/debug_gunzip.py:79
wf_results = wf.run('MultiProc',plugin_args={'n_procs':6})
File ~/.conda/envs/csp_wiesner_johannes_new/lib/python3.8/site-packages/nipype/pipeline/engine/workflows.py:638 in run
runner.run(execgraph, updatehash=updatehash, config=self.config)
File ~/.conda/envs/csp_wiesner_johannes_new/lib/python3.8/site-packages/nipype/pipeline/plugins/base.py:224 in run
raise error from cause
RuntimeError: 3 raised. Re-raising first.
Which is a little bit misleading, because it was to be expected that the workflow coulnd’t run for all second sessions (they simply don’t exist). Would be nice if nipype had a feature to properly catch these exceptions without having to raise Errrors. But I think there will be such a feature, as @satra already mentioned in this comment? However, I still don’t really get why the gunzip nodes get stuck. Shouldn’t they check the input (aka. output from file_getter) and then fail because the input is None?