Dcm2bids: how to include PA measurements and multiple T1 images?

Dear experts,

is it possible to include additional PA (posterior-to-anterior, just one volume) measurements and more than one T1 image in the BIDS standard?

I guess for two (or more) T1 images I just have two (or more) anat entries in the config file. But what to do about the PA measurement, since it is not a classic fieldmap (fmap) with two echoes.

Thank you!
Marco

Hi @marco5790,

You could, or if they are the same kind of acquisition with same config criteria, dcm2bids will automatically append the run-<> label. Otherwise, yes you will want separate config items with specific criteria and a custom entity (e.g., the acq-<>) label to differentiate them (assuming they are all T1 images and not already different file types).

Not all fieldmaps are two echos + phasediff. What you have is likely a reverse phase-encoded spin echo fieldmap, which would use the epi.nii.gz suffix. See case 4: Magnetic Resonance Imaging - Brain Imaging Data Structure v1.9.0

Best,
Steven

Hey Steven,

I think it is really the same sequence with only the phase endocing direction and number of volumes changed:

_ep2d_acq-fMRI_PA_20240725171157_7.nii, 2.4mb, 3 vols
_ep2d_acq-fMRI_AP_20240725171157_8.nii, 280.9mb, 350 vols

The json files contain this:

_ep2d_acq-fMRI_PA_20240725171157_7.json:

{
	"Modality": "MR",
	"MagneticFieldStrength": 3,
	"ImagingFrequency": 123.246624,
	"Manufacturer": "Siemens",
	"ManufacturersModelName": "Prisma",
	"InstitutionName": "Universitätsklinik Bo-Langendreer Prisma",
	"InstitutionalDepartmentName": "Department",
	"InstitutionAddress": "In der Schornau 23-25,Bochum,District,DE,44797",
	"DeviceSerialNumber": "66076",
	"StationName": "AWP66076",
	"BodyPartExamined": "BRAIN",
	"PatientPosition": "HFS",
	"ProcedureStepDescription": "Kopf^fMRT",
	"SoftwareVersions": "syngo MR E11",
	"MRAcquisitionType": "2D",
	"SeriesDescription": "ep2d_acq-fMRI_PA",
	"ProtocolName": "ep2d_acq-fMRI_PA",
	"ScanningSequence": "EP",
	"SequenceVariant": "SK",
	"ScanOptions": "FS",
	"SequenceName": "*epfid2d1_104",
	"ImageType": ["ORIGINAL", "PRIMARY", "PERFUSION", "NONE", "ND"],
	"NonlinearGradientCorrection": false,
	"SeriesNumber": 7,
	"AcquisitionTime": "18:42:36.292500",
	"AcquisitionNumber": 1,
	"SliceThickness": 2.7,
	"SpacingBetweenSlices": 3.105,
	"SAR": 0.1045,
	"EchoTime": 0.028,
	"RepetitionTime": 2.4,
	"FlipAngle": 90,
	"PartialFourier": 1,
	"BaseResolution": 104,
	"ShimSetting": [
		4481,
		3184,
		5668,
		70,
		0,
		-414,
		-77,
		148	],
	"TxRefAmp": 276.37,
	"PhaseResolution": 1,
	"ReceiveCoilName": "HeadNeck_64",
	"ReceiveCoilActiveElements": "HC1-7;NC1,2",
	"PulseSequenceDetails": "%SiemensSeq%\\ep2d_fid",
	"RefLinesPE": 24,
	"CoilCombinationMethod": "Sum of Squares",
	"ConsistencyInfo": "N4_VE11B_LATEST_20150530",
	"MatrixCoilMode": "GRAPPA",
	"PercentPhaseFOV": 100,
	"PercentSampling": 100,
	"EchoTrainLength": 51,
	"PhaseEncodingSteps": 103,
	"AcquisitionMatrixPE": 104,
	"ReconMatrixPE": 104,
	"BandwidthPerPixelPhaseEncode": 38.462,
	"ParallelReductionFactorInPlane": 2,
	"EffectiveEchoSpacing": 0.000249997,
	"DerivedVendorReportedEchoSpacing": 0.000499994,
	"TotalReadoutTime": 0.0257497,
	"PixelBandwidth": 2670,
	"DwellTime": 1.8e-06,
	"PhaseEncodingDirection": "j",
	"SliceTiming": [
		1.20312,
		0,
		1.26562,
		0.0625,
		1.32812,
		0.125,
		1.39062,
		0.1875,
		1.45312,
		0.25,
		1.51562,
		0.3125,
		1.57812,
		0.375,
		1.64062,
		0.4375,
		1.70312,
		0.5,
		1.76562,
		0.5625,
		1.82812,
		0.625,
		1.89062,
		0.6875,
		1.95312,
		0.75,
		2.01562,
		0.8125,
		2.07812,
		0.89062,
		2.14062,
		0.95312,
		2.20312,
		1.01562,
		2.26562,
		1.07812,
		2.34375,
		1.14062	],
	"ImageOrientationPatientDICOM": [
		0.993231,
		0.0799807,
		-0.0842285,
		-0.0767738,
		0.996219,
		0.0406542	],
	"ImageOrientationText": "Tra>Sag(-5.0)>Cor(1.9)",
	"InPlanePhaseEncodingDirectionDICOM": "COL",
	"BidsGuess": ["func","_acq-epfid2p2_dir-PA_run-7_bold"],
	"ConversionSoftware": "dcm2niix",
	"ConversionSoftwareVersion": "v1.0.20240202"
}

_ep2d_acq-fMRI_AP_20240725171157_8.json:

{
	"Modality": "MR",
	"MagneticFieldStrength": 3,
	"ImagingFrequency": 123.246623,
	"Manufacturer": "Siemens",
	"ManufacturersModelName": "Prisma",
	"InstitutionName": "Universitätsklinik Bo-Langendreer Prisma",
	"InstitutionalDepartmentName": "Department",
	"InstitutionAddress": "In der Schornau 23-25,Bochum,District,DE,44797",
	"DeviceSerialNumber": "66076",
	"StationName": "AWP66076",
	"BodyPartExamined": "BRAIN",
	"PatientPosition": "HFS",
	"ProcedureStepDescription": "Kopf^fMRT",
	"SoftwareVersions": "syngo MR E11",
	"MRAcquisitionType": "2D",
	"SeriesDescription": "ep2d_acq-fMRI_AP",
	"ProtocolName": "ep2d_acq-fMRI_AP",
	"ScanningSequence": "EP",
	"SequenceVariant": "SK",
	"ScanOptions": "FS",
	"SequenceName": "*epfid2d1_104",
	"ImageType": ["ORIGINAL", "PRIMARY", "PERFUSION", "NONE", "ND"],
	"NonlinearGradientCorrection": false,
	"SeriesNumber": 8,
	"AcquisitionTime": "18:43:22.417500",
	"AcquisitionNumber": 1,
	"SliceThickness": 2.7,
	"SpacingBetweenSlices": 3.105,
	"SAR": 0.115253,
	"EchoTime": 0.028,
	"RepetitionTime": 2.4,
	"FlipAngle": 90,
	"PartialFourier": 1,
	"BaseResolution": 104,
	"ShimSetting": [
		4479,
		3183,
		5682,
		127,
		-38,
		-452,
		-67,
		157	],
	"TxRefAmp": 276.37,
	"PhaseResolution": 1,
	"ReceiveCoilName": "HeadNeck_64",
	"ReceiveCoilActiveElements": "HC1-7;NC1,2",
	"PulseSequenceDetails": "%SiemensSeq%\\ep2d_fid",
	"RefLinesPE": 24,
	"CoilCombinationMethod": "Sum of Squares",
	"ConsistencyInfo": "N4_VE11B_LATEST_20150530",
	"MatrixCoilMode": "GRAPPA",
	"PercentPhaseFOV": 100,
	"PercentSampling": 100,
	"EchoTrainLength": 51,
	"PhaseEncodingSteps": 103,
	"AcquisitionMatrixPE": 104,
	"ReconMatrixPE": 104,
	"BandwidthPerPixelPhaseEncode": 38.462,
	"ParallelReductionFactorInPlane": 2,
	"EffectiveEchoSpacing": 0.000249997,
	"DerivedVendorReportedEchoSpacing": 0.000499994,
	"TotalReadoutTime": 0.0257497,
	"PixelBandwidth": 2670,
	"DwellTime": 1.8e-06,
	"PhaseEncodingDirection": "j-",
	"SliceTiming": [
		1.20312,
		0,
		1.26562,
		0.0625,
		1.32812,
		0.125,
		1.39062,
		0.1875,
		1.45312,
		0.25,
		1.51562,
		0.3125,
		1.57812,
		0.375,
		1.64062,
		0.4375,
		1.70312,
		0.5,
		1.76562,
		0.5625,
		1.82812,
		0.625,
		1.89062,
		0.6875,
		1.95312,
		0.75,
		2.01562,
		0.82812,
		2.07812,
		0.89062,
		2.14062,
		0.95312,
		2.20312,
		1.01562,
		2.28125,
		1.07812,
		2.34375,
		1.14062	],
	"ImageOrientationPatientDICOM": [
		0.993666,
		0.0745326,
		-0.084101,
		-0.0768073,
		0.996754,
		-0.0241401	],
	"ImageOrientationText": "Tra>Sag(-4.7)>Cor(-1.7)",
	"InPlanePhaseEncodingDirectionDICOM": "COL",
	"BidsGuess": ["func","_acq-epfid2p2_dir-AP_run-8_bold"],
	"ConversionSoftware": "dcm2niix",
	"ConversionSoftwareVersion": "v1.0.20240202"
}

Thank you!
Marco

Hi @marco5790,

If it is to be used as a reverse phase encoded fmap it should go in fmap folder following BIDS fmap conventions. Also both of those have the same phase encoding direction (J), so not sure why they are named as if they are different.

Best,
Steven

Hey Steven,

apparently I pasted the wrong json file for the AP file, sorry. The entry actually is ‘J-’, so it does make sense.

Which suffix do I chose for this reverse phase encoded fmap though?
I thought only magnitude1, magnitude2 and phasediff are allowed?

Thank you!
Marco

Hi @marco5790,

Please review the documentation I linked in my first answer. You can see that it uses the epi suffix.

Best,
Steven

Hey Steven,

now that I have fmriprep as a working BIDS validator again, I am back to this problem it seems.

fmriprep is not happy with how I integrated the PA measurements:

        1: [ERR] Files with such naming scheme are not part of BIDS specification. This error is most commonly caused by typos in file names that make them not BIDS compatible. Please consult the specification and make sure your files are named correctly. If this is not a file naming issue (for example when including files not yet covered by the BIDS specification) you should include a ".bidsignore" file in your dataset (see https://github.com/bids-standard/bids-validator#bidsignore for details). Please note that derived (processed) data should be placed in /derivatives folder and source data (such as DICOMS or behavioural logs in proprietary formats) should be placed in the /sourcedata folder. (code: 1 - NOT_INCLUDED)
                ./sub-001/ses-001/fmap/sub-001_ses-001_run-01_epi.json
                        Evidence: sub-001_ses-001_run-01_epi.json
                ./sub-001/ses-001/fmap/sub-001_ses-001_run-01_epi.nii.gz
                        Evidence: sub-001_ses-001_run-01_epi.nii.gz
                ./sub-001/ses-001/fmap/sub-001_ses-001_run-02_epi.json
                        Evidence: sub-001_ses-001_run-02_epi.json
                ./sub-001/ses-001/fmap/sub-001_ses-001_run-02_epi.nii.gz
                        Evidence: sub-001_ses-001_run-02_epi.nii.gz

Would you have any clue why?

Thank you!
Marco

Hi @marco5790,

Please review the BIDS specification: See case 4: Magnetic Resonance Imaging - Brain Imaging Data Structure v1.9.0

You can see that the epi suffix requires a dir-<> label.

Best,
Steven

Hi @Steven,

thank you!

I added “TotalReadoutTime” and “PhaseEncodingDirection” to “sidecar_changes”:

      "datatype": "fmap",
      "suffix": "epi",
      "criteria": {
        "ProtocolName": "ep2d_acq-fMRI_PA"
      },
      "sidecar_changes": {
        "TaskName": "acq",
        "IntendedFor": "ep2d_acq",
        "TotalReadoutTime": "0.0257497",
        "PhaseEncodingDirection": "j"
      }

But so far the same error persists.

And nothing is added to the nii.gz or json file names:

└── ses-001
    ├── anat
    │   ├── sub-001_ses-001_run-01_T1w.json
    │   ├── sub-001_ses-001_run-01_T1w.nii.gz
    │   ├── sub-001_ses-001_run-02_T1w.json
    │   └── sub-001_ses-001_run-02_T1w.nii.gz
    ├── fmap
    │   ├── sub-001_ses-001_run-01_epi.json
    │   ├── sub-001_ses-001_run-01_epi.nii.gz
    │   ├── sub-001_ses-001_run-02_epi.json
    │   └── sub-001_ses-001_run-02_epi.nii.gz
    └── func
        ├── sub-001_ses-001_task-acq_bold.json
        ├── sub-001_ses-001_task-acq_bold.nii.gz
        ├── sub-001_ses-001_task-ext_bold.json
        ├── sub-001_ses-001_task-ext_bold.nii.gz
        ├── sub-001_ses-001_task-rst_bold.json
        └── sub-001_ses-001_task-rst_bold.nii.gz

Thank you!
Marco

Hi @marco5790,

dir-<> is a “custom_entities” in the dcm2bids config file, which could also be guessed with the ---auto-extract-entities option. I would not add those sidecar changes which may overwrite what was already present in the dcm header.

Best,
Steven

Hi @Steven,

adding PhaseEncodingDirection to the config file as a custom entity

      "datatype": "fmap",
      "suffix": "epi",
      "custom_entities": {
        "PhaseEncodingDirection": "j"
      },         
      "criteria": {
        "ProtocolName": "ep2d_acq-fMRI_PA"
      },
      "sidecar_changes": {
        "TaskName": "acq",
        "IntendedFor": "ep2d_acq"
      }

for dcm2bids causes this error though

Traceback (most recent call last):
  File "/usr/local/bin/dcm2bids", line 8, in <module>
    sys.exit(main())
  File "/home/marco/.local/lib/python3.10/site-packages/dcm2bids/cli/dcm2bids.py", line 135, in main
    app = Dcm2BidsGen(**vars(args)).run()
  File "/home/marco/.local/lib/python3.10/site-packages/dcm2bids/dcm2bids_gen.py", line 117, in run
    parser.build_acquisitions(self.participant)
  File "/home/marco/.local/lib/python3.10/site-packages/dcm2bids/sidecar.py", line 420, in build_acquisitions
    desc, sidecar = self.searchDcmTagEntity(sidecar, desc)
  File "/home/marco/.local/lib/python3.10/site-packages/dcm2bids/sidecar.py", line 534, in searchDcmTagEntity
    descWithTask["custom_entities"].remove(curr_entity)
AttributeError: 'collections.OrderedDict' object has no attribute 'remove'

Thank you!
Marco

Hi @marco5790,

I am saying that the BIDS dir-<> label that goes in file names (eg dir-AP/PA) is a custom entity.

Best,
Steven

fmriprep runs through now - thank you so much @Steven !

The working version now is:

      "datatype": "fmap",
      "suffix": "epi",
      "custom_entities": "dir-PA",        
      "criteria": {
        "ProtocolName": "ep2d_ext-fMRI_PA"
      },
      "sidecar_changes": {
        "TaskName": "ext",
        "IntendedFor": "ep2d_ext"
      }

Best,
Marco

1 Like