Missing information JSON files

Hello everyone!
I ran a draft of my BIDS dataset through the BIDS validator and I got several errors. While trying to fix those, I noticed that whatever I put in my configuration files, it doesn’t change anything. For example, it indicates “error: SIDECAR_KEY_REQUIRED (TaskName)”. I updated my configuration file and made sure that the TaskName sidecar is in there. But when I check my json files after re-running dcm2bids, it still doesn’t include the TaskName. Similarly, the fieldmap json files do not include the IntendedFor information, even though I included this in the configuration file just like explained in the dcm2bids documentation. I would really appreciate it if someone could check my scripts and configuration files to see why exactly this is happening. Thank you!

dcm2bids version: 3.2.0
dcm2niix version: v1.0.20240202

CONFIGURATION FILE

{
  "descriptions": [
   {
      "id": "id_task-RS1",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-RS1",
      "criteria": {
        "ProtocolName": "Mb5_55slice_RS1"
      },
      "sidecarChanges": {
        "TaskName": "RS1"
      }
    },
    {
      "id": "id_task-training1",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-training1",
      "criteria": {
        "ProtocolName": "Mb5_55slice_MSL_1"
      },
      "sidecarChanges": {
         "TaskName": "training1"
      }
    },

    {
      "id": "id_task-training2",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-training2",
      "criteria": {
         "ProtocolName": "Mb5_55slice_MSL_2"
      }, 
      "sidecarChanges": {
        "TaskName": "training2"
      } 
    },
    {
      "id": "id_task-test",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-test",
      "criteria": {
        "ProtocolName": "Mb5_55slice_MSL_TEST"
      },
      "sidecarChanges": {
         "TaskName": "test"
      }
    },
    {
      "id": "id_task-RS2",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-RS2",
      "criteria": {
        "ProtocolName": "Mb5_55slice_RS2"
      },
      "sidecarChanges": {
        "TaskName": "RS2"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "epi",
      "criteria": {
        "ProtocolName": "gre_field_mapping",
        "ImageType": ["ORIGINAL", "PRIMARY", "M", "NONE"],
        "EchoTime": 0.00519
      },
      "sidecarChanges": {
         "TaskName": "fmap_magn1_sess1",
         "IntendedFor":[
           "id_task-RS1",
           "id_task-training1",
           "id_task-training2",
           "id_task-test",
           "id_task-RS2"	
	  ]
      }
    },
    {
      "datatype": "fmap",
      "suffix": "epi",
      "criteria": {
        "ProtocolName": "gre_field_mapping",
        "ImageType": ["ORIGINAL", "PRIMARY", "M", "NONE"],
        "EchoTime": 0.00765
      },
      "sidecarChanges": {
        "TaskName": "fmap_magn2_sess1",
        "IntendedFor":[
           "id_task-RS1",
           "id_task-training1",
           "id_task-training2",
           "id_task-test",
           "id_task-RS2"		
	  ]
      }
    },
    {
      "datatype": "fmap",
      "suffix": "phasediff",
      "criteria": {
        "ProtocolName": "gre_field_mapping",
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "NONE", "PHASE"]
      },
      "sidecarChanges": {
         "TaskName": "fmap_phasediff_sess1",
         "IntendedFor": [
           "id_task-RS1",
           "id_task-training1",
           "id_task-training2",
           "id_task-test",
           "id_task-RS2"		
	  ]
      }
    }
   ]
}

PYTHON SCRIPT (2 sessions but included configuration file of just 1)

import subprocess

# Function to run dcm2bids command

def run_dcm2bids(dicom_dir, participant, session, config_file, output_dir):
    # Constructing the command
    command = [
        'dcm2bids',  		# Command to be executed
        '-d', dicom_dir,  	# DICOM directory argument
        '-p', participant, 	# Participant ID argument
        '-s', session,  	# Session ID argument
        '-c', config_file,  	# Configuration file argument
        '-o', output_dir,  	# Output directory argument
        '--auto_extract_entities',  
        '--force'  
    ]
    # Running the command
    subprocess.run(command, check=True)


# Participant ID
participant = '101'


# List of session directories for the participant and corresponding session information
sessions = [
    {
        'session': 's02',
        'dicom_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\E101\DCM\func\sess2',
        'config_file': r'C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json',
        'output_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS'
    },
    {
        'session': 's03',
        'dicom_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\E101\DCM\func\sess3',
        'config_file': r'C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess2.json',
        'output_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS'
    }
]

# Run dcm2bids for each session
for session_info in sessions:
    run_dcm2bids(
        dicom_dir=session_info['dicom_dir'],
        participant=participant,
        session=session_info['session'],
        config_file=session_info['config_file'],
        output_dir=session_info['output_dir']
    )

TASK JSON FILE (sub-101_ses-s02_task-training1_bold.json)

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.257897,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "MAGNETOM Vida",
    "InstitutionName": "UNIVERSITY of UTAH",
    "InstitutionAddress": "Arrapeen Dr. 729,Salt Lake City,UTAH,US,84108",
    "DeviceSerialNumber": "176038",
    "StationName": "AWP176038",
    "BodyPartExamined": "BRAIN",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "MRE729",
    "SoftwareVersions": "syngo MR XA50",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "Mb5_55slice_MSL_1",
    "ProtocolName": "Mb5_55slice_MSL_1",
    "ScanningSequence": "EP",
    "SequenceVariant": "SK",
    "ScanOptions": "FS",
    "PulseSequenceName": "*epfid2d1_88",
    "ImageType": [
        "ORIGINAL",
        "PRIMARY",
        "FMRI",
        "NONE"
    ],
    "ImageTypeText": [
        "ORIGINAL",
        "PRIMARY",
        "M",
        "ND"
    ],
    "NonlinearGradientCorrection": false,
    "SeriesNumber": 8,
    "AcquisitionTime": "10:13:38.577500",
    "AcquisitionNumber": 1,
    "SliceThickness": 2.5,
    "SpacingBetweenSlices": 2.5,
    "EchoTime": 0.031,
    "RepetitionTime": 0.797,
    "MTState": false,
    "FlipAngle": 59,
    "PartialFourier": 1,
    "BaseResolution": 88,
    "ShimSetting": [
        -4270,
        9543,
        9392,
        781,
        4,
        -315,
        -461,
        211
    ],
    "TxRefAmp": 304.876,
    "PhaseResolution": 1,
    "ReceiveCoilName": "HeadNeck_64_CS",
    "ReceiveCoilActiveElements": "HC3-7",
    "CoilString": "HeadNeck_64_CS",
    "PulseSequenceDetails": "%SiemensSeq%\\ep2d_bold",
    "RefLinesPE": 21,
    "CoilCombinationMethod": "Adaptive Combine",
    "MultibandAccelerationFactor": 5,
    "PercentPhaseFOV": 100,
    "PercentSampling": 100,
    "EchoTrainLength": 88,
    "PhaseEncodingSteps": 88,
    "FrequencyEncodingSteps": 88,
    "AcquisitionMatrixPE": 88,
    "ReconMatrixPE": 88,
    "BandwidthPerPixelPhaseEncode": 20.292,
    "ParallelAcquisitionTechnique": "SMS",
    "EffectiveEchoSpacing": 0.000560006,
    "DerivedVendorReportedEchoSpacing": 0.000560006,
    "AcquisitionDuration": 1203.7,
    "TotalReadoutTime": 0.0487205,
    "PixelBandwidth": 2273,
    "DwellTime": 2.5e-06,
    "PhaseEncodingDirection": "j-",
    "SliceTiming": [
        0,
        0.4225,
        0.07,
        0.4925,
        0.14,
        0.565,
        0.21,
        0.635,
        0.2825,
        0.705,
        0.3525,
        0,
        0.4225,
        0.07,
        0.4925,
        0.14,
        0.565,
        0.21,
        0.635,
        0.2825,
        0.705,
        0.3525,
        0,
        0.4225,
        0.07,
        0.4925,
        0.14,
        0.565,
        0.21,
        0.635,
        0.2825,
        0.705,
        0.3525,
        0,
        0.4225,
        0.07,
        0.4925,
        0.14,
        0.565,
        0.21,
        0.635,
        0.2825,
        0.705,
        0.3525,
        0,
        0.4225,
        0.07,
        0.4925,
        0.14,
        0.565,
        0.21,
        0.635,
        0.2825,
        0.705,
        0.3525
    ],
    "ImageOrientationPatientDICOM": [
        1,
        0,
        0,
        0,
        1,
        0
    ],
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "BidsGuess": [
        "func",
        "_acq-epfid2m5_dir-AP_run-8_bold"
    ],
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20240202",
    "Dcm2bidsVersion": "3.2.0"
}

MAGNITUDE FIELDMAP JSON FILE (sub-101_ses-s02_dir-AP_run-02_epi)

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.257875,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "MAGNETOM Vida",
    "InstitutionName": "UNIVERSITY of UTAH",
    "InstitutionAddress": "Arrapeen Dr. 729,Salt Lake City,UTAH,US,84108",
    "DeviceSerialNumber": "176038",
    "StationName": "AWP176038",
    "BodyPartExamined": "BRAIN",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "MRE729",
    "SoftwareVersions": "syngo MR XA50",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "gre_field_mapping",
    "ProtocolName": "gre_field_mapping",
    "ScanningSequence": "GR",
    "SequenceVariant": "SP",
    "PulseSequenceName": "*fm2d2r",
    "ImageType": [
        "ORIGINAL",
        "PRIMARY",
        "M",
        "NONE"
    ],
    "ImageTypeText": [
        "ORIGINAL",
        "PRIMARY",
        "M",
        "DIS2D"
    ],
    "NonlinearGradientCorrection": true,
    "SeriesNumber": 4,
    "AcquisitionTime": "10:00:24.005000",
    "AcquisitionNumber": 1,
    "SliceThickness": 2.5,
    "SpacingBetweenSlices": 2.5,
    "EchoNumber": 2,
    "EchoTime": 0.00765,
    "RepetitionTime": 0.752,
    "MTState": false,
    "FlipAngle": 90,
    "PartialFourier": 1,
    "BaseResolution": 88,
    "ShimSetting": [
        -4270,
        9543,
        9392,
        781,
        4,
        -315,
        -461,
        211
    ],
    "TxRefAmp": 304.876,
    "PhaseResolution": 1,
    "ReceiveCoilName": "HeadNeck_64_CS",
    "ReceiveCoilActiveElements": "HC3-7",
    "CoilString": "HeadNeck_64_CS",
    "PulseSequenceDetails": "%SiemensSeq%\\gre_field_mapping",
    "CoilCombinationMethod": "Sum of Squares",
    "MatrixCoilMode": "SENSE",
    "PercentPhaseFOV": 100,
    "PercentSampling": 100,
    "PhaseEncodingSteps": 88,
    "FrequencyEncodingSteps": 88,
    "AcquisitionMatrixPE": 88,
    "ReconMatrixPE": 88,
    "AcquisitionDuration": 131.587,
    "PixelBandwidth": 434,
    "DwellTime": 1.31e-05,
    "PhaseEncodingDirection": "j-",
    "SliceTiming": [
        0,
        0.3825,
        0.0125,
        0.395,
        0.0275,
        0.41,
        0.04,
        0.4225,
        0.055,
        0.4375,
        0.0675,
        0.45,
        0.0825,
        0.465,
        0.095,
        0.4775,
        0.1075,
        0.4925,
        0.1225,
        0.505,
        0.135,
        0.52,
        0.15,
        0.5325,
        0.1625,
        0.545,
        0.1775,
        0.56,
        0.19,
        0.5725,
        0.205,
        0.5875,
        0.2175,
        0.6,
        0.2325,
        0.615,
        0.245,
        0.6275,
        0.26,
        0.6425,
        0.2725,
        0.655,
        0.2875,
        0.67,
        0.3,
        0.6825,
        0.3125,
        0.6975,
        0.3275,
        0.71,
        0.34,
        0.725,
        0.355,
        0.7375,
        0.3675
    ],
    "ImageOrientationPatientDICOM": [
        1,
        0,
        0,
        0,
        1,
        0
    ],
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "BidsGuess": [
        "fmap",
        "_acq-fm2_magnitude2"
    ],
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20240202",
    "Dcm2bidsVersion": "3.2.0"
}

LOG OUTPUT FILE

2024-09-10 09:34:06.645 - INFO     - dcm2bids.main | --- dcm2bids start ---
2024-09-10 09:34:06.645 - INFO     - dcm2bids.main | Running the following command: C:\Users\u1350546\AppData\Local\anaconda3\envs\dcm2bids\Scripts\dcm2bids -d C:\Users\u1350546\Documents\Analysis_MRI_Data\E101\DCM\func\sess2 -p 101 -s s02 -c C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json -o C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS --auto_extract_entities --force
2024-09-10 09:34:06.714 - INFO     - dcm2bids.main | OS version: Windows-10-10.0.19042-SP0
2024-09-10 09:34:06.715 - INFO     - dcm2bids.main | Python version: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:04:44) [MSC v.1940 64 bit (AMD64)]
2024-09-10 09:34:06.717 - INFO     - dcm2bids.main | dcm2bids version: 3.2.0
2024-09-10 09:34:06.780 - INFO     - dcm2bids.main | dcm2niix version: v1.0.20240202
2024-09-10 09:34:06.780 - INFO     - dcm2bids.main | Checking for software update
2024-09-10 09:34:07.393 - INFO     - tools.check_latest | Currently using the latest version of dcm2bids.
2024-09-10 09:34:07.663 - INFO     - tools.check_latest | Currently using the latest version of dcm2niix.
2024-09-10 09:34:07.664 - INFO     - dcm2bids.main | participant: sub-101
2024-09-10 09:34:07.671 - INFO     - dcm2bids.main | session: ses-s02
2024-09-10 09:34:07.679 - INFO     - dcm2bids.main | config: C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json
2024-09-10 09:34:07.679 - INFO     - dcm2bids.main | BIDS directory: C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS
2024-09-10 09:34:07.680 - INFO     - dcm2bids.main | Auto extract entities: True
2024-09-10 09:34:07.680 - INFO     - dcm2bids.main | Reorder entities: True
2024-09-10 09:34:07.680 - INFO     - dcm2bids.main | Validate BIDS: False

2024-09-10 09:34:07.696 - INFO     - utils.run_shell_command | Running: dcm2niix -b y -ba y -z y -f %3s_%f_%p_%t -o C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02 C:\Users\u1350546\Documents\Analysis_MRI_Data\E101\DCM\func\sess2
2024-09-10 09:41:10.391 - DEBUG    - dcm2niix_gen.execute | 
Chris Rorden's dcm2niiX version v1.0.20240202  MSC1929  (64-bit Windows)

Found 2483 DICOM file(s)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 0..3825, TR=797 ms)

Convert 375 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\014_sess2_Mb5_55slice_RS2_20240719095640 (88x88x55x375)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 0..3825, TR=797 ms)

Convert 770 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\010_sess2_Mb5_55slice_MSL_2_20240719095640 (88x88x55x770)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 0..3825, TR=797 ms)

Convert 375 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\006_sess2_Mb5_55slice_RS1_20240719095640 (88x88x55x375)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 0..3825, TR=797 ms)

Convert 807 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\008_sess2_Mb5_55slice_MSL_1_20240719095640 (88x88x55x807)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 0..3825, TR=797 ms)

Convert 153 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\012_sess2_Mb5_55slice_MSL_TEST_20240719095640 (88x88x55x153)

Slices not stacked: echo varies (TE 5.19, 7.65; echo 1, 2). Use 'merge 2D slices' option to force stacking

Convert 1 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\004_sess2_gre_field_mapping_20240719095640_e1 (88x88x55x1)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 755..1492.5, TR=752 ms)

Convert 1 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\004_sess2_gre_field_mapping_20240719095640_e2 (88x88x55x1)

CSA slice timing based on 2nd volume, 1st volume corrupted (CMRR bug, range 755..1492.5, TR=752 ms)

Convert 1 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\sub-101_ses-s02\005_sess2_gre_field_mapping_20240719095640_e2_ph (88x88x55x1)

Conversion required 422.669006 seconds.


2024-09-10 09:41:10.391 - INFO     - dcm2niix_gen.execute | Check log file for dcm2niix output

2024-09-10 09:41:10.398 - INFO     - sidecar.build_acquisitions | SIDECAR PAIRING
2024-09-10 09:41:10.399 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_dir-AP_epi  <-  004_sess2_gre_field_mapping_20240719095640_e1
2024-09-10 09:41:10.400 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_dir-AP_epi  <-  004_sess2_gre_field_mapping_20240719095640_e2
2024-09-10 09:41:10.400 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_phasediff  <-  005_sess2_gre_field_mapping_20240719095640_e2_ph
2024-09-10 09:41:10.401 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_task-RS1_bold  <-  006_sess2_Mb5_55slice_RS1_20240719095640
2024-09-10 09:41:10.401 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_task-training1_bold  <-  008_sess2_Mb5_55slice_MSL_1_20240719095640
2024-09-10 09:41:10.402 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_task-training2_bold  <-  010_sess2_Mb5_55slice_MSL_2_20240719095640
2024-09-10 09:41:10.402 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_task-test_bold  <-  012_sess2_Mb5_55slice_MSL_TEST_20240719095640
2024-09-10 09:41:10.402 - INFO     - sidecar.build_acquisitions | sub-101_ses-s02_task-RS2_bold  <-  014_sess2_Mb5_55slice_RS2_20240719095640
2024-09-10 09:41:10.403 - INFO     - sidecar.find_runs | sub-101\ses-s02\fmap\sub-101_ses-s02_dir-AP_epi has 2 runs
2024-09-10 09:41:10.403 - INFO     - sidecar.find_runs | Adding run information to the acquisition
2024-09-10 09:41:10.404 - INFO     - dcm2bids_gen.run | Moving acquisitions into BIDS folder "C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\sub-101\ses-s02".

2024-09-10 09:41:10.432 - INFO     - dcm2bids.main | Logs saved in C:\Users\u1350546\Documents\Analysis_MRI_Data\OfflineBrain_BIDS\tmp_dcm2bids\log\sub-101_ses-s02_20240910-093406.log
2024-09-10 09:41:10.432 - INFO     - dcm2bids.main | --- dcm2bids end ---

Hi @ankevr97,

Please refer to the documentation (Create a config file - dcm2bids documentation). You misspelled the sidecar_changes field.

Best,
Steven

That is such a stupid mistake. Thank you so much, Steven!

1 Like

Getting stuck because of a typo: we’ve all been there! Welcome to the club! :stuck_out_tongue_winking_eye:

2 Likes