Fmriprep - IndexError: list index out of range

Summary of what happened:

Hello! I am getting a error for resting state run.

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

python -m fmriprep_docker "/Users/Carlos Leandro/Desktop/dados/bids" "/Users/Carlos Leandro/dados/derivatives" participant --participant-label 01 --skip-bids-validation --md-only-boilerplate --fs-license-file "/Users/Carlos Leandro/Desktop/sourcedata/license.txt" --fs-no-reconall --output-spaces MNI152NLin2009cAsym:res-2 --stop-on-first-crash -w "/Users/Carlos Leandro/Desktop/dados/workdir" --mem-mb 6000

Version:

22.1.1

Environment (Docker, Singularity, custom installation):

Docker

Data formatted according to a validatable standard? Please provide the output of the validator:

Attention: I converted my data from Nifiti to Dicom, but it was validated by Bidscoin.

Relevant log outputs (up to 20 lines):

Error:

Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/workflow.py", line 115, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 91, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 413, in init_single_subject_wf
    func_preproc_wf = init_func_preproc_wf(bold_file, has_fieldmap=has_fieldmap)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/bold/base.py", line 204, in init_func_preproc_wf
    nvols = nb.load(bold_file[0] if isinstance(bold_file, (list, tuple)) else bold_file).shape[3]
IndexError: tuple index out of range
fMRIPrep: Please report errors to https://github.com/nipreps/fmriprep/issues

Screenshots / relevant information:

Any suggestion?
Thank you so much!

Best Regards
Carlos Leandro

Hi @CarlosLeandro09 and welcome to Neurostars!

I have relabeled your post as Software Support and added the appropriate template.

  1. Can you run BIDS validator on your data?

  2. Also, I do not suggest putting --fs-no-reconall in your command.

  3. --mem-mb 6000 is not a lot of memory, so keep an eye on that when you run.

Best,
Steven

Hi @Steven! Thank you!

  1. Yes, I did the validation with BIDS editor 3.7.4.

imagem_2023-02-03_141456775

  1. Thank you!
  2. I needed to modify it to run on my computer.

The error still remains.

C:\Users\Carlos Leandro\Desktop\dados>python -m fmriprep_docker "/Users/Carlos Leandro/Desktop/dados/bids" "/Users/Carlos Leandro/dados/derivatives" participant --participant-label 01 --skip-bids-validation --md-only-boilerplate --fs-license-file "/Users/Carlos Leandro/Desktop/sourcedata/license.txt" --output-spaces MNI152NLin2009cAsym:res-2 --stop-on-first-crash -w "/Users/Carlos Leandro/Desktop/dados/workdir" --mem-mb 6000
Warning: <8GB of RAM is available within your Docker environment.
Some parts of fMRIPrep may fail to complete.
Continue anyway? [y/N]y
RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=20.10.17 -it -v C:\Users\Carlos Leandro\Desktop\sourcedata\license.txt:/opt/freesurfer/license.txt:ro -v C:\Users\Carlos Leandro\Desktop\dados\bids:/data:ro -v C:\Users\Carlos Leandro\dados\derivatives:/out -v C:\Users\Carlos Leandro\Desktop\dados\workdir:/scratch nipreps/fmriprep:22.1.1 /data /out participant --participant-label 01 --skip-bids-validation --md-only-boilerplate --stop-on-first-crash --mem-mb 6000 -w /scratch --output-spaces MNI152NLin2009cAsym:res-2
--topup-max-vols input is no longer used and the flag will be removed in a future release.
230203-17:16:47,802 nipype.workflow IMPORTANT:
         Running fMRIPrep version 22.1.1

         License NOTICE ##################################################
         fMRIPrep 22.1.1
         Copyright 2022 The NiPreps Developers.

         This product includes software developed by
         the NiPreps Community (https://nipreps.org/).

         Portions of this software were developed at the Department of
         Psychology at Stanford University, Stanford, CA, US.

         This software redistributes the versioneer Python package, which is
         Public domain source code.

         This software is also distributed as a Docker container image.
         The bootstraping file for the image ("Dockerfile") is licensed
         under the MIT License.

         This software may be distributed through an add-on package called
         "Docker Wrapper" that is under the BSD 3-clause License.
         #################################################################
230203-17:16:47,858 nipype.workflow IMPORTANT:
         Building fMRIPrep's workflow:
           * BIDS dataset path: /data.
           * Participant list: ['01'].
           * Run identifier: ***********
           * Output spaces: MNI152NLin2009cAsym:res-2.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /out/sourcedata/freesurfer.
Process Process-2:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/workflow.py", line 115, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 91, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 413, in init_single_subject_wf
    func_preproc_wf = init_func_preproc_wf(bold_file, has_fieldmap=has_fieldmap)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/bold/base.py", line 204, in init_func_preproc_wf
    nvols = nb.load(bold_file[0] if isinstance(bold_file, (list, tuple)) else bold_file).shape[3]
IndexError: tuple index out of range
fMRIPrep: Please report errors to https://github.com/nipreps/fmriprep/issues

Best,
Carlos

Can you provide the output of tree run on one of your subject’s input data?

Sorry, I didn’t understand. Did you mean it?

Hi,

I was referring to the tree command in your terminal. I would need to see inside the anat and func folders.

What happens when you don’t skip bids validation in fMRIPrep?

Best,
Steven

Hi, @Steven!

  • My tree

C:.
├───bids
│ │ .bidsignore
│ │ dataset_description.json
│ │ participants.json
│ │ participants.tsv
│ │ README
│ │
│ ├───code
│ │ └───bidscoin
│ │ bidscoiner.errors
│ │ bidscoiner.log
│ │ bidseditor.errors
│ │ bidseditor.log
│ │ bidsmap.yaml
│ │ bidsmapper.errors
│ │ bidsmapper.log
│ │
│ └───sub-01
│ │ sub-01_scans.tsv
│ │
│ ├───anat
│ │ sub-01_acq-AXFSPGR3D_rec-3DORIGINALPRIMARYOTHER_run-1_T1w.json
│ │ sub-01_acq-AXFSPGR3D_rec-3DORIGINALPRIMARYOTHER_run-1_T1w.nii.gz
│ │
│ └───func
│ sub-01_task-fMRITESTE6_run-1_echo-1_bold.json
│ sub-01_task-fMRITESTE6_run-1_echo-1_bold.nii.gz

├───derivatives
│ └───logs
├───participant
│ └───logs
└───workdir
├───20230203-111406_be5fef69-1411-4058-b60c-b6efef40fd95
│ │ config.toml
│ │
│ └───bids_db
│ layout_index.sqlite

├───20230203-111742_58e12e27-a2c6-49e5-9191-f9e6070f5a6d
│ │ config.toml
│ │
│ └───bids_db
│ layout_index.sqlite

├───20230203-111920_81efddf6-5e76-4811-b379-588865400d5d
│ │ config.toml
│ │
│ └───bids_db
│ layout_index.sqlite

├───20230203-171627_d80fceff-1d07-4785-b041-72f065d4c785
│ │ config.toml
│ │
│ └───bids_db
│ layout_index.sqlite

└───20230203-185525_3f2d6eb1-957b-4d50-b626-07d0fcd7879f
└───bids_db
layout_index.sqlite

  • When I don’t skip it happens:
C:\Users\Carlos Leandro\Desktop\dados>python -m fmriprep_docker "/Users/Carlos Leandro/Desktop/dados/bids" "/Users/Carlos Leandro/dados/derivatives" participant --participant-label 01 --md-only-boilerplate --fs-license-file "/Users/Carlos Leandro/Desktop/sourcedata/license.txt" --output-spaces MNI152NLin2009cAsym:res-2 --stop-on-first-crash -w "/Users/Carlos Leandro/Desktop/dados/workdir" --mem-mb 6000
Warning: <8GB of RAM is available within your Docker environment.
Some parts of fMRIPrep may fail to complete.
Continue anyway? [y/N]y
RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=20.10.17 -it -v C:\Users\Carlos Leandro\Desktop\sourcedata\license.txt:/opt/freesurfer/license.txt:ro -v C:\Users\Carlos Leandro\Desktop\dados\bids:/data:ro -v C:\Users\Carlos Leandro\dados\derivatives:/out -v C:\Users\Carlos Leandro\Desktop\dados\workdir:/scratch nipreps/fmriprep:22.1.1 /data /out participant --participant-label 01 --md-only-boilerplate --stop-on-first-crash --mem-mb 6000 -w /scratch --output-spaces MNI152NLin2009cAsym:res-2
--topup-max-vols input is no longer used and the flag will be removed in a future release.
bids-validator@1.8.0

        1: [ERR] Invalid JSON file. The file is not formatted according the schema. (code: 55 - JSON_SCHEMA_VALIDATION_ERROR)
                ./sub-01/func/sub-01_task-fMRITESTE6_run-1_echo-1_bold.json
                        Evidence: .TaskName should be string

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

        2: [ERR] Bold scans must be 4 dimensional. (code: 54 - BOLD_NOT_4D)
                ./sub-01/func/sub-01_task-fMRITESTE6_run-1_echo-1_bold.nii.gz
                        Evidence: header field "dim" = 3,112,112,1

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

        3: [ERR] "SliceTiming" value/s contains invalid value as it is greater than RepetitionTime.  SliceTiming values should be in seconds not milliseconds (common mistake). (code: 66 - SLICETIMING_VALUES_GREATOR_THAN_REPETITION_TIME)
                ./sub-01/func/sub-01_task-fMRITESTE6_run-1_echo-1_bold.nii.gz
                        Evidence: 5.083

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

        4: [ERR] NIfTI file's header is missing time dimension information. (code: 75 - NIFTI_PIXDIM4)
                ./sub-01/func/sub-01_task-fMRITESTE6_run-1_echo-1_bold.nii.gz

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

        1: [WARN] The Authors field of dataset_description.json should contain an array of fields - with one author per field. This was triggered based on the presence of only one author field. Please ignore if all contributors are already properly listed. (code: 102 - TOO_FEW_AUTHORS)

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


        Summary:                Available Tasks:        Available Modalities:
        9 Files, 38.93KB                                MRI
        1 - Subject
        1 - Session


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

Traceback (most recent call last):
  File "/opt/conda/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/run.py", line 42, in main
    parse_args()
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/parser.py", line 810, in parse_args
    validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/utils/bids.py", line 186, in validate_input_dir
    subprocess.check_call(['bids-validator', str(bids_dir), '-c', temp.name])
  File "/opt/conda/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bids-validator', '/data', '-c', '/tmp/tmpsmpu096o.json']' returned non-zero exit status 1.

Best,
Carlos

Hi @CarlosLeandro09,

Yes, your data are not BIDS valid, according to the official BIDS validator. Looking at the errors 1-by-1:

All you need to do here is add TaskName: "fMRITESTE6" to the BOLD json file

I have no idea why a BOLD file would only have one volume, and also it’s strange that you only have 3 slices in the X direction. You might want to reconfirm that you converted Nifti from DCM correctly.

Both of these errors would probably be fixed by confirming you are using the most recent version of dcm2niix.

In short, I would suggest using a tool such as dcm2bids to go from dicoms to a BIDS valid dataset. There are tutorials on the website I linked. If done properly, it should take care of all the errors.

Best,
Steven

Thanks a million @Steven! This means a lot to me.
I will do everything you shared.