fMRIprep, dcm2bids Issues (IndexError: tuple index out of range)

Summary of what happened:

Hi all! I have been having some issues running fMRIprep for a dataset of participants. I had issues using clpipe, so recently I turned to Python to run dcm2bids as a way to do a conversion. For most of our participant data, fMRIprep has worked fine, but for some, we are getting error messages that don’t seem to reflect errors with the data. When running BIDS validation, we get “BOLD scans need 4 dimensions” and “SliceTiming > RepetitionTiming” error messages. When running fMRIprep, we get the “tuple index out of range” error.

I have tried updating versions, editing the configuration file, and trying to split up dcm2niix and a Nifti to BIDS conversion to try to find the root of the issue but I haven’t had any luck figuring out what’s wrong.

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

%matplotlib inline

import os
import glob
from tqdm import tqdm
import pandas as pd
import numpy as np

base_dir = '/proj/hng/keelylab/projects/npirs'

!pip install nltools
!pip install dcm2niix
!pip install dcm2bids

nifti_dir = os.path.join(base_dir,'niftis','NPIRS-111')
dicom2nifti = "/nas/longleaf/home/mktark/dcm2niix/build/bin/dcm2niix -z y"
!{dicom2nifti} {nifti_dir}

conv = os.path.join(base_dir, 'conversion_config.json')
bids_dir = os.path.join(base_dir, 'data_BIDS')
!dcm2bids -d {nifti_dir} -p 111 -c {conv} -o {bids_dir} --clobber --force_dcm2bids

Version:

fMRIprep v. 22.1.1 (the newer version wouldn’t run for any participant data) / dcm2bids v. 3.1.1 / dcm2niix v. 1.0.20230411

Environment (Docker, Singularity / Apptainer, custom installation):

pip install; clpipe

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

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

INFO:    Environment variable SINGULARITYENV_TEMPLATEFLOW_HOME is set, but APPTAINERENV_TEMPLATEFLOW_HOME is preferred
You are using fMRIPrep-22.1.1, and a newer version of fMRIPrep is available: 23.1.4.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
--topup-max-vols input is no longer used and the flag will be removed in a future release.
240116-08:52:36,557 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.
         #################################################################
240116-08:52:36,559 nipype.workflow WARNING:
	 Previous output generated by version 0+unknown found.
240116-08:52:48,210 nipype.workflow IMPORTANT:
	 Building fMRIPrep's workflow:
           * BIDS dataset path: /proj/hng/keelylab/projects/npirs/data_BIDS.
           * Participant list: ['112'].
           * Run identifier: 20240116-085107_135568a3-84f3-46a4-b8a3-1d63eff9c853.
           * Output spaces: MNI152NLin2009cAsym:res-native.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /proj/hng/keelylab/projects/npirs/data_fmriprep_downgrade/sourcedata/freesurfer.
240116-08:52:59,563 nipype.workflow INFO:
	 B0 field inhomogeneity map will be estimated with  the following 27 estimators: [<EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>, <EstimatorType.PEPOLAR: 2>].
240116-08:53:00,459 nipype.workflow INFO:
	 No single-band-reference found for sub-112_task-impressions_bold.nii.gz.
240116-08:53:00,460 nipype.workflow CRITICAL:
	 None of the available B0 fieldmaps are associated to </proj/hng/keelylab/projects/npirs/data_BIDS/sub-112/func/sub-112_task-impressions_bold.nii.gz>
240116-08:53:00,821 nipype.workflow IMPORTANT:
	 BOLD series will be slice-timing corrected to an offset of 0.346s.
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

Hi @mktark and welcome to neurostars!

We’ll need some more information to accurately debug here.

Sounds like it may be an issue with either the dicom conversion, an incomplete or partial scan, or the dcm2bids config is not specific enough (e.g., it is labeling the sbref as the BOLD file).

The following information would help:

  1. Your dcm2bids config
  2. Some example JSONs from the dcm2niix conversion
  3. The directory layout (e.g. tree) run on a failing subject’s data directory
  4. The full BIDS validation report
  5. The command you use to run fMRIPrep

Also, you should aim to get fmriprep 23.2.0 working. What is the error you get there?

Not related to your problem, but you will have to be sure to edit the IntendedFor fields in your JSON to remove the BIDS URI (e.g., bids::sub-112/, the remainder should be the path relative to within the subject directory) to make sure your fieldmaps are associated with your BOLD files. Experimental support for the BIDS URI should be in the next release of fMRIPrep.

Best,
Steven

Hi @Steven Thank you so much for the timely response!

In terms of the updated fMRIprep, we were having skull stripping issues and half of our data was bad so our colleague recommended going down to the 22.1.1 as a means to try to remedy that (which so far it has).

dcm2bids conversion configuration:

 {"dcm2niixOptions": "-b y -ba y -z y -f '%3s_%f_%p_%t' -d 9",
	
  "descriptions": [
      {
          "datatype": "anat",
          "suffix": "T1w",
          "criteria": {
              "SeriesDescription": "*ADNI3_t1_mprag_sag_p2_iso*",
              "EchoTime": 0.00296
          },
          "sidecar_changes": {
              "ProtocolName": "*ADNI3_t1_mprag_sag_p2_iso*"
          }
      },
      {
          "id": "task-rest1",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task-rest1",
          "criteria": {
              "SeriesDescription": "*rfMRI_REST1_PA*"
          },
          "sidecar_changes": {
              "TaskName": "REST1"
          }
      },
      {
          "datatype": "fmap",
          "suffix": "epi",
          "criteria": {
              "SeriesDescription": "*rfMRI_REST1_AP*"
          }
      },
      {
          "id": "task-impressions",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task-impressions",
          "criteria": {
              "SeriesDescription": "*rfMRI_impressions_PA*"
          },
          "sidecar_changes": {
              "TaskName": "impressions"
          }
      },
      {
          "id": "task-rest2",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task-rest2",
          "criteria": {
              "SeriesDescription": "*rfMRI_REST2_PA*"
          },
          "sidecar_changes": {
              "TaskName": "REST2"
          }
      },
      {
          "datatype": "fmap",
          "suffix": "epi",
          "criteria": {
              "SeriesDescription": "*rfMRI_REST2_AP*"
          }
      },
      {
          "datatype": "fmap",
          "suffix": "epi",
          "custom_entities": "acq-FMAP_dir-PA",
          "criteria": {
              "SeriesDescription": "*SpinEchoFieldMap_PA*"
          }
      },
      {
          "datatype": "fmap",
          "suffix": "epi",
          "custom_entities": "acq-FMAP_dir-AP",
          "criteria": {
              "SeriesDescription": "*SpinEchoFieldMap_AP*"
          }
      }
  ]
}

Example JSON from dcm2niix:

{
	"Modality": "MR",
	"MagneticFieldStrength": 3,
	"ImagingFrequency": 123.247967,
	"Manufacturer": "Siemens",
	"ManufacturersModelName": "Prisma_fit",
	"DeviceSerialNumber": "24d905581b269d7e",
	"StationName": "P1",
	"SeriesInstanceUID": "1.3.12.2.230132.159198.313799.203242.221271.801681",
	"StudyInstanceUID": "1.3.12.2.180105.142781.120019.121783.211236.209821",
	"ReferringPhysicianName": "fw://muscatellk/NPIRS",
	"PatientName": "NPIRS-111",
	"PatientID": "NPIRS-111/visit1",
	"PatientWeight": 58.967,
	"BodyPartExamined": "BRAIN",
	"PatientPosition": "HFS",
	"ProcedureStepDescription": "PRISMA^HEAD",
	"SoftwareVersions": "syngo MR E11",
	"MRAcquisitionType": "3D",
	"SeriesDescription": "ADNI3_t1_mprag_sag_p2_iso",
	"ProtocolName": "ADNI3_t1_mprag_sag_p2_iso",
	"ScanningSequence": "GR\\IR",
	"SequenceVariant": "SK\\SP\\MP",
	"ScanOptions": "IR",
	"SequenceName": "*tfl3d1_16ns",
	"ImageType": ["ORIGINAL", "PRIMARY", "M", "NORM", "DIS3D", "DIS2D"],
	"NonlinearGradientCorrection": true,
	"SeriesNumber": 2,
	"AcquisitionNumber": 1,
	"SliceThickness": 1,
	"SAR": 0.0571503,
	"EchoTime": 0.00296,
	"RepetitionTime": 2.3,
	"SpoilingState": true,
	"InversionTime": 0.9,
	"FlipAngle": 9,
	"PartialFourier": 1,
	"BaseResolution": 256,
	"ShimSetting": [
		-1664,
		7498,
		6659,
		528,
		-43,
		-101,
		157,
		14	],
	"TxRefAmp": 230.316,
	"PhaseResolution": 1,
	"ReceiveCoilName": "Head_32",
	"ReceiveCoilActiveElements": "HEA;HEP",
	"PulseSequenceDetails": "%SiemensSeq%\\tfl",
	"RefLinesPE": 32,
	"CoilCombinationMethod": "Adaptive Combine",
	"ConsistencyInfo": "N4_VE11C_LATEST_20160120",
	"MatrixCoilMode": "GRAPPA",
	"PercentPhaseFOV": 93.75,
	"PercentSampling": 100,
	"PhaseEncodingSteps": 239,
	"AcquisitionMatrixPE": 240,
	"ReconMatrixPE": 240,
	"ParallelReductionFactorInPlane": 2,
	"PixelBandwidth": 240,
	"DwellTime": 8.1e-06,
	"ImageOrientationPatientDICOM": [
		0,
		1,
		0,
		0,
		0,
		-1	],
	"ImageOrientationText": "Sag",
	"InPlanePhaseEncodingDirectionDICOM": "ROW",
	"ConversionSoftware": "dcm2niix",
	"ConversionSoftwareVersion": "v1.0.20230411"
}

Command for fMRIprep: clpipe preprocess 111 -c /proj/hng/keelylab/projects/npirs/clpipe_config_mktark_OLD.json -submit

clpipe configuration file:

	"ProjectTitle": "NPIRS",
	"Authors/Contributors": "Madison Tarkenton",
	"ProjectDirectory": "/proj/hng/keelylab/projects/npirs",
	"EmailAddress": "mktark@unc.edu",
	"SourceOptions": {
		"SourceURL": "fw://muscatellk/NPIRS",
		"DropoffDirectory": "/proj/hng/keelylab/projects/npirs/flywheel_raw",
		"TempDirectory": "/proj/hng/keelylab/projects/npirs/dicoms",
		"CommandLineOpts": "-y",
		"TimeUsage": "1:0:0",
		"MemUsage": "10000",
		"CoreUsage": "1"
	},
	"DICOMToBIDSOptions": {
		"DICOMDirectory": "/proj/hng/keelylab/projects/npirs/niftis",
		"BIDSDirectory": "/proj/hng/keelylab/projects/npirs/data_BIDS",
		"ConversionConfig": "/proj/hng/keelylab/projects/npirs/conversion_config.json",
		"DICOMFormatString": "NPIRS-{subject}",
		"TimeUsage": "5:0:0",
		"MemUsage": "5000",
		"CoreUsage": "2",
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/DCM2BIDS_logs"
	},
	"BIDSValidationOptions": {
		"BIDSValidatorImage": "/proj/hng/singularity_imgs/validator.simg",
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/bids_validation_logs"
	},
	"FMRIPrepOptions": {
		"BIDSDirectory": "/proj/hng/keelylab/projects/npirs/data_BIDS",
		"WorkingDirectory": "/work/users/m/k/mktark",
		"OutputDirectory": "/proj/hng/keelylab/projects/npirs/data_fmriprep_downgrade",
		"FMRIPrepPath": "/proj/hng/singularity_imgs/fmriprep_22.1.1.sif",
		"FreesurferLicensePath": "/proj/hng/singularity_imgs/license.txt",
		"UseAROMA": true,
		"CommandLineOpts": "--skip_bids_validation",
		"TemplateFlowToggle": true,
		"TemplateFlowPath": "/proj/hng/singularity_imgs/template_flow",
		"TemplateFlowTemplates": [
			"MNI152NLin2009cAsym",
			"MNI152NLin6Asym",
			"OASIS30ANTs",
			"MNIPediatricAsym",
			"MNIInfant"
		],
		"FMapCleanupROIs": 10,
		"FMRIPrepMemoryUsage": "50000",
		"FMRIPrepTimeUsage": "72:0:0",
		"NThreads": "12",
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/FMRIprep_logs",
		"DockerToggle": false,
		"DockerFMRIPrepVersion": ""
	},
	"PostProcessingOptions": {
		"TargetDirectory": "/proj/hng/keelylab/projects/npirs/data_fmriprep_downgrade",
		"TargetSuffix": "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz",
		"OutputDirectory": "/proj/hng/keelylab/projects/npirs/data_postproc/postproc_default",
		"OutputSuffix": "postproc.nii.gz",
		"ConfoundSuffix": "desc-confounds_timeseries.tsv",
		"DropCSV": "",
		"Regress": true,
		"Confounds": [
			"trans_x",
			"trans_y",
			"trans_z",
			"rot_x",
			"rot_y",
			"rot_z",
			"csf",
			"white_matter",
			"global_signal",
			"a_comp_cor.*"
		],
		"ConfoundsQuad": [
			"trans_x",
			"trans_y",
			"trans_z",
			"rot_x",
			"rot_y",
			"rot_z",
			"csf",
			"white_matter",
			"global_signal"
		],
		"ConfoundsDerive": [
			"trans_x",
			"trans_y",
			"trans_z",
			"rot_x",
			"rot_y",
			"rot_z",
			"csf",
			"white_matter",
			"global_signal"
		],
		"ConfoundsQuadDerive": [
			"trans_x",
			"trans_y",
			"trans_z",
			"rot_x",
			"rot_y",
			"rot_z",
			"csf",
			"white_matter",
			"global_signal"
		],
		"FilteringHighPass": 0.008,
		"FilteringLowPass": -1,
		"FilteringOrder": 2,
		"OversamplingFreq": 4,
		"PercentFreqSample": 1,
		"Scrubbing": true,
		"ScrubVar": "framewise_displacement",
		"ScrubFDThreshold": 0.3,
		"ScrubAhead": 1,
		"ScrubBehind": 1,
		"ScrubContig": 2,
		"RespNotchFilter": true,
		"MotionVars": [
			"trans_x",
			"trans_y",
			"trans_z",
			"rot_x",
			"rot_y",
			"rot_z"
		],
		"RespNotchFilterBand": [
			0.31,
			0.43
		],
		"PostProcessingMemoryUsage": "20000",
		"PostProcessingTimeUsage": "8:0:0",
		"NThreads": "1",
		"SpectralInterpolationBinSize": 5000,
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/postproc_logs"
	},
	"PostProcessingOptions2": {
		"WorkingDirectory": "",
		"WriteProcessGraph": true,
		"TargetDirectory": "",
		"TargetImageSpace": "MNI152NLin2009cAsym",
		"TargetTasks": [],
		"TargetAcquisitions": [],
		"OutputDirectory": "",
		"ProcessingSteps": [
			"SpatialSmoothing",
			"TemporalFiltering",
			"IntensityNormalization",
			"ApplyMask"
		],
		"ProcessingStepOptions": {
			"TemporalFiltering": {
				"Implementation": "fslmaths",
				"FilteringHighPass": 0.008,
				"FilteringLowPass": -1,
				"FilteringOrder": 2
			},
			"IntensityNormalization": {
				"Implementation": "10000_GlobalMedian"
			},
			"SpatialSmoothing": {
				"Implementation": "SUSAN",
				"FWHM": 6
			},
			"AROMARegression": {
				"Implementation": "fsl_regfilt"
			},
			"ScrubTimepoints": {
				"TargetVariable": "framewise_displacement",
				"Threshold": 0.9,
				"ScrubAhead": 0,
				"ScrubBehind": 0,
				"ScrubContiguous": 0,
				"InsertNA": true
			},
			"Resample": {
				"ReferenceImage": "SET REFERENCE IMAGE"
			},
			"TrimTimepoints": {
				"FromEnd": 0,
				"FromBeginning": 0
			},
			"ConfoundRegression": {
				"Implementation": "afni_3dTproject"
			}
		},
		"ConfoundOptions": {
			"Columns": [
				"csf",
				"csf_derivative1",
				"white_matter",
				"white_matter_derivative1"
			],
			"MotionOutliers": {
				"Include": true,
				"ScrubVar": "framewise_displacement",
				"Threshold": 0.9,
				"ScrubAhead": 0,
				"ScrubBehind": 0,
				"ScrubContiguous": 0
			}
		},
		"BatchOptions": {
			"MemoryUsage": "20000",
			"TimeUsage": "2:0:0",
			"NThreads": "1"
		}
	},
	"BetaSeriesOptions": {
		"TargetDirectory": "/proj/hng/keelylab/projects/npirs/data_fmriprep_downgrade",
		"TargetSuffix": "preproc_bold.nii.gz",
		"OutputDirectory": "/proj/hng/keelylab/projects/npirs/data_postproc/betaseries_default",
		"OutputSuffix": "betaseries.nii.gz",
		"ConfoundSuffix": "desc-confounds_regressors.tsv",
		"Regress": true,
		"NuisanceRegression": "QuadLagged",
		"WhiteMatter": true,
		"CSF": true,
		"GlobalSignalRegression": true,
		"FilteringHighPass": 0.008,
		"FilteringLowPass": -1,
		"FilteringOrder": 2,
		"TaskSpecificOptions": [
			{
				"Task": "",
				"ExcludeColumnInfo": "trial_type",
				"ExcludeTrialTypes": [
					"block"
				]
			}
		],
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/betaseries_logs"
	},
	"SUSANOptions": {
		"TargetDirectory": "/proj/hng/keelylab/projects/npirs/data_postproc/postproc_default",
		"TargetSuffix": "postproc.nii.gz",
		"OutputDirectory": "/proj/hng/keelylab/projects/npirs/data_postproc/postproc_default",
		"OutputSuffix": "postproc_default.nii.gz",
		"BrightnessThreshold": 500,
		"FWHM": 0,
		"MemoryUsage": "5000",
		"TimeUsage": "2:0:0",
		"NThreads": "4",
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/SUSAN_logs"
	},
	"ProcessingStreams": [
		{
			"ProcessingStream": "smooth_aroma-regress_filter_normalize",
			"PostProcessingOptions": {
				"ProcessingSteps": [
					"SpatialSmoothing",
					"AROMARegression",
					"TemporalFiltering",
					"IntensityNormalization"
				]
			}
		},
		{
			"ProcessingStream": "filter_confound-regress",
			"PostProcessingOptions": {
				"ProcessingSteps": [
					"TemporalFiltering",
					"ConfoundRegression"
				]
			}
		},
		{
			"ProcessingStream": "smooth_aroma-regress_filter_normalize_fwhm-8",
			"PostProcessingOptions": {
				"ProcessingSteps": [
					"SpatialSmoothing",
					"AROMARegression",
					"TemporalFiltering",
					"IntensityNormalization"
				],
				"ProcessingStepOptions": {
					"SpatialSmoothing": {
						"FWHM": 8
					}
				}
			}
		}
	],
	"ROIExtractionOptions": {
		"TargetDirectory": "/proj/hng/keelylab/projects/npirs/data_postproc2/default",
		"TargetSuffix": "postproc_bold.nii.gz",
		"OutputDirectory": "/proj/hng/keelylab/projects/npirs/data_ROI_ts/postproc_default",
		"Atlases": [
			"power"
		],
		"RequireMask": true,
		"PropVoxels": 0.5,
		"MemoryUsage": "20000",
		"TimeUsage": "2:0:0",
		"NThreads": "1",
		"LogDirectory": "/proj/hng/keelylab/projects/npirs/logs/ROI_extraction_logs"
	},
	"ReHoExtraction": {
		"TargetDirectory": "",
		"TargetSuffix": "",
		"ExclusionFile": "",
		"WorkingDirectory": "",
		"MaskDirectory": "",
		"MaskSuffix": "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz",
		"MaskFileOverride": "",
		"OutputDirectory": "",
		"OutputSuffix": "",
		"Neighborhood": "vertices",
		"LogDirectory": ""
	},
	"T2StarExtraction": {
		"TargetDirectory": "",
		"TargetSuffix": "",
		"ExclusionFile": "",
		"WorkingDirectory": "",
		"MaskDirectory": "",
		"MaskSuffix": "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz",
		"MaskFileOverride": "",
		"OutputDirectory": "",
		"OutputSuffix": "",
		"LogDirectory": ""
	},
	"RunLog": [],
	"StatusCache": "",
	"BatchConfig": "slurmUNCConfig.json"
}

Hi @mktark,

You did not specify any IntendedFor in your dcm2bids configs, so your fieldmaps will not be associated with any of your images.

You forwarded one of the T1w jsons as far as I can tell. One for your BOLD images that you are having trouble with might be more informative.

In your config you have task-rest1 and task-rest2. Why not do task-rest and have run-1/2 (if same sequnece) or acq-1/2 (if they are different acquisition patterns)

This might be too liberal. What if your SBREF images have this same string in them? That could explain why you get a 3D image in BOLD labeled incorrectly in your original error.\

Also I can’t help much on the fMRIPrep side because I do not know how CIPipe is working. I suggest running fMRIPrep directly if you can for easier trouble shooting / fewer moving parts.

Best,
Steven

Hi @Steven
For the IntendedFor, I thought it wasn’t compatible with the 3.1.1 version of dcm2bids.

BOLD image json:

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.248203,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "Prisma_fit",
    "InstitutionName": "University of North Carolina BRIC",
    "InstitutionalDepartmentName": "Department",
    "InstitutionAddress": "Mason Farm Rd 106,Chapel Hill,District,US,27599",
    "DeviceSerialNumber": "67094",
    "StationName": "Prisma",
    "BodyPartExamined": "BRAIN",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "PRISMA^HEAD",
    "SoftwareVersions": "syngo MR E11",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "rfMRI_impressions_PA_SBRef",
    "ProtocolName": "rfMRI_impressions_PA",
    "ScanningSequence": "EP",
    "SequenceVariant": "SK\\SS",
    "ScanOptions": "FS",
    "SequenceName": "epfid2d1_104",
    "ImageType": [
        "ORIGINAL",
        "PRIMARY",
        "M",
        "ND",
        "MOSAIC"
    ],
    "NonlinearGradientCorrection": false,
    "SeriesNumber": 7,
    "AcquisitionTime": "13:22:13.987500",
    "AcquisitionNumber": 1,
    "ImageComments": "Single-band reference",
    "SliceThickness": 2,
    "SpacingBetweenSlices": 2,
    "SAR": 0.0632185,
    "EchoTime": 0.037,
    "RepetitionTime": 0.8,
    "FlipAngle": 52,
    "PartialFourier": 1,
    "BaseResolution": 104,
    "ShimSetting": [
        -1681,
        7508,
        6608,
        548,
        -124,
        -366,
        -128,
        82
    ],
    "TxRefAmp": 229.166,
    "PhaseResolution": 1,
    "ReceiveCoilName": "Head_32",
    "ReceiveCoilActiveElements": "HEA;HEP",
    "PulseSequenceDetails": "%CustomerSeq%\\cmrr_mbep2d_bold",
    "WipMemBlock": "ec6eeb12-f382-431f-8bc2-ff83ffbc206a||Sequence: R016 ve11c/master r/e634e98; Dec 19 2017 11:00:25 by eja",
    "CoilCombinationMethod": "Sum of Squares",
    "ConsistencyInfo": "N4_VE11C_LATEST_20160120",
    "MatrixCoilMode": "SENSE",
    "PercentPhaseFOV": 100,
    "PercentSampling": 100,
    "EchoTrainLength": 104,
    "PhaseEncodingSteps": 104,
    "AcquisitionMatrixPE": 104,
    "ReconMatrixPE": 104,
    "BandwidthPerPixelPhaseEncode": 16.578,
    "EffectiveEchoSpacing": 0.000580009,
    "DerivedVendorReportedEchoSpacing": 0.000580009,
    "TotalReadoutTime": 0.0597409,
    "PixelBandwidth": 2290,
    "DwellTime": 2.1e-06,
    "PhaseEncodingDirection": "j",
    "SliceTiming": [
        0,
        0.0875,
        0.175,
        0.26,
        0.3475,
        0.435,
        0.52,
        0.6075,
        0.695,
        0.78,
        0.8675,
        0.955,
        1.04,
        1.1275,
        1.215,
        1.3,
        1.3875,
        1.475,
        1.56,
        1.6475,
        1.735,
        1.82,
        1.9075,
        1.995,
        2.08,
        2.1675,
        2.255,
        2.34,
        2.4275,
        2.515,
        2.6,
        2.6875,
        2.775,
        2.86,
        2.9475,
        3.035,
        3.12,
        3.2075,
        3.295,
        3.38,
        3.4675,
        3.555,
        3.64,
        3.7275,
        3.815,
        3.9,
        3.9875,
        4.075,
        4.16,
        4.2475,
        4.335,
        4.42,
        4.5075,
        4.595,
        4.68,
        4.7675,
        4.855,
        4.94,
        5.0275,
        5.115,
        5.2,
        5.2875,
        5.375,
        5.46,
        5.5475,
        5.635,
        5.72,
        5.8075,
        5.895,
        5.98,
        6.0675,
        6.155
    ],
    "ImageOrientationPatientDICOM": [
        0.995437,
        -0.0428988,
        -0.0852298,
        1.56636e-08,
        0.893234,
        -0.449592
    ],
    "ImageOrientationText": "Tra>Cor(-26.7)>Sag(-5.5)",
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20230411",
    "Dcm2bidsVersion": "3.1.1",
    "TaskName": "impressions"
}

In terms of the configuration file rest we used a configuration file from a department head that works with clpipe, but am open to adjusting if it would make the code run more smoothly.

How would you recommend running fMRIprep directly?

Not sure what you mean there. IntendedFor works, as I mentioned for current and past versions of fMRIPrep you just need to remove the BIDS URI after the fact.

You can review the documentation here: Usage Notes — fmriprep version documentation

How would you rewrite the IntendedFor code into the conversion configuration file?

As you can see, your config will count an SBRef as a BOLD image because the criteria is too liberally defined.

1 Like

You can see an example in

1 Like

Are there any other issues you could see with the code? I will try to fix the configuration file and see if that helps.

For the T1w, you might have to additionally specify ImageType as an additional criteria to get the RMS norm T1 if it is also output from the scanner.

Additionally, depending on what kind of fmaps you are using, you might want to specify a dir-<> as a custom_entities.

1 Like

I am still having issues writing a configuration file that works for the data. Does anyone have experience writing one? I tried to use dcm2bids-helper but am still having issues with the data output and being able to morph that into a configuration file that works for all participants.

Here is the current edited version:

{"dcm2niixOptions": "-b y -ba y -z y -f '%3s_%f_%p_%t' -d 9",
	
  "descriptions": [
      {
          "datatype": "anat",
          "suffix": "T1w",
          "criteria": {
              "SeriesDescription": "ADNI3_t1_mprag_sag_p2_iso",
              "EchoTime": 0.00296
          },
          "sidecar_changes": {
              "ProtocolName": "ADNI3_t1_mprag_sag_p2_iso"
          }
      },
      {
          "id": "task-rest1",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task",
          "criteria": {
              "SeriesDescription": "rfMRI_REST1_PA"
          },
          "sidecar_changes": {
              "TaskName": "REST1"
          }
      },
      {
          "datatype": "func",
          "suffix": "sbref",
          "criteria": {
              "SeriesDescription": "rfMRI_REST1_PA_SBRef"
          },
          "sidecar_changes": {
              "ProtocolName": "rfMRI_REST1_PA_SBRef"
          }
      },
      {
          "id": "task-rest1",
          "datatype": "func",
          "suffix": "bold",
          "custom-entities": "task",
          "criteria": {
              "SeriesDescription": "rfMRI_REST1_AP"
          },
          "sidecar_changes":{
              "TaskName": "REST1"
          }
      },
      {
          "datatype": "func",
          "suffix": "sbref",
          "criteria": {
              "SeriesDescription": "rfMRI_REST1_AP_SBRef"
          },
          "sidecar_changes": {
              "ProtocolName": "rfMRI_REST1_AP_SBRef"
          }
      },
      {
          "id": "task-impressions",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task",
          "criteria": {
              "SeriesDescription": "rfMRI_impressions_PA"
          },
          "sidecar_changes": {
              "TaskName": "Impressions"
          }
      },
      {
          "datatype": "func",
          "suffix": "sbref",
          "criteria": {
              "SeriesDescription": "rfMRI_impressions_PA_SBRef"
          },
          "sidecar_changes": {
              "ProtocolName": "rfMRI_impressions_PA_SBRef"
          }
      },
      {
          "id": "task-rest2",
          "datatype": "func",
          "suffix": "bold",
          "custom_entities": "task",
          "criteria": {
              "SeriesDescription": "rfMRI_REST2_PA"
          },
          "sidecar_changes": {
              "TaskName": "REST2"
          }
      },
      {
          "datatype": "func",
          "suffix": "sbref",
          "criteria": {
              "SeriesDescription": "rfMRI_REST2_PA_SBRef"
          },
          "sidecar_changes": {
              "ProtocolName": "rfMRI_REST2_PA_SBRef"
          }
      },
      {
          "id": "task-rest2",
          "datatype": "func",
          "suffix": "bold",
          "custom-entities": "task",
          "criteria": {
              "SeriesDescription": "rfMRI_REST2_AP"
          },
          "sidecar_changes":{
              "TaskName": "REST2"
          }
      },
      {
          "datatype": "func",
          "suffix": "sbref",
          "criteria": {
              "SeriesDescription": "rfMRI_REST2_AP_SBRef"
          },
          "sidecar_changes": {
              "ProtocolName": "rfMRI_REST2_AP_SBRef"
          }
      },
      {
          "id": "spin-echo",
          "datatype": "fmap",
          "suffix": "epi",
          "custom_entities": "dir",
          "criteria": {
              "SeriesDescription": "*SpinEchoFieldMap_PA*"
          }
      },
      {
          "id": "spin-echo",
          "datatype": "fmap",
          "suffix": "epi",
          "custom_entities": "dir",
          "criteria": {
              "SeriesDescription": "*SpinEchoFieldMap_AP*"
          }
      }
  ]
}

We can’t really write one for you unless we have a full set of JSONS you need, and the desired naming convention you want for each one. We also do not know what errors you are getting currently / what outputs look like with your current command.

I see. The errors remain the same when running through fMRIprep, but I also noticed that the output when running dcm2bids just looks funny in terms of the anat, func, and fmap folders.

But I see based on what you just shared you did not add the IntendedFor field in the fmaps (First steps - dcm2bids documentation), e.g.

      "sidecar_changes": {
        "intendedFor": ["id_task-rest"]
      }

And your custom_entities (e.g., "custom_entities": "dir") is underspecified (should be something like dir-PA [j] or dir-AP [j-] depending on phase encoding direction). Unless you try the --auto_extract_entities option which will try to guess some of that information for you.

Best,
Steven

1 Like