Fmriprep 20.1.1 does not run after BIDS validation - error on unhashable type 'dict'

Hi all,

I am trying to run fmriprep using singularity 3.4.2 and fmriprep version 20.1.1. I build fmriprep using the singularity 3.4.2 version via fmriprep’s docker hub container as shown here.

This is the fmriprep call I used:

fmriprep /mnt/data/All_subjects /mnt/data/All_subjects/derivatives participant --task-id confidence --verbose --fd-spike-threshold 0.5 --fs-no-reconall -w /mnt/work --n-cpus 16 --omp-nthreads 16 --fs-license-file $PWD/license.txt

I’m running into an error, however, for which I did not find a solution yet. This is the error I got, there are no log files / error files in the derivatives or work directories though:

Making sure the input data is BIDS compliant (warnings can be ignored in most cases).

bids-validator@1.4.0

*1: [WARN] The Authors field of dataset_description.json should contain an array of fields - with one author per field. This was triggered because there are no authors, which will make DOI registration from dataset metadata impossible. (code: 113 - NO_AUTHORS)

*Please visit https://neurostars.org/search?q=NO_AUTHORS for existing conversations about this issue.

*Summary: Available Tasks: Available Modalities:

1984 Files, 149.19GB confidence T1w

126 - Subjects bold

1 - Session events

*If you have any questions, please post on https://neurostars.org/tags/bids.

Traceback (most recent call last):
*File “/usr/local/miniconda/bin/fmriprep”, line 10, in
*sys.exit(main())
*File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py”, line 24, in main
*sentry_setup()
*File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/utils/sentry.py”, line 57, in sentry_setup
*for k, v in config.get(flat=True).items():
*File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/config.py”, line 570, in get
*‘execution’: execution.get(),
*File “/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/config.py”, line 202, in get
*v = str(v)
*File “/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py”, line 312, in repr
*self.session.query(Tag).filter_by(entity_name=‘session’)

TypeError: unhashable type: ‘dict’
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit


I tried deleting the –ncpus and –omp-nthreads options, and I tried pre-processing only a single subject, but I get the same error message. I also verified that the data are actually BIDS compliant with the validator. Moreover, I rearranged the order of the call (all the options first and input + output dir last), that did not work as well.

When I use an older version of singularity (2.5.2) and fmriprep (1.5.3) with the same call, it all works perfectly fine.

It would be great if someone can help me with this error. Thank you very much for your help! Greatly appreciate it!

Best,
Monja

At first glance, this looks like a problem when converting your BIDSLayout to a string. Could you rerun the command you used, but replace the --verbose flag with -vvv to increase verbosity?

Thank you for thinking along!
I reran the command with the -vvv flag. However, the error remains exactly the same, so that didn’t give me any additional information on the error, unfortunately.

Okay, let’s try to reproduce this minimally.

import sys
import os
import re
from bids import BIDSLayout, __version__

bids_dir = os.path.abspath(sys.argv[-1])

layout = BIDSLayout(
                bids_dir,
                validate=False,
                ignore=("code", "stimuli", "sourcedata", "models",
                        "derivatives", re.compile(r'^\.'))
)

print("Using pybids version: %s" % __version__)
print(str(layout))

If you save this to a file and call it via python <file.py> <path-to-bids-directory> we should expect to see the same error. This assumes you have the same version of pybids installed as inside the container.

Hi @monjahoven, could you either (or both):

Best,
Oscar

Hi all,

I acknowledge this topic is from over 2 years ago, but I have recently started encountering the problem presented by the original user. I have taken the steps outlined in this thread to try and fix my issue, but I have not had any luck thus far.

I have been using fmriprep to run analyses since December 2021 on an HPC linux server hosted by my university. I recently (about a month ago) started receiving the following error when trying to run my fmriprep script using fmriprep 21.0.0 and singularity 3.8 (this is what is produced when I use the -vvv flag in my script):

Traceback (most recent call last):
  File "/opt/conda/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/cli/run.py", line 45, in
 main
    sentry_setup()
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/utils/sentry.py", line 7
9, in sentry_setup
    for k, v in config.get(flat=True).items():
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/config.py", line 689, in
 get
    "execution": execution.get(),
  File "/opt/conda/lib/python3.8/site-packages/fmriprep/config.py", line 254, in
 get
    v = str(v)
  File "/opt/conda/lib/python3.8/site-packages/bids/layout/layout.py", line 191,
 in __repr__
    set(
TypeError: unhashable type: 'dict'
Sentry is attempting to send 1 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit
INFO:    Cleaning up image...

I also ran the minimal reproduction suggested by @mgxd in this thread and receive the following output:

[willibwe@l001 cogneuro]$ python file.py bids/
Traceback (most recent call last):
  File "file.py", line 4, in <module>
    from bids import BIDSLayout, __version__
ImportError: cannot import name 'BIDSLayout'

My BIDS dataset does have a sub-<id>_scans.tsv file, and when I remove said file I still receive the same error. There is no _scan.json file. It is not clear to me if the patch in the linked github issue is relevant since I am using a more recent version of fmriprep (from Dec 2021) and have not had any issues with it until now.

I did reach out to the people at my university that manage the HPC in case this was a problem with something on their end, and they suggested it was a problem on my end/locally (they suggested using a different python module or installing some package locally), but it doesn’t make sense to me that the container would break, but that could very well be an incorrect assumption on my part.

I did try re-installing the container, and running the script using other versions of fmriprep, and I end up receiving the same error. I have attached the script I am using that is producing this error.

If there’s any other information I can share to be helpful, please let me know and I’m happy to do so.

Thanks,
Sam Williams
sbatch_fmriprep.txt (1.7 KB)

Hi @willibwe,

Have you tried BIDS-validating your dataset outside of fMRIPrep?

On recent versions of PyBIDS, BIDSLayout is module under bids.layout, not just bids.

Can you try the most recent release (22.1.1 or 20.2.7 if using the LTS version)?

Looking at your script, --bind /mmfs1/data/kensinel/canlab/cogneuro/bids/derivatives/fmriprep:/out, you don’t need the lagging /fmriprep, since fmriprep will create an fmriprep folder in the output directory. I also see in your script that you --skip-bids-validation. A BIDS validation problem could be underlying all of this.

Best,
Steven