fMRIprep EPI and Tw1 coregistration issues

Summary of what happened:

I am psychiatrist who is running fMRI analysis for the first time. Many thanks to the group and fMRIprep contributors, it is fantastic and relatively straight forward!
I am using fMRIprep v 23.2.1 to process some resting-state BOLD data on one participant. I have also entered their T1w structural into the pipeline. For distortion correction, I have uploaded corresponding magnitude and phase images at two seperate echo times.
The pipeline is completing but I encounter two issues:

  1. The BOLD and T1w coregestration appears to be poor, especially around the orbitofrontal cortex and temporal lobe.
  2. I am unsure if the distortion correction is making optimal corrections.

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

/opt/conda/envs/fmriprep/bin/fmriprep /data/project/CARDS/BIDS/nifti/ /data/project/CARDS/BIDS/output participant --work-dir /data/project/CARDS/BIDS/workdir --participant-label 031 --fs-license-file /data/project/CARDS/BIDS/scripts/fslicense.txt -vv --omp-nthreads 8 --nthreads 12 --mem_mb 30000 --skip-bids-validation

Version:

fMRIprep v 23.2.1

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

I am running this on my University Neuroimaging network.

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

The data for this participant passes the BIDS validator step

Relevant log outputs (up to 20 lines):

N/A

Screenshots / relevant information:

HTML saved here:


1 Like

Hi @Luke_Vano and welcome to neurostars!

I don’t believe you are able to attach HTMLs here, at least I don’t see anything. Try posting screenshots?

Best,
Steven

1 Like

Thanks Steven! I have saved to a .pdf and shared via google drive. Please let me know if any issues.

Best wishes,
Luke

1 Like

Thanks! But unfortunately, the PDF version makes it hard to compare distorted vs corrected, since it’s usually displayed as a GIF and thus wouldn’t be captured by a single screenshot.

1 Like

Apologies, I can only upload one image per post so will try and put up the important ones.

Preprocessed mapping of phase-difference acquisition

Alignment between the anatomical reference of the fieldmap and the target EPI

Alignment between the anatomical reference of the fieldmap and the target EPI

Susceptibility distortion correction

Alignment of functional and anatomical MRI data (coregistration)

I will stop uploading now but please let me know if any more images are needed. Thanks so much!

I would like to check that I have uploaded the data in the correct format, as there are a few steps that are unclear to me and the resulting corrected BOLD images appear suboptimal.
My main questions are:

  1. Have I used constructed the .json files correctly?
  2. Is the phase data in the correct units?

I get the following lines of code which I believe means that fMRIprep is correctly identifying my mag and phase images and will use them to generate the B0 field map:

240725-13:47:00,986 nipype.workflow INFO:
	 B0 field inhomogeneity map will be estimated with the following 1 estimator(s): [<EstimatorType.PHASEDIFF: 3>].
240725-13:47:01,42 nipype.workflow INFO:
	 Setting-up fieldmap "fmap0" (EstimatorType.PHASEDIFF) with <sub-031_magnitude1.nii.gz, sub-031_magnitude2.nii.gz, sub-031_phase1.nii.gz, sub-031_phase2.nii.gz>

Below shows the contents of the .json files. Do they look correct?

sub-031_magnitude1.json:

{
        "EchoTime": 0.00584,
        "IntendedFor": [
                "func/sub-031_task-rest_run-1_bold.nii"
        ],
        "B0FieldIdentifier": "fmap0"
}

sub-031_magnitude2.json:

{
        "EchoTime": 0.01063,
        "IntendedFor": [
                "func/sub-031_task-rest_run-1_bold.nii"
        ],
        "B0FieldIdentifier": "fmap0"
}

sub-031_phase1.json:

{
        "EchoTime": 0.00584,
        "IntendedFor": [
                "func/sub-031_task-rest_run-1_bold.nii"
        ],
        "B0FieldIdentifier": "fmap0"
}

sub-031_phase2.json:

{
        "EchoTime": 0.01063,
        "IntendedFor": [
                "func/sub-031_task-rest_run-1_bold.nii"
        ],
        "B0FieldIdentifier": "fmap0"
}

These phase maps are wrapped between 0 and 2 pi. The image below shows the data for _phase1.nii.gz. Is this correct?

Hi @Luke_Vano,

What about the B0FieldSource item in the func json? You would need to set it to fmap0 if you want that run to be linked to the B0 map identified by fmap0.

Best,
Steven

1 Like

Hi @Steven
Thanks. I didn’t have this item specified in the func json but have added it. This hasn’t changed the resulting map. I have copied the full json below. I have attached the T1w image and BOLD image in MNI space and their respective masks to illustrate the failed normalization of the BOLD image, either due to error with distortion correction or coregistration with the T1w, as the T1w normalization is perfect.
Thanks, Luke

sub-031_task-rest_run-1_bold.json

{
        "Modality": "MR",
        "MagneticFieldStrength": 3,
        "ImagingFrequency": 123.256375,
        "Manufacturer": "Siemens",
        "InstitutionalDepartmentName": "Department",
        "InstitutionAddress": "Du Cane Road StreetNo,London,District,GB,W12 0HS",
        "DeviceSerialNumber": "166001",
        "BodyPartExamined": "HEAD",
        "PatientPosition": "HFS",
        "ProcedureStepDescription": "MRI Head",
        "SoftwareVersions": "syngo MR E11",
        "MRAcquisitionType": "2D",
        "SeriesDescription": "BOLD - Resting State",
        "ProtocolName": "BOLD - Resting State",
        "ScanningSequence": "EP",
        "SequenceVariant": "SK",
        "ScanOptions": "FS",
        "SequenceName": "*epfid2d1_64",
        "ImageType": [
                "ORIGINAL",
                "PRIMARY",
                "M",
                "ND",
                "NORM",
                "MOSAIC"
        ],
        "NonlinearGradientCorrection": false,
        "SeriesNumber": 41,
        "AcquisitionTime": "12:46:14.277500",
        "AcquisitionNumber": 1,
        "SliceThickness": 3,
        "SpacingBetweenSlices": 3,
        "SAR": 0.10801,
        "EchoTime": 0.03,
        "RepetitionTime": 2.5,
        "FlipAngle": 90,
        "PartialFourier": 1,
        "BaseResolution": 64,
        "ShimSetting": [
                8824,
                -8129,
                -129,
                302,
                -16,
                -154,
                197,
                7
        ],
        "TxRefAmp": 279.714,
        "PhaseResolution": 1,
        "VendorReportedEchoSpacing": 0.00071,
        "ReceiveCoilName": "HeadNeck_64",
        "ReceiveCoilActiveElements": "HC3-6",
        "PulseSequenceDetails": "%SiemensSeq%\\ep2d_pace",
        "RefLinesPE": 24,
        "CoilCombinationMethod": "Sum of Squares",
        "ConsistencyInfo": "N4_VE11C_LATEST_20160120",
        "MatrixCoilMode": "GRAPPA",
        "PercentPhaseFOV": 100,
        "PercentSampling": 100,
        "EchoTrainLength": 31,
        "PhaseEncodingSteps": 63,
        "AcquisitionMatrixPE": 64,
        "ReconMatrixPE": 64,
        "BandwidthPerPixelPhaseEncode": 44.014,
        "ParallelReductionFactorInPlane": 2,
        "EffectiveEchoSpacing": 0.000355001,
        "DerivedVendorReportedEchoSpacing": 0.000710001,
        "TotalReadoutTime": 0.022365,
        "PixelBandwidth": 1595,
        "DwellTime": 4.9e-06,
        "PhaseEncodingDirection": "j-",
        "SliceTiming": [
                0,
                0.06,
                0.1175,
                0.1775,
                0.2375,
                0.295,
                0.355,
                0.4125,
                0.4725,
                0.5325,
                0.59,
                0.65,
                0.7075,
                0.7675,
                0.8275,
                0.885,
                0.945,
                1.005,
                1.0625,
                1.1225,
                1.18,
                1.24,
                1.3,
                1.3575,
                1.4175,
                1.475,
                1.535,
                1.595,
                1.6525,
                1.7125,
                1.7725,
                1.83,
                1.89,
                1.9475,
                2.0075,
                2.0675,
                2.125,
                2.185,
                2.2425,
                2.3025,
                2.3625,
                2.42
        ],
        "ImageOrientationPatientDICOM": [
                0.997087,
                -0.040086,
                0.0648888,
                0.0697231,
                0.823941,
                -0.56237
        ],
        "ImageOrientationText": "Tra>Cor(-34.4)>Sag(1.8)",
        "InPlanePhaseEncodingDirectionDICOM": "COL",
        "BidsGuess": [
                "func",
                "_acq-epfid2p2_dir-AP_run-41_bold"
        ],
        "ConversionSoftware": "dcm2niix",
        "ConversionSoftwareVersion": "v1.0.20240202",
        "TaskName": "rest",
	"B0FieldSource": "fmap0"
}

BOLD in MNI space

BOLD mask in MNI space

T1w in MNI space

T1w with the BOLD mask ontop in MNI space

Demonstrates the misalignment.

Hi @Luke_Vano ,

At first sight, I tend to think that the bold 2 T1w registration looks good, I usually look at the position of the ventricules on both images and if they overlap reasonably well, I tend to think that the bold-to-T1w worked.

Regarding IntendedFor and B0FieldIdentifier/B0FieldSource tags, usually tou just need one type or the other type (IntendedFor or B0FieldXX) . If both are present, fmriprep will use the B0FieldXX type.

I looked closely at the distorted and corrected images and I think that SDC worked as expected! It seems anyway that there was little distorsions to correct for on those images.

Now for the masks: note that the bold mask is calculated directly on the BOLD image, which still does not have the same exact shape as the anatomical T1w image, in particular because of the dropout inherent in the GRE-EPI images used for BOLD, which is never recovered. It is more common to use the brain mask calculated on the T1w image in MNI space and resample it in BOLD MNI space grid.

Does this makes sense to you?

2 Likes

Many thanks @Steven @jsein

Your explanations have been very clear and we are happy with the output from fmriprep.