[fmriprep & dcm2bids] fieldmap(SDC) and multiple runs(func)

Summary of what happened:

I have magnitude1, magnitude2, and phasediff fieldmaps. For the functional files, there are 2 runs of resting-state.
I am using dcm2bids and fMRIPrep, and running with the following config file does enable SDC in fMRIPrep.

However, I am curious if I have configured the config file correctly.

1. Did I correctly include “IntendedFor”, “B0FieldIdentifier”, and “B0FieldSource”?

Below is an excerpt from the current config file.

  • resting
    “id”: “id_task-rest”,
    “datatype”: “func”,
    “B0FieldSource”: [“phasediff_fmap0”, “mag1_fmap0”, “mag2_fmap0”]

  • fieldmap - magnitude1
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “mag1_fmap0”
    }

  • fieldmap - magnitude2
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “mag2_fmap0”
    }

  • fieldmap - phasediff
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “phasediff_fmap0”
    }

2. When there are multiple runs (2 runs) in resting-state fmri, do I need to specify each run in the config file? With the current config file (not specifying each run), multiple run files (01, 02) are automatically created in the BIDS format.

3. When running dcm2bids with the following config file, only run-01(in resting fmri) is specified in the “IntendedFor” field in the fmap folder’s JSON file. Can I make it automatically specify both runs (run-01 and run-02) using the dcm2bids config file?

e.g.

  • Curruent output: "IntendedFor": "bids::sub-037\\ses-1\\func\\sub-037_ses-1_task-rest_run-01_bold.nii"
  • Desired output: "IntendedFor": "bids::sub-037\\ses-1\\func\\sub-037_ses-1_task-rest_run-01_bold.nii", "bids::sub-037\\ses-1\\func\\sub-037_ses-1_task-rest_run-02_bold.nii"

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

fmriprep-docker D:/test2 D:/test2/derivatives participant --fs-license-file D:/freesurfer.txt

Version:

fMRIPrep v23.2.3
Dcm2bidsVersion: 3.1.1

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

dcm2bids(anaconda)
fmriprep-docker

Screenshots / relevant information:

current entire config file (for dcm2bids)

{
  "dcm2niixOptions": "-ba n",
  "descriptions": [
    {
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "t1*",
        "EchoTime": 0.00236,
        "RepetitionTime": 2.3
      },
      "sidecar_changes": {
        "ProtocolName": "T1"
      }
    },
    {
      "datatype": "anat",
      "suffix": "T2w",
      "criteria": {
        "SeriesDescription": "t2*",
        "EchoTime": 0.093,
        "RepetitionTime": 9
      },
      "sidecar_changes": {
        "ProtocolName": "T2"
      }
    },
    {
      "id": "id_task-rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "EchoTime": 0.03,
        "RepetitionTime": 2
      },
      "sidecar_changes": {
        "TaskName": "rest",
        "B0FieldSource": ["phasediff_fmap0", "mag1_fmap0", "mag2_fmap0"]
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude1",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00492
      },
      "sidecar_changes": {
        "IntendedFor": ["id_task-rest"],
        "B0FieldIdentifier": "mag1_fmap0"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude2",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
      },
      "sidecar_changes": {
        "IntendedFor": "id_task-rest",
        "B0FieldIdentifier": "mag2_fmap0"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "phasediff",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
      "sidecar_changes": {
        "IntendedFor": ["id_task-rest"],
        "B0FieldIdentifier": "phasediff_fmap0"
      }
    }
  ]
}

I have the following information:

  • When setting the “IntendedFor” using dcm2bids, it is inputted as a BIDS URL. This does not work with fMRIPrep.
  • For fieldmap correction (SDC), a pair of BOLD file and fieldmap file is used. In this case, instead of “IntendedFor” in the JSON file, “B0FieldIdentifier” and “B0FieldSource” are used. Currently, it is recommended to use both “IntendedFor” and “B0FieldIdentifier” according to BIDS documentation.

Hi @jj0012345,

Everything you set looks correct. I think it’s a bug in dcm2bids that the IntendedFor isn’t propagating above run-1 if multiple BOLD files fit a criteria.

That being said, when both B0FieldSource/Identified and IntendedFor are present, fmriprep will go with B0FieldSource, so as long as that is making the pairings you expect, you should be good to go.

Best,
Steven

Thank you for your quick reply!

These should all be “B0FieldIdentifier”: “fmap0”. By making them different, you are indicating that these files contribute to distinct B0Field estimates. You want to make them the same to indicate that these files are all needed to create one field estimate.

Thank you for your reply.
So can I do it like this? b0FieldSource also changed.

  • resting
    “id”: “id_task-rest”,
    “datatype”: “func”,
    “B0FieldSource”: “phasediff_fmap0”

  • fieldmap - magnitude1
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “phasediff_fmap0”
    }

  • fieldmap - magnitude2
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “phasediff_fmap0”
    }

  • fieldmap - phasediff
    “datatype”: “fmap”,
    “sidecar_changes”: {
    “IntendedFor”: “id_task-rest”,
    “B0FieldIdentifier”: “phasediff_fmap0”
    }

Or can I just make the magnitude the same?
(e.g.

  • func(b0fieldsource: fmap0, phasediff_fmap0)
  • magnitude1(b0fieldidentifer:fmap0)
  • magnitude2(b0fieldidentifer:fmap0)
  • phasediff(b0fieldidentifer: phasediff_fmap0)

)

Your first example, all phasediff_fmap0 should work.

Hi @jj0012345 ,

Quick question about dcm2bids: at the end did you have an issue with dcm2bids ?
Did you have, like @Steven said, an issue with dcm2bids no propagating above run-1 ?
I’m the main dev behind dcm2bids and want to make sure it does what it is suppose to do.

Thank you in advance
Arnaud

Hi @abore

As @Steven said, there was an issue with dcm2bids not propagating above run-1.
I didn’t solve this, so I gave up using Intendedfor and solved it with b0identifier.

Can you share your config file ? I’m curious about what you did that worked. Thank you in advance
Arnaud

It’s almost the same as what’s written in the post.
If you need anything else, please feel free to let me know.

{
  "dcm2niixOptions": "-ba n",
  "descriptions": [
    {
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "t1*",
        "EchoTime": 0.00236,
        "RepetitionTime": 2.3
      },
      "sidecar_changes": {
        "ProtocolName": "T1"
      }
    },
    {
      "datatype": "anat",
      "suffix": "T2w",
      "criteria": {
        "SeriesDescription": "t2*",
        "EchoTime": 0.093,
        "RepetitionTime": 9
      },
      "sidecar_changes": {
        "ProtocolName": "T2"
      }
    },
    {
      "id": "id_task-rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "EchoTime": 0.03,
        "RepetitionTime": 2
      },
      "sidecar_changes": {
        "TaskName": "rest"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude1",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00492
      },
      "sidecar_changes": {
        "IntendedFor": "id_task-rest"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude2",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
      },
      "sidecar_changes": {
        "IntendedFor": "id_task-rest"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "phasediff",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
      "sidecar_changes": {
        "IntendedFor": "id_task-rest"
      }
    }
  ]
}

I don’t understand you said you gave up using IntendedFor and used b0identifier but there is nothing about b0identifier in your config file and a lot of IntendedFor.

Sorry, I was mistaken for another file.
The “intendfor” was attached, but I worked on SDC with b0identifier.

{
  "dcm2niixOptions": "-ba n",
  "descriptions": [
    {
      "datatype": "anat",
      "suffix": "T1w",
      "criteria": {
        "SeriesDescription": "t1*",
        "EchoTime": 0.00236,
        "RepetitionTime": 2.3
      },
      "sidecar_changes": {
        "ProtocolName": "T1"
      }
    },
    {
      "datatype": "anat",
      "suffix": "FLAIR",
      "criteria": {
        "SeriesDescription": "t2*",
        "EchoTime": 0.093,
        "RepetitionTime": 9
      },
      "sidecar_changes": {
        "ProtocolName": "FLAIR"
      }
    },
    {
      "id": "id_task-rest",
      "datatype": "func",
      "suffix": "bold",
      "custom_entities": "task-rest",
      "criteria": {
        "EchoTime": 0.03,
        "RepetitionTime": 2
      },
      "sidecar_changes": {
        "TaskName": "rest",
        "B0FieldSource": ["phasediff_fmap0"]
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude1",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00492
      },
      "sidecar_changes": {
        "IntendedFor": ["id_task-rest"],
        "B0FieldIdentifier": "phasediff_fmap0"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "magnitude2",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND"]
      },
      "sidecar_changes": {
        "IntendedFor": "id_task-rest",
        "B0FieldIdentifier": "phasediff_fmap0"
      }
    },
    {
      "datatype": "fmap",
      "suffix": "phasediff",
      "criteria": {
        "ProtocolName": "field_map",
        "EchoTime": 0.00738,
        "ImageType": ["ORIGINAL", "PRIMARY", "P", "ND", "PHASE"]
      },
      "sidecar_changes": {
        "IntendedFor": ["id_task-rest"],
        "B0FieldIdentifier": "phasediff_fmap0"
      }
    }
  ]
}
  • There were three files in the fmap folder created in subject 50
sub-050_ses-1_magnitude1
sub-050_ses-1_magnitude2
sub-050_ses-1_phasediff
  • Below is part of the “phasediff” json file
    In “intendedfor”, only run-01 of the resting is written, but the actual restingfmri has two runs.
    So I would like to check if run-01 only SDC is applied or SDC is applied to both run.

"ImageOrientationText": "Tra",
"InPlanePhaseEncodingDirectionDICOM": "COL",
"BidsGuess": [
"fmap",
"_acq-fm2_phasediff"
],
"ConversionSoftware": "dcm2niix",
"ConversionSoftwareVersion": "v1.0.20240202",
"Dcm2bidsVersion": "3.1.1",
"IntendedFor": "bids::sub-y050\\ses-1\\func\\sub-y050_ses-1_task-rest_run-01_bold.nii",
"B0FieldIdentifier": "phasediff_fmap0"
}

I just validated and there were an issue with the dcm2bids 3.1.1 it has been fixed and will be available very soon. Thank you

1 Like