Nipype/FSL task analysis - Trait error for template file (instance must be pathlike object...)

Hi everyone,

as a follow-up to fmriprep, I use a nipypeflow based on this one (https://github.com/poldracklab/ds003-post-fMRIPrep-analysis/) for my task analysis. The first level works fine, but for the group level analysis, a new template is downloaded via templateflow. When this template is used in the smoothest step, nipype can not find it:

traits.trait_errors.TraitError: The ‘mask_file’ trait of a SmoothEstimateInputSpec instance must be a pathlike object or string representing an existing file, but a value of ‘/home/bidsapp/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz’ <class ‘str’> was specified.

I can navigate to the file via bash but the path does not seem to work with python. I came across this problem multiple times and could only solve it by putting all necessary files and folders in child directories of the one housing the workflow script. I feel like I am missing something very obvious about how python and bash handle path strings…

Best,

André

Okay, bypassed it temporarily by putting my workflow file in basefolder of the docker container. Now I get the following error regarding mask and residual volumes:

File: /crash-20201103-142021-bidsapp-smoothness-f51a4bbc-6be9-422b-ac5e-f8c8de4e42a2.pklz
Node: wf_2nd_level.smoothness
Working directory: /input/work/wf_2nd_level/smoothness

Node inputs:

args =
dof = 3
environ = {‘FSLOUTPUTTYPE’: ‘NIFTI_GZ’}
mask_file = /home/bidsapp/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz
output_type = NIFTI_GZ
residual_fit_file = /input/work/wf_2nd_level/flameo_ols/stats/res4d.nii.gz
zstat_file =

Traceback:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/linear.py”, line 46, in run
node.run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 516, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 635, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 741, in _run_command
result = self._interface.run(cwd=outdir)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 419, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 814, in _run_interface
self.raise_exception(runtime)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/core.py”, line 745, in raise_exception
).format(**runtime.dictcopy())
RuntimeError: Command:
smoothest --dof=3 --mask=/home/bidsapp/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz --res=/input/work/wf_2nd_level/flameo_ols/stats/res4d.nii.gz
Standard output:

Standard error:
Mask and Data (residuals/zstat) volumes MUST be the same size!
Return code: 1

The template dimensions (via fslhd)
sizeof_hdr 348
data_type UINT8
dim0 3
dim1 97
dim2 115
dim3 97

The res4d file:
sizeof_hdr 348
data_type FLOAT32
dim0 4
dim1 65
dim2 77
dim3 61

Closing this cause the problem I posted this for was solved. Created a new topic for the second problem that I can’t find a way around for.