The 'mean_img' trait of a MCFLIRTOutputSpec cannot be generated

Summary of what happened:

When I tried to run the preprocessing function on the fMRI images in BIDS format, it stuck at generating the mean image for MCFlirt.

Command used:

I followed an excellent Nipype tutorial by


Python: 3.10.9
All executions are on jupyter notebook

Relevant log outputs (up to 20 lines):

 	Traceback (most recent call last):
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/nipype/interfaces/base/", line 454, in aggregate_outputs
	    setattr(outputs, key, val)
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/nipype/interfaces/base/", line 330, in validate
 	    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/nipype/interfaces/base/", line 135, in validate
 	    self.error(objekt, name, str(value))
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/traits/", line 74, in error
 	    raise TraitError(
 	traits.trait_errors.TraitError: The 'mean_img' trait of a MCFLIRTOutputSpec instance must be a pathlike object or string representing an existing file, but a value of '/Users/mekolau/fmri/nipype/output/workingdir/preproc/_subject_id_01_task_name_task-p_run-01/mcflirt/sub-01_task-p_run-01_bold_roi_mcf_mean_reg.nii' <class 'str'> was specified.
 During handling of the above exception, another exception occurred:
 	Traceback (most recent call last):
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/nipype/interfaces/base/", line 401, in run 	    outputs = self.aggregate_outputs(runtime)
 	  File "/Users/mekolau/.local/lib/python3.10/site-packages/nipype/interfaces/base/", line 461, in aggregate_outputs
 	    raise FileNotFoundError(msg)
 	FileNotFoundError: No such file or directory '/Users/mekolau/fmri/nipype/output/workingdir/preproc/_subject_id_01_task_name_task-p_run-01/mcflirt/sub-01_task-p_run-01_bold_roi_mcf_mean_reg.nii' for output 'mean_img' of a MCFLIRT interface

I have tried different methods like
and it still didn’t help.

1 Like