MRIQC fails with TraitError

Hi Oscar,

Thanks again for updating. With v0.15.0 it is giving this other error…

Process Process-2:
Traceback (most recent call last):
  File "/usr/local/Anaconda/envs/py3.6/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/local/Anaconda/envs/py3.6/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/gpfs/gsfs10/users/winkleram/ENIGMA/code/env/lib/python3.6/site-packages/mriqc/bin/mriqc_run.py", line 418, in init_mriqc
    wf_list.append(build_workflow(dataset[mod], mod, settings=settings))
  File "/gpfs/gsfs10/users/winkleram/ENIGMA/code/env/lib/python3.6/site-packages/mriqc/workflows/core.py", line 27, in build_workflow
    workflow = anat_qc_workflow(dataset, mod=mod, settings=settings)
  File "/gpfs/gsfs10/users/winkleram/ENIGMA/code/env/lib/python3.6/site-packages/mriqc/workflows/anatomical.py", line 87, in anat_qc_workflow
    norm = spatial_normalization(settings)
  File "/gpfs/gsfs10/users/winkleram/ENIGMA/code/env/lib/python3.6/site-packages/mriqc/workflows/anatomical.py", line 191, in spatial_normalization
    get_template(tpl_id, resolution=resolution, desc='brain', suffix='mask'))
  File "/gpfs/gsfs10/users/winkleram/ENIGMA/code/env/lib/python3.6/site-packages/nipype/interfaces/base/traits_extension.py", line 112, in validate
    self.info_text, value))
traits.trait_errors.TraitError: The trait 'reference_mask' of a RobustMNINormalizationInputSpecRPT instance is an existing file name, but the path  '[]' does not exist.

Let me provide some extra piece of info: we don’t have .json sidercar files for this dataset, and this is only structural T1w.
At the top of the BIDS directory, in the same level as the dataset_description.json, we added a file named T1w.json that contains nothing but just an empty pair of curly braces, that is:

{ }

What is the version of TemplateFlow?:

python -c 'import templateflow; print(templateflow.__version__)'

Next question is the output of:

python -c "from templateflow import api; print([str(f) for f in api.get('MNI152NLin2009c', resolution=2)])"

It is very likely that pip install -U templateflow would fix this issue, but those two commands will help to be sure.

Templateflow is 0.1.7.

The 2nd output is an empty list:

$ python -c "from templateflow import api; print([str(f) for f in api.get('MNI152NLin2009c', resolution=2)])"
[]

Okay, I think I can guess what is happening. Your TemplateFlow 0.1.7 was not installed fresh, and that is confusing the machinery to work around git-annex. I’ve opened an issue in our repo. Thanks for reporting!

Let’s see if the following steps get you on your way while we find a better solution:

python -c "from templateflow import api; print(api.get('MNI152NLin2009cAsym', resolution=2, desc='brain', suffix='mask'))"

This should return [].

Then let’s try to fix the problem.

touch ${TEMPLATEFLOW_HOME:-$HOME/.cache/templateflow}/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz

Then, we re-run the first command again:

python -c "from templateflow import api; print(api.get('MNI152NLin2009cAsym', resolution=2, desc='brain', suffix='mask'))"

And now, after some download indicator, you should see that the output is '/some/path/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz'.

After these three steps, please post the output of the following command (I made a mistake in the original post), so that I can check whether you need to manually initiate more files for MRIQC to work:

python -c "from templateflow import api; print('\n'.join([str(f) for f in api.get('MNI152NLin2009cAsym', resolution=2)]))"

Thanks Oscar!

The first returned [] indeed. Did then the touch and in the 3rd command it downloaded from amazonaws. The NIFTI file came, and it’s stored in ~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz as I believe it’s expected. The file has 29576 bytes.

But then the last command did not run successfully:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: 'PosixPath' object is not iterable

I made it iterable then transforming it to a list, hope this is fine:

python -c "from templateflow import api; print('\n'.join([str(f) for f in [api.get('MNI152NLin2009cAsym', resolution=2)]]))"

It gave then this output (except that instead of “~” it shows the full path):

~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz

Would it be ok if we tried to run MRIQC at this point? Thanks!

The fact that you only got one file from the (fixed) last command makes me worry.

Let’s start fresh to make sure MRIQC will work out.

rm -r ${TEMPLATEFLOW_HOME:-$HOME/.cache/templateflow}
python -c "from templateflow import api; print('\n'.join([str(f) for f in api.get('MNI152NLin2009cAsym')]))"

That should first clean up the template flow cache (beware of the rm command in the beginning, please proceed with caution -maybe checking with ls what is to be deleted-).

The second line should download the full MNI152NLin2009cAsym template and all related files and resolutions.

If the second command is successful and you get the following:

~/.cache/templateflow/tpl-MNI152NLin2009cAsym/CHANGES
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/LICENSE
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/template_description.json
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_from-OASISTRT20_mode-image_xfm.mat
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-brain_T1w.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-BrainCerebellumExtraction_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-BrainCerebellumRegistration_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-carpet_dseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-eye_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-face_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-head_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_label-CSF_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_label-GM_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_label-WM_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_PD.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_T2w.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_T1w.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-carpet_dseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-DKT31_dseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-eye_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-face_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-fMRIPrep_boldref.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-head_mask.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_label-CSF_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_label-GM_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_label-WM_probseg.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_PD.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz
~/.cache/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T2w.nii.gz

MRIQC should be good to go.

Great, got the same output, and have just submitted to run. Fingers crossed…!
Thanks!

1 Like