Spm_mat_file in spm Level1Design

I run a variation of this script on my own data set:

When running the spm Level1Design I receive this error:

Traceback (most recent call last):

File “”, line 1, in

File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py”, line 524, in run
outputs = self.aggregate_outputs(runtime)

File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py”, line 625, in aggregate_outputs
raise error

File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py”, line 618, in aggregate_outputs
setattr(outputs, key, val)

File “/home/or/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/traits_extension.py”, line 112, in validate
self.info_text, value))

TraitError: The trait ‘spm_mat_file’ of a Level1DesignOutputSpec instance is an existing file name, but the path ‘/home/or/SPM.mat’ does not exist.

The path is correct of course but there is no SPM.mat file there.
What am I missing?

Does anyone else received such an error message before?
Any help will be appreciated.


I have the exact same error and have posted an issue on github: https://github.com/nipy/nipype/issues/2880

My guess is: as inputs to you level1design you have a mask_image and also a custom spm_mat_dir? If so, a temporary SPM.mat file is created in the initial working folder of MATLAB. If you change the spm_mat_dir input, it will not find this SPM.mat file anymore.

I created a workaround (in the thread at github) for the time being.

1 Like

Thank you.
I’m not sure if we have the same issue or not.
I’m able to run if smoothly and only encounter problems when I try to add regressors to the info file (using Bunch). I take the regressors from fmriprep pipeline and I think there might be some issues around that.

@satra I don’t feel qualified to give advice on SPM interfaces, if you can give us a hint I can take it from there tomorrow.

I have solved the issue. And I think the error message is misleading.
The issue was associated with the fact the the Bunch object was array and not an array of lists (when I added the confounds).
After changing that it ran without a problem.
I think it might be a good idea to change the error message (something like - ‘unfit data’ or else).

Can you file a new issue on nipype’s repository (https://github.com/nipy/nipype/issues/new) requesting such change?