Skip to content

Normalize12 does not accept an existing file as "apply_to_files" input #3030

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

Closed
fednem opened this issue Sep 16, 2019 · 10 comments
Closed

Normalize12 does not accept an existing file as "apply_to_files" input #3030

fednem opened this issue Sep 16, 2019 · 10 comments
Labels
Milestone

Comments

@fednem
Copy link

fednem commented Sep 16, 2019

Summary

When I try to provide the path towards the file to whom apply the deformation field it throws an error message

Actual behavior

When I provide the path towards the file to whom apply the deformation field as in

nrm = Normalize12()
nrm.inputs.apply_to_files = "/path/to/file.nii"

it throws the following error

TraitError: Each element of the 'apply_to_files' trait of a Normalize12InputSpec instance must be a pathlike object or string representing an existing file or a list of items which are a pathlike object or string representing an existing file, but a value of '/media/zipat/DATA/temp/AD_75_T1.nii' <class 'str'> was specified.

Expected behavior

The expected behavior would be to accept the input, especially since it takes as deformation_field a file in the same directory and I have double checked that the files I am providing exist.

Script/Workflow details

https://gist.github.com/fednem/e4725d8812af75a51d681214da3b401f

Platform details:

/home/zipat/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
{'commit_hash': '4b69cfcfa',
 'commit_source': 'installation',
 'networkx_version': '2.1',
 'nibabel_version': '2.4.0',
 'nipype_version': '1.2.2',
 'numpy_version': '1.14.3',
 'pkg_path': '/home/zipat/anaconda3/lib/python3.6/site-packages/nipype',
 'scipy_version': '1.1.0',
 'sys_executable': '/home/zipat/anaconda3/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) \n'
                '[GCC 7.2.0]',
 'traits_version': '5.1.2'}

@fednem
Copy link
Author

fednem commented Sep 16, 2019

After having restarted the python console and reinstalled nipype, it does accept the file as input, but it does not run, giving the following error

Traceback (most recent call last):

  File "<ipython-input-28-56bd4d3919aa>", line 10, in <module>
    nrm.run()

  File "/home/zipat/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 378, in run
    outputs = self.aggregate_outputs(runtime)

  File "/home/zipat/anaconda3/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 481, in aggregate_outputs
    raise FileNotFoundError(val, message=msg)

TypeError: __init__() got an unexpected keyword argument 'message'

Which seems to me to be a similar problem, since it is complaining about not finding a file that it is absolutely there.

@effigies effigies added the bug label Sep 16, 2019
@effigies effigies added this to the 1.2.3 milestone Sep 16, 2019
@effigies
Copy link
Member

For the FileNotFoundError, I've proposed a fix in #3035.

As to why the file isn't being found, what kind of environment are you running in? Is the process running on the same machine and with the same permissions as your user?

@effigies
Copy link
Member

@fednem Can you confirm whether this persists with the current master?

@fednem
Copy link
Author

fednem commented Sep 20, 2019 via email

@effigies
Copy link
Member

Great, thanks for the confirmation!

@axiezai
Copy link
Contributor

axiezai commented May 27, 2020

Hi, I'm running into the same problem:

traits.trait_errors.TraitError: Each element of the 'T1_files' trait of a ReconAllInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/dwi_preproc/derivatives/pipetography/_subject_id_01/apply_warp/mapflow/_apply_warp1/acpc_t1.nii.gz' <class 'str'> was specified.

I'm running nipype with it's fsl and freesurfer interfaces in singularity/docker image:

root@e1498729b2f7:/# nipypecli version
1.5.0-rc1

The crazy thing is, I built the workflow on my Mac, which does not spit out this error, but when I run this on a remote linux machine in the containers i build with the same version of nipype, I get this error. The file does exist. Any suggestions? Thank you in advance.

@fednem
Copy link
Author

fednem commented May 27, 2020 via email

@axiezai
Copy link
Contributor

axiezai commented May 28, 2020

That is indeed a good suggestion, I changed the previous step's output to be .nii instead of .nii.gz so recon-all get's a .nii for input, now the workflow is complaining that the input to the previous step is a str that points to a file that doesn't exist, but it does:

traits.trait_errors.TraitError: The 'in_file' trait of an ApplyWarpInputSpec instance must be a pathlike object or string representing an existing file, but a value of '/BIDS_output/sub-01/ses-002/anat/sub-01_ses-002_T1w.nii.gz' <class 'str'> was specified.

Just to be sure:

$ ls /BIDS_output/sub-01/ses-002/anat/
sub-01_ses-002_T1w.json  sub-01_ses-002_T1w.nii.gz

Additionally, another node in my workflow for mrtrix3's dwipreproc is also failing, i'm feeding in a .mif image as suggested by mrtrix, and getting the same error that the .mif cannot be found but it does exist.

@effigies
Copy link
Member

Can you open a new issue?

@axiezai
Copy link
Contributor

axiezai commented Jun 4, 2020

hi @effigies,

After reading through more issues and documentations, I was able to solve the issue by configuring my workflow with {'use_relative_paths':'True', 'hash_method': 'content'}.

SO I won't be opening a new issue. Thank you everyone for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants