-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
traits.trait_errors.TraitError: Each element of the 'in_files' trait of a SmoothInputSpec instance must be a pathlike object or string representing an existing file, but a value of 'xxx’ <class 'str'> was specified. #3693
Comments
SmoothInputSpec and similar SPM functions only accept uncompressed nifti files. Uncompress the file and try again. It should work. nipype/nipype/interfaces/spm/preprocess.py Lines 482 to 491 in bc456dd
nipype/nipype/interfaces/spm/base.py Lines 612 to 613 in bc456dd
Maybe changing the value of allow_compressed to true could solve this problem. nipype/nipype/interfaces/spm/base.py Line 623 in bc456dd
|
Has SPM started accepting compressed files? If so, in what version? |
Not that I'm aware unfortunately. Related to issue #2420 |
It looks like we would need to do that in this class:
By overriding nipype/nipype/interfaces/base/traits_extension.py Lines 104 to 118 in bc456dd
to indicate acceptable extensions.
Automatically? I can't immediately think of a way. But there is nipype.algorithms.misc.Gunzip. |
I'm assuming that would not work well with other libraries that accept compressed nifti. |
Sorry, I don't understand that comment. |
Ah I'm sorry. Nipype incorporates a lot of libraries. Do they all use the File class to confirm filetype? If so, it would be hard to raise an error only for SPM. Or even add a restriction for .nii filetypes |
Got it. No, we should be able to do this without changing what succeeds or fails. What I'm proposing is just to improve the text emitted by the class File(BasePath):
...
@property
def info_text(self):
info_text = super().info_text
if self._exts:
if len(self._exts) == 1:
info_text += f" with extension {self._exts[0]}"
else:
info_text += f" with one of the extensions: {self.exts}"
return info_text |
Summary
When running a script using
smooth.inputs.in_files
, an error occurs indicating that thein_files
trait must be a pathlike object or a string representing an existing file, despite the file path being valid and existing.Actual behavior
The script fails with the following error traceback:
Expected behavior
The file path
'/Users/ab/Documents/Code/nipype_tutorial/tests/test.nii.gz'
should be accepted as a valid path, and thesmooth.inputs.in_files
trait should accept it without raising an error, as the file does exist. But using an absolute path results in the same outcome.How to replicate the behavior
run the following scripts:
Script/Workflow details
Platform details:
Execution environment
I use miniconda, the conda version is
conda 24.7.1
. Nipype was installed usingconda install --channel conda-forge nipype
.Python version
3.10.13
The text was updated successfully, but these errors were encountered: