Convert dcm2bids config file to version >= 3.0.0

Dear experts,

I updated my dcm2bids versoin to:
dcm2bids version: 3.1.1
Based on BIDS version: v1.8.0

I want to converts this set if measurements (using the ND measurements):


├── 1-AAHead_Scout
├── 2-AAHead_Scout_MPR_sag
├── 3-AAHead_Scout_MPR_cor
├── 4-AAHead_Scout_MPR_tra
├── 5-T1wC_biobankTRR_1_KS_s_a_1_1_2_88_1010103D_2_2000_ND
├── 6-T1wC_biobankTRR_1_KS_s_a_1_1_2_88_1010103D_2_2000
├── 7-boldB_TRR_rest_SMS_1_1_KS_t_a_1_6_1_8_24242400_38_869
├── 8-fmapB_2p4mm_1_1_KS_t_a_2_1_1_8_24242400_5_698_ND
└── 9-fmapB_2p4mm_1_1_KS_t_a_2_1_1_8_24242400_5_698
├── 10-fmapB_2p4mm_1_1_KS_t_a_2_1_1_8_24242400_5_698_ND
├── 11-fmapB_2p4mm_1_1_KS_t_a_2_1_1_8_24242400_5_698
├── 12-boldB_TRR_SST_SMS_1_1_KS_t_a_1_6_1_8_24242400_38_869

For a former version of dcm2bids (<=3.0.0) I used the config file I will paste below.

So far I could not find a complete example for a config file when for the new version, in case there are phase and magnitude fieldmap files. Would you know where to find it?

Thank you so much!
Marco

Here is my config file which used to work for a dcm2bids version <=3.0.0:

{
  "descriptions": [
    {
      "dataType": "anat",
      "modalityLabel": "T1w",
      "criteria": {
        "SidecarFilename": "005*"
      }
    },
    {
      "dataType": "func",
      "modalityLabel": "bold",
      "customLabels": "task-rest_run-01",
      "criteria": {
        "SidecarFilename": "007*"
      },
      "sidecarChanges": {
        "TaskName": "rest"
      }
    },
    {
      "dataType": "fmap",
      "modalityLabel": "magnitude1",
      "IntendedFor": [
         1,
         4
      ],
      "criteria": {
        "SidecarFilename": "008*",
        "EchoTime": 0.00519
        }
    },
    {
      "dataType": "fmap",
      "modalityLabel": "phasediff",
      "IntendedFor": [
         1,
         4
      ],      
      "criteria": {
        "SidecarFilename": "010*"
      },
        "sidecarChanges": {
            "EchoTime1": 0.00519,
            "EchoTime2": 0.00765
            }
     },
     {
      "dataType": "func",
      "modalityLabel": "bold",
      "customLabels": "task-SST_run-01",
      "criteria": {
        "SidecarFilename": "012*",
        "ProtocolName": "boldB_TRR-SST*"
      },
      "sidecarChanges": {
        "TaskName": "SST"
      }
    }
  ]
}

Hi @marco5790,

You can use this example: Create a config file - dcm2bids documentation

and make the suffix to be magnitude1/2 or phasediff for the fmaps.

Best,
Steven

Dear Steven,

thank you for your quick reply!

I hope I did not miss it, but do you have by any chance the folder structure of the dicoms/niftis that the config file in your link is made for?

Thanks a bunch!
Marco

Hi @marco5790, just put all the dicoms you want to convert in one folder and pass that into the -d argument. That isn’t specific for the config file, that is how dcm2bids works for any dataset.

Best,
Steven

Hey Steven,

please excuse the delay - it took some time for me to get back to this issue.

When I run the helper I get these sequences (showing nii.gz files only here):


├── 005_02022_all_T1wC_biobankTRR_1_KS-s-a-1-1-2-88-1010103D-2-2000_20220809183753.nii.gz
├── 007_02022_all_boldB_TRR-rest-SMS_1-1_KS-t-a-1-6-1-8-24242400-38-869_20220809183753.nii.gz
├── 008_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e1.nii.gz
├── 008_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e2.nii.gz
├── 010_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e2_ph.nii.gz
└── 012_02022_all_boldB_TRR-SST-SMS_1-1_KS-t-a-1-6-1-8-24242400-38-869_20220809183753.nii.gz

(for proper ordering I added numbers to the front)

The config file looks like this now (based on the one on your link):

{
  "descriptions": [
    {
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "*T1*"
      },
      "sidecar_changes": {
        "ProtocolName": "T1"
      }
    },
    {
      "id": "task_rest",
      "datatype": "func",
      "suffix": "bold",
      "criteria": {
        "ProtocolName": "*boldB_TRR-rest*"
      }
    },
    {
      "id": "id_task_SST",
      "datatype": "func",
      "suffix": "bold",
      "criteria": {
        "ProtocolName": "*boldB_TRR-SST*",
        "SeriesDescription": "bold_task-SST"
      },
      "sidecar_changes": {
        "TaskName": "SST"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude1",
      "criteria": {
        "ProtocolName": "*fmapB*",        
        "SeriesDescription": "fmap_task-SST"
      },
      "sidecar_changes": {
        "TaskName": "SST",
        "IntendedFor": "task_rest",
        "IntendedFor": "task_SST"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude2",
      "criteria": {
        "ProtocolName": "*fmapB*",        
        "SeriesDescription": "fmap_task-SST"
      },
      "sidecar_changes": {
        "TaskName": "SST",
        "IntendedFor": "task_rest",
        "IntendedFor": "task_SST"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "phase",
      "criteria": {
        "ProtocolName": "*fmapB*",        
        "SeriesDescription": "fmap_task-SST"
      },
      "sidecar_changes": {
        "TaskName": "SST",
        "IntendedFor": "task_rest",
        "IntendedFor": "task_SST"
      }
    }
  ]
}

Which produces this output:

➜  output /home/marco/.local/bin/dcm2bids -d /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/10101/prisma/02022_all -p 001 -s 001 -c /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/mandatory_BIDS_files/dcm2bids_config_10101-prisma-12.json -o /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output
INFO    | --- dcm2bids start ---
INFO    | Running the following command: /home/marco/.local/bin/dcm2bids -d /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/10101/prisma/02022_all -p 001 -s 001 -c /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/mandatory_BIDS_files/dcm2bids_config_10101-prisma-12.json -o /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output
INFO    | OS version: Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
INFO    | Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
INFO    | dcm2bids version: 3.1.1
INFO    | dcm2niix version: v1.0.20240202
INFO    | Checking for software update
INFO    | Currently using the latest version of dcm2bids.
INFO    | Currently using the latest version of dcm2niix.
INFO    | participant: sub-001
INFO    | session: ses-001
INFO    | config: /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/mandatory_BIDS_files/dcm2bids_config_10101-prisma-12.json
INFO    | BIDS directory: /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output
INFO    | Auto extract entities: False
INFO    | Validate BIDS: False

INFO    | Running: dcm2niix -b y -ba y -z y -f %3s_%f_%p_%t -o /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output/tmp_dcm2bids/sub-001_ses-001 /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/10101/prisma/02022_all
INFO    | Check log file for dcm2niix output

INFO    | SIDECAR PAIRING
INFO    | sub-001_ses-001_T1w  <-  005_02022_all_T1wC_biobankTRR_1_KS-s-a-1-1-2-88-1010103D-2-2000_20220809183753
INFO    | sub-001_ses-001_bold  <-  007_02022_all_boldB_TRR-rest-SMS_1-1_KS-t-a-1-6-1-8-24242400-38-869_20220809183753
INFO    | No Pairing  <-  008_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e1
INFO    | No Pairing  <-  008_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e2
INFO    | No Pairing  <-  010_02022_all_fmapB_2p4mm_1-1_KS-t-a-2-1-1-8-24242400-5-698_20220809183753_e2_ph
INFO    | No Pairing  <-  012_02022_all_boldB_TRR-SST-SMS_1-1_KS-t-a-1-6-1-8-24242400-38-869_20220809183753
INFO    | Moving acquisitions into BIDS folder "/mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output/sub-001/ses-001".

INFO    | Logs saved in /mnt/c/Users/marco/HiDrive/KKB/QA/dcm2bids_mriqc_pipeline/output/tmp_dcm2bids/log/sub-001_ses-001_20240605-184922.log
INFO    | --- dcm2bids end ---

So it only recognizes the 007 bold measurement and the 005 T1, and misses the 012 bold measurement and the fieldmap (008, 012).

Do you have any clue how to fix the config file?

Thank you so much for your work and best wishes,
Marco

Hi @marco5790,

Without seeing jsons for your fieldmap mag/phase images I cannot tell you how to change your config file. But right now you are using the same criteria for all your mag/phase images:

      "criteria": {
        "ProtocolName": "*fmapB*",        
        "SeriesDescription": "fmap_task-SST"
      },

which shouldn’t be the case. Each image (mag1, mag2, phase) should have unique criteria.

Best,
Steven

Hi Steven,

I finally understood that I just use any unique combination of json entries under criteria :slight_smile:

Now it works.

Thank you!
Marco