fMRIPrep error: "ValueError: dictionary update sequence element #0 has length 4; 2 is required"

Hi there, I am attempting to run fmriprep on singular subjects in my BIDS directory but am getting the following error.

Command used (and if a helper script was used, a link to the helper script or the command generated):

SUB=$2
echo $SUB
singularity run --cleanenv -B /projects/b1108:/projects/b1108 \
-B /projects/b1108/studies/RADAR/data/preprocessed/fmriprep:/out \
-B /projects/b1108/studies/RADAR/data/raw/neuroimaging/bids:/data \
-B /projects/b1108/studies/RADAR/data/preprocessed/fmriprep/work:/work \
/projects/b1108/software/singularity_images/fmriprep_23.1.4.sif \
/data /out participant --participant-label ${2} \
--fs-license-file /projects/b1108/software/freesurfer_license/license.txt \
--fs-subjects-dir /projects/b1108/studies/RADAR/data/preprocessed/fmriprep/freesurfer \
--output-spaces MNI152NLin6Asym MNI152NLin2009cAsym \
-w /work --skip_bids_validation --bids-filter-file /projects/b1108/studies/RADAR/scripts/2_quality_check/bids_filter.json

Relevant log outputs (up to 20 lines):

You are using fMRIPrep-23.1.4, and a newer version of fMRIPrep is available: 25.1.3.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 43, in main
    parse_args()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/parser.py", line 786, in parse_args
    config.from_dict({})
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/config.py", line 678, in from_dict
    execution.load(settings, init=initialize('execution'), ignore=ignore)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/config.py", line 232, in load
    cls.init()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/config.py", line 476, in init
    cls._layout = BIDSLayout(
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/bids/layout/layout.py", line 176, in __init__
    indexer(self)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/bids/layout/index.py", line 150, in __call__
    self._index_metadata()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/bids/layout/index.py", line 403, in _index_metadata
    file_md.update(pl())
ValueError: dictionary update sequence element #0 has length 4; 2 is required

I am not sure if this is a BIDS compliance issue or a code issue. I have experimented with my bids filter json file with little luck.

Thank you in advance!

Hi @akashkrathi, and welcome to neurostars!

Please try updating, return the BIDS validator output, and provide contents your BIDS filter file.

Best,
Steven

Hi Steven, thanks for the response!

Here is my BIDS filter file

{
    "t1w": {
        "datatype": "anat",
        "session": "1",
        "acquisition": null,
        "suffix": "T1w"
    },
    "bold": {
        "datatype": "func",
        "session": "1",
        "suffix": "bold"
    }
}

Unfortunately, I cannot get my BIDS validator output because the code breaks before validation.

Thanks!

Hi @akashkrathi,

You can run the bids validator separately from fmriprep. GitHub - bids-standard/bids-validator: Validator for the Brain Imaging Data Structure

A tree output from a subject raw data folder might also be helpful.

Best,
Steven

Here is the output from bids-validator. I downloaded a couple subjects and all non-subject folders locally and ran bids-validator.

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'unicode-name@1.0.4',
npm WARN EBADENGINE   required: { node: '>=18.20' },
npm WARN EBADENGINE   current: { node: 'v18.18.2', npm: '9.8.1' }
npm WARN EBADENGINE }
npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
bids-validator@1.15.0
(node:16897) Warning: Closing directory handle on garbage collection
(Use `node --trace-warnings ...` to show where the warning was created)
	1: [WARN] Task scans should have a corresponding events.tsv file. If this is a resting state scan you can ignore this warning or rename the task to include the word "rest". (code: 25 - EVENTS_TSV_MISSING)
		./sub-2200/ses-1/func/sub-2200_ses-1_task-mid_run-01_bold.nii.gz
		./sub-2200/ses-1/func/sub-2200_ses-1_task-mid_run-02_bold.nii.gz
		./sub-2235/ses-1/func/sub-2235_ses-1_task-mid_run-01_bold.nii.gz
		./sub-2235/ses-1/func/sub-2235_ses-1_task-mid_run-02_bold.nii.gz
		./sub-2295/ses-1/func/sub-2295_ses-1_task-mid_run-01_bold.nii.gz
		./sub-2295/ses-1/func/sub-2295_ses-1_task-mid_run-02_bold.nii.gz

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

	2: [WARN] The recommended file /README is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 101 - README_FILE_MISSING)

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

	3: [WARN] The Name field of dataset_description.json is present but empty of visible characters. (code: 115 - EMPTY_DATASET_NAME)

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

        Summary:                Available Tasks:        Available Modalities: 
        93 Files, 8.28GB        mid                     MRI                   
        3 - Subjects            rest                                          
        1 - Session                                                           


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

Here is the tree diagram:

.
├── code
│   └── Protocol_Translator.json
├── dataset_description.json
├── derivatives
├── participants.json
├── participants.tsv
├── sourcedata
│   └── 2374
│       └── 1
├── sub-2200
│   └── ses-1
│       ├── anat
│       ├── dwi
│       ├── fmap
│       └── func
├── sub-2235
│   └── ses-1
│       ├── anat
│       ├── dwi
│       ├── fmap
│       └── func
└── sub-2295
    └── ses-1
        ├── anat
        ├── dwi
        ├── fmap
        └── func

24 directories, 4 files 

Thanks!

Akash

Hi @akashkrathi,

Please make sure the file names are visible as well in the tree output.

Best,
Steven

Here is an updated version

./
├── code/
│   └── Protocol_Translator.json
├── dataset_description.json
├── derivatives/
├── participants.json
├── participants.tsv
├── sourcedata/
└── sub-2295/
    └── ses-1/
        ├── anat/
        │   ├── sub-2295_ses-1_run-1_T1w.json
        │   └── sub-2295_ses-1_run-1_T1w.nii.gz
        ├── dwi/
        │   ├── sub-2295_ses-1_run-1_dwi.bval
        │   ├── sub-2295_ses-1_run-1_dwi.bvec
        │   ├── sub-2295_ses-1_run-1_dwi.json
        │   └── sub-2295_ses-1_run-1_dwi.nii.gz
        ├── fmap/
        │   ├── sub-2295_ses-1_dir-ap_run-1_epi.json
        │   ├── sub-2295_ses-1_dir-ap_run-1_epi.nii.gz
        │   ├── sub-2295_ses-1_dir-ap_run-2_epi.json
        │   ├── sub-2295_ses-1_dir-ap_run-2_epi.nii.gz
        │   ├── sub-2295_ses-1_dir-ap_run-3_epi.json
        │   ├── sub-2295_ses-1_dir-ap_run-3_epi.nii.gz
        │   ├── sub-2295_ses-1_dir-pa_run-1_epi.json
        │   ├── sub-2295_ses-1_dir-pa_run-1_epi.nii.gz
        │   ├── sub-2295_ses-1_dir-pa_run-2_epi.json
        │   ├── sub-2295_ses-1_dir-pa_run-2_epi.nii.gz
        │   ├── sub-2295_ses-1_dir-pa_run-3_epi.json
        │   └── sub-2295_ses-1_dir-pa_run-3_epi.nii.gz
        └── func/
            ├── sub-2295_ses-1_task-mid_run-01_bold.json
            ├── sub-2295_ses-1_task-mid_run-01_bold.nii.gz
            ├── sub-2295_ses-1_task-mid_run-02_bold.json
            ├── sub-2295_ses-1_task-mid_run-02_bold.nii.gz
            ├── sub-2295_ses-1_task-rest_run-01_bold.json
            ├── sub-2295_ses-1_task-rest_run-01_bold.nii.gz
            ├── sub-2295_ses-1_task-rest_run-02_bold.json
            ├── sub-2295_ses-1_task-rest_run-02_bold.nii.gz
            ├── sub-2295_ses-1_task-rest_run-03_bold.json
            ├── sub-2295_ses-1_task-rest_run-03_bold.nii.gz
            ├── sub-2295_ses-1_task-rest_run-04_bold.json
            └── sub-2295_ses-1_task-rest_run-04_bold.nii.gz

10 directories, 34 files

Hi @akashkrathi,

Does fmriprep work locally on this smaller dataset? Did you try updating fmriprep? Can you try the validator on your full dataset?

Best,
Steven

Hi Steven,

Fmriprep does not work on the smaller dataset likely because i used docker to run it locally. The larger dataset is on a computing cluster and on which I am unable to install bids-validator. Fmriprep did not work on the local dataset likely because I used docker to run it.

It seems as though someone else on Neurostars experienced the same issue. Was there ever a resolution to this post?

Thanks!

Hi @akashkrathi,

What do you mean by this?

Best,
Steven

Hi Steven,

I was able to figure out. My work folder had output from a separate process.

Thanks!