TraitError for CoregisterInputSpec

Hi everyone,
I am running in a funny (let’s say funny) error when trying to specify the input to a nipype.interface.spm.preprocess.Coregister object. When I try to specify the source trait I got the following error

Each element of the 'source' trait of a CoregisterInputSpec instance must be a pathlike object or string     representing an existing file, but a value of '/path/to/my/file/img.nii.gz' <class 'str'> was specified.

Now, the point is that the file specified exists (as attested by a os.isfile returning True) and the path is provided as a string (as attested by type). Using the exact same string as input to a nilearn.image.load_img lead to the successful creation of a nibabel.nifti1.Nifti1Image. Note that to be on the safe side I have upgraded nipype to the last version available. For the sake of my life I cannot understand what is going wrong. Have you ever stumbled upon this ? Do you have any idea on how to make this go away ?


I think you might need to gunzip your source file before inputting to any SPM functions. You can add an extra node before the coregister node that will unzip nii.gz to nil image, if you know that your input files will be nii.gz format. Otherwise, depending on your previous nodes, you can also make the previous step to output unzipped nii image.

I hope that will solve your issue…!

Thanks. I feel just the dumbest right now. Of course SPM will not like gunzipped files. 9/10 the most obvious thing is the one you’ll not see. Thanks again to point this out !

Don’t feel bad…! I’m sure I’ve asked dumber questions :stuck_out_tongue: