Correct use of custom_entities

Summary of what happened:

Trying to create a suitable .json file for conversion of DICOM data including a gradient echo fieldmap - which would then be put through fmriprep. I am unsure about the correct formatting of the custom_entities entries - and why my phasediff image is not being labelled correctly.

Any help would be much appreciated.

Kind regards,
Jon

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

$ dcm2bids -d sourcedata/DICOM/0F6380FB/ -p MRC204 -c convert_memag_v3.json --force_dcm2bids

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

Not there yet…

Relevant log outputs (up to 20 lines):

$ dcm2bids -d sourcedata/DICOM/0F6380FB/ -p MRC204 -c convert_memag_v3.json --force_dcm2bids^C
(dcm2bids) [gnx20mmu@uwwbichead01 ~/dcm2bids-proj/MEMAG/sub-MRC204]$ cd ..
(dcm2bids) [gnx20mmu@uwwbichead01 ~/dcm2bids-proj/MEMAG]$ dcm2bids -d sourcedata/DICOM/0F6380FB/ -p MRC204 -c convert_memag_v3.json --force_dcm2bids
INFO    | --- dcm2bids start ---
INFO    | Running the following command: /gpfs/data/uwwbic/gnx20mmu/.conda/envs/dcm2bids/bin/dcm2bids -d sourcedata/DICOM/0F6380FB/ -p MRC204 -c convert_memag_v3.json --force_dcm2bids
INFO    | OS version: Linux-3.10.0-1160.45.1.el7.x86_64-x86_64-with-glibc2.17
INFO    | Python version: 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 08:03:24) [GCC 12.3.0]
INFO    | dcm2bids version: 3.1.1
INFO    | dcm2niix version: v1.0.20230411
INFO    | Checking for software update
INFO    | Currently using the latest version of dcm2bids.
WARNING | A newer version exists for dcm2niix: v1.0.20240202
WARNING | You should update it -> https://github.com/rordenlab/dcm2niix.
INFO    | participant: sub-MRC204
INFO    | config: /gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/convert_memag_v3.json
INFO    | BIDS directory: /gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG
INFO    | Auto extract entities: False
INFO    | Validate BIDS: False

WARNING | Previous dcm2bids temporary directory output found:
WARNING | /gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/tmp_dcm2bids/sub-MRC204
WARNING | 'force' argument is set to True
WARNING | Cleaning the previous directory and running dcm2bids
INFO    | Running: dcm2niix -b y -ba y -z y -f %3s_%f_%p_%t -o /gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/tmp_dcm2bids/sub-MRC204 sourcedata/DICOM/0F6380FB
Error: 144 n_tags CSA Image Header corrupted (0029,1010) see issue 633.
Error: 144 n_tags CSA Image Header corrupted (0029,1010) see issue 633.
INFO    | Check log file for dcm2niix output

INFO    | SIDECAR PAIRING
INFO    | No Pairing  <-  006_0F6380FB_AAHead_Scout_20231207152646
INFO    | No Pairing  <-  007_0F6380FB_AAHead_Scout_20231207152646_i00001
INFO    | No Pairing  <-  007_0F6380FB_AAHead_Scout_20231207152646_i00002
INFO    | No Pairing  <-  007_0F6380FB_AAHead_Scout_20231207152646_i00003
INFO    | No Pairing  <-  007_0F6380FB_AAHead_Scout_20231207152646_i00004
INFO    | No Pairing  <-  008_0F6380FB_AAHead_Scout_20231207152646_i00001
INFO    | No Pairing  <-  008_0F6380FB_AAHead_Scout_20231207152646_i00002
INFO    | No Pairing  <-  008_0F6380FB_AAHead_Scout_20231207152646_i00003
INFO    | No Pairing  <-  009_0F6380FB_AAHead_Scout_20231207152646_i00001
INFO    | No Pairing  <-  009_0F6380FB_AAHead_Scout_20231207152646_i00002
INFO    | No Pairing  <-  009_0F6380FB_AAHead_Scout_20231207152646_i00003
INFO    | sub-MRC204_T1w  <-  010_0F6380FB_MPRAGE_GRAPPA2_20231207152646
INFO    | sub-MRC204_task-rest_bold  <-  011_0F6380FB_rest_cmrr_mbep2d_20231207152646
INFO    | sub-MRC204_task-recall_bold  <-  012_0F6380FB_task_cmrr_mbep2d_20231207152646
WARNING | Entity "['fmap']" is not a valid BIDS entity.
INFO    | sub-MRC204_fmap-magnitude1_fmap  <-  013_0F6380FB_gre_field_mapping_3mm_20231207152646_e1
WARNING | Entity "['fmap']" is not a valid BIDS entity.
INFO    | sub-MRC204_fmap-magnitude2_fmap  <-  013_0F6380FB_gre_field_mapping_3mm_20231207152646_e2
WARNING | Entity "['fmap']" is not a valid BIDS entity.
INFO    | sub-MRC204_fmap-magnitude2_fmap  <-  014_0F6380FB_gre_field_mapping_3mm_20231207152646_e2_ph
WARNING | Entity "['anat']" is not a valid BIDS entity.
INFO    | sub-MRC204_anat-HippoTE1_T2w  <-  015_0F6380FB_TSE_3TE_Cor_Hippo_20231207152646_e1
WARNING | Entity "['anat']" is not a valid BIDS entity.
INFO    | sub-MRC204_anat-HippoTE2_T2w  <-  015_0F6380FB_TSE_3TE_Cor_Hippo_20231207152646_e2
WARNING | Entity "['anat']" is not a valid BIDS entity.
INFO    | sub-MRC204_anat-HippoTE3_T2w  <-  015_0F6380FB_TSE_3TE_Cor_Hippo_20231207152646_e3
INFO    | sub-MRC204_dir-AP_dwi  <-  016_0F6380FB_cmrr_mbep2d_diff_60B07_AP_20231207152646
INFO    | No Pairing  <-  017_0F6380FB_cmrr_mbep2d_diff_60B07_AP_20231207152646
INFO    | No Pairing  <-  018_0F6380FB_cmrr_mbep2d_diff_60B07_AP_20231207152646
INFO    | No Pairing  <-  019_0F6380FB_cmrr_mbep2d_diff_60B07_AP_20231207152646
INFO    | No Pairing  <-  020_0F6380FB_cmrr_mbep2d_diff_60B07_AP_20231207152646
INFO    | sub-MRC204_dir-PA_dwi  <-  022_0F6380FB_cmrr_mbep2d_diff_60B07_PA_20231207152646
INFO    | No Pairing  <-  023_0F6380FB_cmrr_mbep2d_diff_60B07_PA_20231207152646
INFO    | No Pairing  <-  024_0F6380FB_cmrr_mbep2d_diff_60B07_PA_20231207152646
INFO    | No Pairing  <-  025_0F6380FB_cmrr_mbep2d_diff_60B07_PA_20231207152646
INFO    | No Pairing  <-  026_0F6380FB_cmrr_mbep2d_diff_60B07_PA_20231207152646
INFO    | sub-MRC204/fmap/sub-MRC204_fmap-magnitude2_fmap has 2 runs
INFO    | Adding run information to the acquisition
WARNING | Entity "['fmap']" is not a valid BIDS entity.
WARNING | âś… Filename was reordered according to BIDS entity table order:
                from:   sub-MRC204_fmap-magnitude2_run-01_fmap
                to:     sub-MRC204_run-01_fmap-magnitude2_fmap
WARNING | Entity "['fmap']" is not a valid BIDS entity.
WARNING | âś… Filename was reordered according to BIDS entity table order:
                from:   sub-MRC204_fmap-magnitude2_run-02_fmap
                to:     sub-MRC204_run-02_fmap-magnitude2_fmap
INFO    | Moving acquisitions into BIDS folder "/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204".

INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-rest_bold.nii.gz' already exists
INFO    | Use --clobber option to overwrite
INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-rest_bold.json' already exists
INFO    | Use --clobber option to overwrite
INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-recall_bold.nii.gz' already exists
INFO    | Use --clobber option to overwrite
INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-recall_bold.json' already exists
INFO    | Use --clobber option to overwrite
INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/anat/sub-MRC204_T1w.nii.gz' already exists
INFO    | Use --clobber option to overwrite
INFO    | '/gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/anat/sub-MRC204_T1w.json' already exists
INFO    | Use --clobber option to overwrite
INFO    | Logs saved in /gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/tmp_dcm2bids/log/sub-MRC204_20240301-120220.log
INFO    | --- dcm2bids end ---

Screenshots / relevant information:

.json file below:

{
  "descriptions": [
	{
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "MPRAGE GRAPPA2"
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "anat-HippoTE1",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.0095
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "anat-HippoTE2",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.076
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "anat-HippoTE3",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.143
      }
    },
	{
      "id": "task-rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "SeriesDescription": "rest_cmrr_mbep2d"
	  },
      "sidecar_changes": {
        "TaskName": "rest"
      }
    },
	{
      "id": "task-recall",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-recall",
      "criteria": {
        "SeriesDescription": "task_cmrr_mbep2d"
	  },
      "sidecar_changes": {
        "TaskName": "recall"
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "fmap",
      "custom_entities": "fmap-magnitude1",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "EchoNumber": "1",
		"EchoTime": 0.00492
      },
	  "sidecar_changes": {
        "TaskName": "magnitude1"
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "fmap",
      "custom_entities": "fmap-magnitude2",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "EchoNumber": "2",
		"EchoTime": 0.00738
      },
	  "sidecar_changes": {
        "TaskName": "magnitude2"
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "fmap",
      "custom_entities": "fmap-phasediff",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "ImageType": "*PHASE*"
      },
	  "sidecar_changes": {
        "TaskName": "phasediff",
		"EchoTime1": 0.00492,
        "EchoTime2": 0.00738
      }
    },
	{
      "datatype": "dwi",
      "suffix": "dwi",
      "custom_entities": "dir-AP",
      "criteria": {
        "SeriesDescription": "cmrr_mbep2d_diff_60B07_AP"
      }
    },
	{
      "datatype": "dwi",
      "suffix": "dwi",
      "custom_entities": "dir-PA",
      "criteria": {
        "SeriesDescription": "cmrr_mbep2d_diff_60B07_PA"
      }
    }
]
}


Hi @Jon_Brooks and welcome to neurostars!

All custom entities should be label-value pairs as defined by the BIDS specification: Magnetic Resonance Imaging - Brain Imaging Data Structure v1.9.0

That should be something like acq-HippoTE1 (same with your TE2/TE3)

Couple problems here (and with magnitude2).

As you can see here, magnitude1/2 is a file suffix. Additionally, you don’t need a TaskName for this file. If you have any other custom entities you want that are valid based on the BIDS specification, you can add them, but fmap-magnitude1/2 is not valid.

Try instead

{
      "datatype": "fmap",
	  "suffix": "magnitude1",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "EchoNumber": "1",
		"EchoTime": 0.00492
      }
}

Best,
Steven

HI Steven,

Thanks for the speedy reply, can I check the following with you?

{
      "datatype": "fmap",
	  "suffix": "phasediff",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "ImageType": "*PHASE*"
      },
	  "sidecar_changes": {
		"EchoTime1": 0.00492,
        "EchoTime2": 0.00738,
		"B0FieldIdentifier": "phasediff_fmap0"
      }
    },

From looking here, it seems like I might need to also populate relevant information about the echo spacing for the fMRI runs, for FUGUE to unwarp properly.

Thanks again,

Jon

Hi @Jon_Brooks,

Echo times and spacing should be automatically extracted from the dicoms. What scanner are these images from? If Siemens you’ll be fine.

Best,
Steven

Hi Steven,

Yes it’s Siemens, but the main problem I’m having is getting the phasediff image created properly.

On the scanner we save out magnitude and phase, and end up with three series, which dcm2niix names:
_e1
_e2
_e2_ph

looking at the output from dcm2bids I can see:

INFO    | sub-MRC204_magnitude2  <-  014_0F6380FB_gre_field_mapping_3mm_20231207152646_e2_ph

and

INFO    | sub-MRC204/fmap/sub-MRC204_magnitude2 has 2 runs

but no phasediff image is ever created. Here’s the contents of the fmap folder:

$ ls fmap
sub-MRC204_magnitude1.json    sub-MRC204_run-01_magnitude2.json    sub-MRC204_run-02_magnitude2.json
sub-MRC204_magnitude1.nii.gz  sub-MRC204_run-01_magnitude2.nii.gz  sub-MRC204_run-02_magnitude2.nii.gz

Any tips on where I’m going wrong?

Cheers, Jon

You must have used a too liberal criteria for your magnitude2 such that it is capturing your mag2 and phdiff file becuase they contain similar metadata. Be more explicit in your criteria, e.g., use the full (or bigger part of) the series description for example.

Best,
Steven

Hi @Jon_Brooks,

From your other post (Field mapping ( Siemens scanners)- dcm2niix output 2 BIDS - #18 by Chris_Rorden):

You can just set these ImageType explicitly in the dcm2bids criteria:

{
      "datatype": "fmap",
	  "suffix": "phasediff",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
	  "sidecar_changes": {
		"EchoTime1": 0.00492,
        "EchoTime2": 0.00738,
		"B0FieldIdentifier": "phasediff_fmap0"
      }
    },
}

I also wouldn’t recommend having dcm2bids change the echotimes for you on the phasediff file. That should be information automatically extracted from the dicom.

Best,
Steven

Hi @Steven

Thanks for getting back to me - and for connecting the two threads! From what I read in the earlier thread and what info is contained on the BIDS standard it expects the phasediff image to have both TEs in the sidecar, and the issue is that Siemens are not writing to the DICOM that is a derived image (and worse they (sort-of) label it as the 2nd echo).

Base on your suggestion I get the following warning:

WARNING | Several Pairing  <-  014_0F6380FB_gre_field_mapping_3mm_20231207152646_e2_ph
WARNING |     ->  _magnitude2
WARNING |     ->  _phasediff

Unfortunately no phasediff image is outputted.

Please let me know if you’d need more info to trouble shoot this or want me to do more digging.

Cheers, Jon

Hi @Jon_Brooks,

That’s because your mangitude2 criteria is defined too liberally and is also associated with the phase diff. Similar to what I did above for you in the phasediff file, you can more explicitly define your magnitude2 criteria.

True but this information will be in the dicom. It is better to get it from there than to hard code it.

This is just the standard siemens naming convention, unless I am misunderstanding your problem.

Best,
Steven

Okay - that was the sound of the penny finally dropping… and is a direct consequence of Siemens approach not helpfully including an echo time for a phasemap… which is really not appropriate in isolation. Two echo times, fine - but definitely not one…

For anyone interested, relevant info here

Happy to say that it’s now working - thanks for all your help with this!

The relevant section below - hope it helps someone.

{
      "datatype": "fmap",
	  "suffix": "magnitude1",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "EchoNumber": "1",
		"EchoTime": 0.00492
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "magnitude2",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "EchoNumber": "2",
		"EchoTime": 0.00738,
		"ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "phasediff",
	  "IntendedFor": ["task-rest",
		"task-recall"],
      "criteria": {
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
	  "sidecar_changes": {
		"EchoTime1": 0.00492,
        "EchoTime2": 0.00738,
		"B0FieldIdentifier": "phasediff_fmap0"
      }
    },

Cheers, Jon

1 Like

Hi,

Sorry to open an old wound… but I’m struggling with using dcm2bids to convert my gre_field_mapping data from a Siemens scanner. I don’t know if there’s something wonky in the way that dcm2niix is converting my data ( @Chris_Rorden ?)

Output from using dcm2bids_helper
Using dcm2bids version 3.1.1 and dcm2niix version v1.0.20230411

As expected I end up with
_e1.nii.gz
_e2.nii.gz
_e2_ph.nii.gz

Looking at the derived .json files I have the following differences:

$ diff 013_0F6380FB_gre_field_mapping_3mm_20231207152646_e1.json 013_0F6380FB_gre_field_mapping_3mm_20231207152646_e2.json
25c25
< 	"AcquisitionTime": "16:39:28.605000",
---
> 	"AcquisitionTime": "16:39:29.127500",
30,31c30,31
< 	"EchoNumber": 1,
< 	"EchoTime": 0.00492,
---
> 	"EchoNumber": 2,
> 	"EchoTime": 0.00738,
53d52
< 	"MultibandAccelerationFactor": 2,
65,66d63
< 		0,
< 		0.26562,
69,70c66,67
< 		0.03125,
< 		0.29688,
---
> 		0.01562,
> 		0.28125,
76c73
< 		0.32812,
---
> 		0.3125,
81c78
< 		0.09375,
---
> 		0.07812,
88,89c85,86
< 		0.39062,
< 		0.14062,
---
> 		0.375,
> 		0.125,
96c93
< 		0.4375,
---
> 		0.42188,
101c98
< 		0.20312,
---
> 		0.1875,
106a104,105
> 		0.21875,
> 		0.48438,
109,110c108,109
< 		0.23438,
< 		0.5,
---
> 		0.25,
> 		0.51562,

I have no idea why multiband is being “set” for echo 1 - it really isn’t set that way on the scanner host.

For the difference between one of the magnitude echo images and the derived phasemap we have:

$ diff 013_0F6380FB_gre_field_mapping_3mm_20231207152646_e1.json 014_0F6380FB_gre_field_mapping_3mm_20231207152646_e2_ph.json
22c22
< 	"ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"],
---
> 	"ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"],
24,25c24,25
< 	"SeriesNumber": 13,
< 	"AcquisitionTime": "16:39:28.605000",
---
> 	"SeriesNumber": 14,
> 	"AcquisitionTime": "16:39:29.127500",
30,31c30,31
< 	"EchoNumber": 1,
< 	"EchoTime": 0.00492,
---
> 	"EchoNumber": 2,
> 	"EchoTime": 0.00738,
33a34,35
> 	"EchoTime1": 0.00492,
> 	"EchoTime2": 0.00738,
53d54
< 	"MultibandAccelerationFactor": 2,
65,66d65
< 		0,
< 		0.26562,
69,70c68,69
< 		0.03125,
< 		0.29688,
---
> 		0.01562,
> 		0.28125,
76c75
< 		0.32812,
---
> 		0.3125,
81c80
< 		0.09375,
---
> 		0.07812,
88,89c87,88
< 		0.39062,
< 		0.14062,
---
> 		0.375,
> 		0.125,
96c95
< 		0.4375,
---
> 		0.42188,
101c100
< 		0.20312,
---
> 		0.1875,
106a106,107
> 		0.21875,
> 		0.48438,
109,110c110,111
< 		0.23438,
< 		0.5,
---
> 		0.25,
> 		0.51562,

So the only meaningful difference that I can see is in the “ImageType” section (keyword is “PHASE”). The problem is that I can’t get dcm2bids to use this information to hive off the phasediff image as it seems to be fixated that this is another echo-2 image… any advice on how to solve this would be much appreciated.

Cheers,

Jon

Hi All ( @Steven )

I’m still trying to get to grips with formatting my .json file for dcm2bids to make sense of some DICOM data. In particular, I’m struggling with applying fieldmaps to the relevant scans…

When I’m running fmriprep I’m getting the following warning:

None of the available B0 fieldmaps are associated to </gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-recall_bold.nii.gz>
240304-18:45:03,500 nipype.workflow IMPORTANT:
	 BOLD series will be slice-timing corrected to an offset of 0.931s.
240304-18:45:03,647 nipype.workflow INFO:
	 No single-band-reference found for sub-MRC204_task-rest_bold.nii.gz.
240304-18:45:03,647 nipype.workflow CRITICAL:
	 None of the available B0 fieldmaps are associated to </gpfs/data/uwwbic/gnx20mmu/dcm2bids-proj/MEMAG/sub-MRC204/func/sub-MRC204_task-rest_bold.nii.gz>

I’ve followed guidance from the dcm2bids config page, and it’s not immediately obvious what I’m doing wrong…?

Here’s the offending .json file used for conversion:

{
  "descriptions": [
	{
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "MPRAGE GRAPPA2"
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "acq-TE1",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.0095
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "acq-TE2",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.076
      }
    },
	{
      "datatype": "anat",
      "suffix": "T2w",
      "custom_entities": "acq-TE3",
      "criteria": {
        "SeriesDescription": "TSE_3TE_Cor_Hippo",
        "EchoTime": 0.143
      }
    },
	{
      "id": "task-rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "SeriesDescription": "rest_cmrr_mbep2d"
	  },
      "sidecar_changes": {
        "TaskName": "rest"
      }
    },
	{
      "id": "task-recall",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-recall",
      "criteria": {
        "SeriesDescription": "task_cmrr_mbep2d"
	  },
      "sidecar_changes": {
        "TaskName": "recall"
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "magnitude1",
	  "IntendedFor": [
		4,
		5
	  ],
      "criteria": {
        "EchoNumber": "1",
		"EchoTime": 0.00492
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "magnitude2",
	  "IntendedFor": [
		4,
		5
	  ],
      "criteria": {
        "EchoNumber": "2",
		"EchoTime": 0.00738,
		"ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
      }
    },
	{
      "datatype": "fmap",
	  "suffix": "phasediff",
	  "IntendedFor": [
		4,
		5
	  ],
      "criteria": {
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
	  "sidecar_changes": {
		"EchoTime1": 0.00492,
        "EchoTime2": 0.00738,
		"B0FieldIdentifier": "phasediff_fmap0"
      }
    },
	{
      "datatype": "dwi",
      "suffix": "dwi",
      "custom_entities": "dir-AP",
      "criteria": {
        "SeriesDescription": "cmrr_mbep2d_diff_60B07_AP"
      }
    },
	{
      "datatype": "dwi",
      "suffix": "dwi",
      "custom_entities": "dir-PA",
      "criteria": {
        "SeriesDescription": "cmrr_mbep2d_diff_60B07_PA"
      }
    }
]
}

Any help would be much appreciated.

Cheers, Jon

Hi @Jon_Brooks,

You probably have to remove the BIDS URI from your IntendedFor field. That is, if your field reads:

"IntendedFor": "bids::sub-xx/ses-xx/func/sub-xx_ses-xx_task-xx_bold.nii.gz"

you must change it to

"IntendedFor": "ses-xx/func/sub-xx_ses-xx_task-xx_bold.nii.gz"

Future releases of fMRIPrep (BOLD) and QSIPrep (DWI) will incorporate the BIDS URI which will make this change unnecessary, but for now you must alter it.

Best,
Steven

Hi @Steven,

Thanks again for looking at this. I was following the instructions from dcm2bids (and threads here) that indicated you could use an array for the “IntendedFor” section with relevant sequences (the task and rest fMRI) being addressed via zero indexed numbers. Will that not work?

Best wishes,
Jon

Hi @Steven,

Just to clarify - is this “IntendedFor” information supposed to be written to the bids sidecar automatically, or does it need to go in as a sidecar_change?

Sorry for being so clueless on this - I’m finding it all really baffling

Cheers, Jon

Hi @Jon_Brooks,

That decides which elements get added to the IntendedFor field in your fmap jsons.

This field is written into the fmap jsons which spells out which EPI file each fmap is associated with. dcm2bids will write the IntendedFor field into the fmap jsons based on what you put in your config file, but you will need to alter it in the way I described until the preprocessing software catches up.

Best,
Steven

Hi @Steven

Just a quick sanity check (my end) - from the information contained within my config file would you have expected an “IntendedFor” field to be present in the bids sidecar? Currently there is nothing like this appearing.

I noticed that in various edits of the documentation it seems like people have used either 0-indexed numbering for the IntendedFor section or the “id” e.g. “task-rest”, is there are preferred method and does the presence of the “id” field override the use of numbering for addressing (I have this in my config file).

Best wishes,
Jon

Hi @Jon_Brooks,

From the documentation (Create a config file - dcm2bids documentation) the IntendedFor part of the dcm2bids config file has to go under sidecar_changes.

Example config:

{
  "descriptions": [
    {
      "datatype": "anat",
      "suffix": "T2w",
      "criteria": {
        "SeriesDescription": "*T2*",
        "EchoTime": 0.1
      },
      "sidecar_changes": {
        "ProtocolName": "T2"
      }
    },
    {
      "id": "task_rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "ProtocolName": "func_task-*",
        "ImageType": ["ORIG*", "PRIMARY", "M", "MB", "ND", "MOSAIC"]
      }
    },
    {
      "datatype": "fmap",
      "suffix": "fmap",
      "criteria": {
        "ProtocolName": "*field_mapping*"
      },
      "sidecar_changes": {
        "IntendedFor": "task_rest"
      }
    },
    {
      "id": "id_task_learning",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-learning",
      "criteria": {
        "SeriesDescription": "bold_task-learning"
      },
      "sidecar_changes": {
        "TaskName": "learning"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "epi",
      "criteria": {
        "SeriesDescription": "fmap_task-learning"
      },
      "sidecar_changes": {
        "TaskName": "learning",
        "IntendedFor": "id_task_learning"
      }
    }
  ]
}

Best,
Steven

Ah - I was basing my config file from the information here: Create a config file - Dcm2Bids

Didn’t realise it was deprecated… will try now. Thanks again for all your help!

Jon

1 Like

Hi Jon,
Thanks for mentioning this, we removed the deprecated doc from the base URL as it shouldn’t have been there in the first place! From now on, people landing on Redirecting will be directed to the latest version.

I hope your conversion went well :slight_smile: