Running fMRIPrep with topup/SDC on HCP-EP

Summary of what happened:

Hi everyone,

I’m trying to run fMRIPrep (v23.2.1 in singularity) with the unprocessed HCP-EP dataset, but I have problems with the topup/SDC workflow.
I reorganized my raw data folder in BIDS by keeping only the T1 and bold files.
Here is an example of the raw data folder :

   raw
    └── 1001_01_MR
        └── unprocessed
            ├── T1w_MPR
            │   ├── 1001_01_MR_T1w_MPR.json
            │   ├── 1001_01_MR_T1w_MPR.nii.gz
            │   └── OTHER_FILES
            │       ├── 1001_01_MR_BIAS_32CH.json
            │       ├── 1001_01_MR_BIAS_32CH.nii.gz
            │       ├── 1001_01_MR_BIAS_BC.json
            │       ├── 1001_01_MR_BIAS_BC.nii.gz
            │       ├── 1001_01_MR_SpinEchoFieldMap1_AP.json
            │       ├── 1001_01_MR_SpinEchoFieldMap1_AP.nii.gz
            │       ├── 1001_01_MR_SpinEchoFieldMap1_PA.json
            │       ├── 1001_01_MR_SpinEchoFieldMap1_PA.nii.gz
            │       ├── 1001_01_MR_T1w_MPR_Norm.json
            │       ├── 1001_01_MR_T1w_MPR_Norm.nii.gz
            │       └── session_report.csv
            ├── rfMRI_REST1_AP
            │   ├── 1001_01_MR_SpinEchoFieldMap1_AP.json
            │   ├── 1001_01_MR_SpinEchoFieldMap1_AP.nii.gz
            │   ├── 1001_01_MR_SpinEchoFieldMap1_PA.json
            │   ├── 1001_01_MR_SpinEchoFieldMap1_PA.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST1_AP.json
            │   ├── 1001_01_MR_rfMRI_REST1_AP.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST1_AP_InitialFrames.nii.gz
            │   └── OTHER_FILES
            │       ├── 1001_01_MR_BIAS_32CH.json
            │       ├── 1001_01_MR_BIAS_32CH.nii.gz
            │       ├── 1001_01_MR_BIAS_BC.json
            │       └── 1001_01_MR_BIAS_BC.nii.gz
            ├── rfMRI_REST1_PA
            │   ├── 1001_01_MR_SpinEchoFieldMap1_AP.json
            │   ├── 1001_01_MR_SpinEchoFieldMap1_AP.nii.gz
            │   ├── 1001_01_MR_SpinEchoFieldMap1_PA.json
            │   ├── 1001_01_MR_SpinEchoFieldMap1_PA.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST1_PA.json
            │   ├── 1001_01_MR_rfMRI_REST1_PA.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST1_PA_InitialFrames.nii.gz
            │   └── OTHER_FILES
            │       ├── 1001_01_MR_BIAS_32CH.json
            │       ├── 1001_01_MR_BIAS_32CH.nii.gz
            │       ├── 1001_01_MR_BIAS_BC.json
            │       └── 1001_01_MR_BIAS_BC.nii.gz
            ├── rfMRI_REST2_AP
            │   ├── 1001_01_MR_SpinEchoFieldMap2_AP.json
            │   ├── 1001_01_MR_SpinEchoFieldMap2_AP.nii.gz
            │   ├── 1001_01_MR_SpinEchoFieldMap2_PA.json
            │   ├── 1001_01_MR_SpinEchoFieldMap2_PA.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST2_AP.json
            │   ├── 1001_01_MR_rfMRI_REST2_AP.nii.gz
            │   ├── 1001_01_MR_rfMRI_REST2_AP_InitialFrames.nii.gz
            │   └── OTHER_FILES
            │       ├── 1001_01_MR_BIAS_32CH.json
            │       ├── 1001_01_MR_BIAS_32CH.nii.gz
            │       ├── 1001_01_MR_BIAS_BC.json
            │       └── 1001_01_MR_BIAS_BC.nii.gz
            └── rfMRI_REST2_PA
                ├── 1001_01_MR_SpinEchoFieldMap2_AP.json
                ├── 1001_01_MR_SpinEchoFieldMap2_AP.nii.gz
                ├── 1001_01_MR_SpinEchoFieldMap2_PA.json
                ├── 1001_01_MR_SpinEchoFieldMap2_PA.nii.gz
                ├── 1001_01_MR_rfMRI_REST2_PA.json
                ├── 1001_01_MR_rfMRI_REST2_PA.nii.gz
                ├── 1001_01_MR_rfMRI_REST2_PA_InitialFrames.nii.gz
                └── OTHER_FILES
                    ├── 1001_01_MR_BIAS_32CH.json
                    ├── 1001_01_MR_BIAS_32CH.nii.gz
                    ├── 1001_01_MR_BIAS_BC.json
                    └── 1001_01_MR_BIAS_BC.nii.gz

I tried running fMRIPrep, which works, but no SDC is applied. As mentioned in Needing further clarification on incorporating PEPOLAR susceptibility to fMRI data in fMRIprep, I tried to add the “IntendedFor” field in the json files for PA direction pointing towards AP files (‘IntendedFor : sub-1001_ses-1_task-rest_dir-ap_run-1_bold.nii.gz’ in sub-1001_ses-1_task-rest_dir-pa_run-1_bold.json). However, still no SDC is applied.
The problem may be the BIDS organization, as I removed many files (e.g., field maps). I don’t know how to organize these files in BIDS, so I tried different converters as mentioned in Unprocessed HCP data in BIDS format for fMRIPrep? - #4 by Steven : GitHub - suyashdb/hcp2bids: To convert Human Connectome projects(HCP) data to BIDS std, Start to finish with `micapipe` — micapipe documentation and github/benoitberanger/niix2bids but none of them work on my raw data folder.

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

singularity run --cleanenv \
-B "${path}BIDS/${site}/:/input" \
-B "${path}derivatives/${site}/fmriprep:/output" \
-B "${FREESURFER}:/freesurfer" \
${FMRIPREP} \
"/input" \
"/output" \
participant \
--participant-label $sub \
--output-spaces MNI152NLin6Asym:res-2 \
--stop-on-first-crash \
--fs-license-file "/freesurfer/license.txt" \
-w "/output/work_dir_${sub}" \
--force-bbr \
--cifti-output 91k -v -v ;

Version:

23.2.1

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

Singularity

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

Here are the files that I kept

sub-1001
└── ses-1
    ├── anat
    │   ├── sub-1001_ses-1_T1w.json
    │   └── sub-1001_ses-1_T1w.nii.gz
    └── func
        ├── sub-1001_ses-1_task-rest_dir-ap_run-1_bold.json
        ├── sub-1001_ses-1_task-rest_dir-ap_run-1_bold.nii.gz
        ├── sub-1001_ses-1_task-rest_dir-ap_run-2_bold.json
        ├── sub-1001_ses-1_task-rest_dir-ap_run-2_bold.nii.gz
        ├── sub-1001_ses-1_task-rest_dir-pa_run-1_bold.json
        ├── sub-1001_ses-1_task-rest_dir-pa_run-1_bold.nii.gz
        ├── sub-1001_ses-1_task-rest_dir-pa_run-2_bold.json
        └── sub-1001_ses-1_task-rest_dir-pa_run-2_bold.nii.gz

BIDS validator output :

bids-validator@1.14.1
	1: [WARN] The recommended file /README is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 101 - README_FILE_MISSING)

	Please visit https://neurostars.org/search?q=README_FILE_MISSING for existing conversations about this issue.

	2: [WARN] The Authors field of dataset_description.json should contain an array of fields - with one author per field. This was triggered because there are no authors, which will make DOI registration from dataset metadata impossible. (code: 113 - NO_AUTHORS)

	Please visit https://neurostars.org/search?q=NO_AUTHORS for existing conversations about this issue.

        Summary:                  Available Tasks:        Available Modalities: 
        257 Files, 47.97GB                                MRI                   
        26 - Subjects                                                           
        1 - Session              

Relevant log outputs (up to 20 lines):

PASTE LOG OUTPUT HERE

Screenshots / relevant information:


I also tried to run topup myself, which gives me two corrected files per subject (run 1 AP-PA corrected and run 2 AP-PA corrected), but I don’t have a json corresponding to these corrected files.
Here are the json files for run 1 dir AP :


{
  "Modality": "MR",
  "MagneticFieldStrength": 3,
  "Manufacturer": "Siemens",
  "ManufacturersModelName": "Prisma",
  "InstitutionName": "INDIANA_UNIVERSITY",
  "InstitutionAddress": "West_16th_355_INDIANAPOLIS_INDIANA_US_46202",
  "DeviceSerialNumber": "66027",
  "StationName": "AWP66027",
  "BodyPartExamined": "BRAIN",
  "PatientPosition": "HFS",
  "SoftwareVersions": "syngo_MR_D13D",
  "MRAcquisitionType": "2D",
  "SeriesDescription": "rfMRI_REST_AP",
  "ProtocolName": "rfMRI_REST_AP",
  "ScanningSequence": "EP",
  "SequenceVariant": "SK_SS",
  "ScanOptions": "FS",
  "SequenceName": "epfid2d1_104",
  "ImageType": [
    "ORIGINAL",
    "PRIMARY",
    "M",
    "MB",
    "ND",
    "MOSAIC"
  ],
  "SeriesNumber": 12,
  "AcquisitionTime": "14:13:24.520000",
  "AcquisitionNumber": 1,
  "ImageComments": "Unaliased_MB8_PE3_LB",
  "SliceThickness": 2,
  "SpacingBetweenSlices": 2,
  "SAR": 0.0563992,
  "EchoTime": 0.037,
  "RepetitionTime": 0.8,
  "FlipAngle": 52,
  "PartialFourier": 1,
  "BaseResolution": 104,
  "ShimSetting": [
    2053,
    -9166,
    420,
    362,
    -42,
    -98,
    -25,
    3
  ],
  "TxRefAmp": 281.896,
  "PhaseResolution": 1,
  "ReceiveCoilName": "Head_32",
  "ReceiveCoilActiveElements": "HEA;HEP",
  "PulseSequenceDetails": "%CustomerSeq%_cmrr_mbep2d_bold; vd13d/master r/6e18ef0; Jul 20 2016 16:59:50 by eja",
  "ConsistencyInfo": "N4_VD13D_LATEST_20130810",
  "MultibandAccelerationFactor": 8,
  "PercentPhaseFOV": 100,
  "EchoTrainLength": 104,
  "PhaseEncodingSteps": 104,
  "AcquisitionMatrixPE": 104,
  "ReconMatrixPE": 104,
  "BandwidthPerPixelPhaseEncode": 16.578,
  "EffectiveEchoSpacing": 0.000580009,
  "DerivedVendorReportedEchoSpacing": 0.000580009,
  "TotalReadoutTime": 0.0597409,
  "PixelBandwidth": 2290,
  "DwellTime": 2.1e-06,
  "PhaseEncodingDirection": "j-",
  "SliceTiming": [
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.52,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345
  ],
  "ImageOrientationPatientDICOM": [
    0.999042,
    0.0386529,
    0.0205118,
    -0.0242051,
    0.878658,
    -0.476838
  ],
  "InPlanePhaseEncodingDirectionDICOM": "COL",
  "ConversionSoftware": "dcm2niix",
  "ConversionSoftwareVersion": "v1.0.20171017 GCC4.4.7"
}

and dir PA :

{
  "Modality": "MR",
  "MagneticFieldStrength": 3,
  "Manufacturer": "Siemens",
  "ManufacturersModelName": "Prisma",
  "InstitutionName": "INDIANA_UNIVERSITY",
  "InstitutionAddress": "West_16th_355_INDIANAPOLIS_INDIANA_US_46202",
  "DeviceSerialNumber": "66027",
  "StationName": "AWP66027",
  "BodyPartExamined": "BRAIN",
  "PatientPosition": "HFS",
  "SoftwareVersions": "syngo_MR_D13D",
  "MRAcquisitionType": "2D",
  "SeriesDescription": "rfMRI_REST_PA",
  "ProtocolName": "rfMRI_REST_PA",
  "ScanningSequence": "EP",
  "SequenceVariant": "SK_SS",
  "ScanOptions": "FS",
  "SequenceName": "epfid2d1_104",
  "ImageType": [
    "ORIGINAL",
    "PRIMARY",
    "M",
    "MB",
    "ND",
    "MOSAIC"
  ],
  "SeriesNumber": 14,
  "AcquisitionTime": "14:20:18.922500",
  "AcquisitionNumber": 1,
  "ImageComments": "Unaliased_MB8_PE3_LB",
  "SliceThickness": 2,
  "SpacingBetweenSlices": 2,
  "SAR": 0.0563992,
  "EchoTime": 0.037,
  "RepetitionTime": 0.8,
  "FlipAngle": 52,
  "PartialFourier": 1,
  "BaseResolution": 104,
  "ShimSetting": [
    2053,
    -9166,
    420,
    362,
    -42,
    -98,
    -25,
    3
  ],
  "TxRefAmp": 281.896,
  "PhaseResolution": 1,
  "ReceiveCoilName": "Head_32",
  "ReceiveCoilActiveElements": "HEA;HEP",
  "PulseSequenceDetails": "%CustomerSeq%_cmrr_mbep2d_bold; vd13d/master r/6e18ef0; Jul 20 2016 16:59:50 by eja",
  "ConsistencyInfo": "N4_VD13D_LATEST_20130810",
  "MultibandAccelerationFactor": 8,
  "PercentPhaseFOV": 100,
  "EchoTrainLength": 104,
  "PhaseEncodingSteps": 104,
  "AcquisitionMatrixPE": 104,
  "ReconMatrixPE": 104,
  "BandwidthPerPixelPhaseEncode": 16.578,
  "EffectiveEchoSpacing": 0.000580009,
  "DerivedVendorReportedEchoSpacing": 0.000580009,
  "TotalReadoutTime": 0.0597409,
  "PixelBandwidth": 2290,
  "DwellTime": 2.1e-06,
  "PhaseEncodingDirection": "j",
  "SliceTiming": [
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345,
    0,
    0.4325,
    0.085,
    0.5175,
    0.1725,
    0.605,
    0.26,
    0.6925,
    0.345
  ],
  "ImageOrientationPatientDICOM": [
    0.999042,
    0.0386529,
    0.0205118,
    -0.0242051,
    0.878658,
    -0.476838
  ],
  "InPlanePhaseEncodingDirectionDICOM": "COL",
  "ConversionSoftware": "dcm2niix",
  "ConversionSoftwareVersion": "v1.0.20171017 GCC4.4.7"
}

I have two questions :

  • How do I convert my raw data to BIDS to run fMRIPrep and have all the files needed for SDC/top-up?
  • If I can’t run topup/SDC within fMRIPrep, can I write a json for the topup corrected files by mixing information from the AP and PA json files to directly run fMRIPrep on my topup corrected files ? If yes, what must I keep, remove, or modify ?

Thank you so much for your help,
Best,
Katia

Hi @kchardon and welcome to neurostars!

In the future please use the Software Support post template. You can see I edited it in for you this time.

You need fmaps for SDC. You have those already, they are your spin echo PA/AP pairs.

You can find several examples here: GitHub - bids-standard/bids-examples: A set of BIDS compatible datasets with empty raw data files that can be used for writing lightweight software tests.
For example: bids-examples/ieeg_visual_multimodal/sub-som682/ses-nyu3t01 at master · bids-standard/bids-examples · GitHub

You can read the full specification here: Magnetic Resonance Imaging - Brain Imaging Data Structure 1.10.0

In your case that has reverse phase encoded spin echo pairs, see Case 4 in the above link.

IntendedFor goes in fmap, not bold, jsons.

We recommend using the latest version.

Just adding fmaps should do the trick.

fmriprep expects raw data, so I don’t think this would be a good plan.

Best,
Steven