Fieldmap not detected

Hi all,
I have been reading multiple threads on similar issue but none of the previous solutions worked.
I have inherited a children task fMRI dataset. The results on SPM were subpar due to high signal noise and I was curious if I could do better using fmriprep. I would like to run ICA-AROMA on the dataset, so my working fmriprep version is 23.0.1. I am kind of lost because I have used this fmriprep version before on other datasets (rest data) and the correction was always applied. There, IntendedFor value was set to


{
"IntendedFor": "bids::sub-01/ses-Scan2postECT/func/sub-01_ses-Scan2postECT_task-rest_run-1_part-mag_bold.nii.gz"
}

with direct fieldmapping.

Now I have a single pepolar image but no matter the IntendedFor definition, fmap is never located and fmriprep finishes without it. BIDS validation only passed a single IntendedFor value:

{"IntendedFor": "ses-1/func/sub-1005_ses-1_task-sst_part-mag_bold.nii.gz"}

Here is the subject tree I am testing on:

sub-1005
    └── ses-1
        ├── anat
        │   ├── sub-1005_ses-1_T1w.json
        │   └── sub-1005_ses-1_T1w.nii.gz
        ├── beh
        │   ├── sub-1005_ses-1_task-sst_beh.tsv
        │   └── sub-1005_ses-1_task-ts_beh.tsv
        ├── fmap
        │   ├── sub-1005_ses-1_acq-sst_dir-pa_epi.json
        │   └── sub-1005_ses-1_acq-sst_dir-pa_epi.nii.gz
        └── func
            ├── sub-1005_ses-1_task-sst_events.tsv
            ├── sub-1005_ses-1_task-sst_part-mag_bold.json
            └── sub-1005_ses-1_task-sst_part-mag_bold.nii.gz

fmap json should hold all information:

{
    "Manufacturer": "Philips",
    "PatientPosition": "HFS",
    "SeriesDescription": "ImageMRSERIES",
    "ProtocolName": "WIPSST_PA_s1SENSE",
    "SeriesNumber": 8,
    "AcquisitionNumber": 8,
    "ImageComments": "TECTO",
    "PhilipsRescaleSlope": 0.75018,
    "PhilipsRescaleIntercept": 0,
    "PhilipsScaleSlope": 0.00316373,
    "UsePhilipsFloatNotDisplayScaling": 1,
    "EchoTime": 0.03,
    "RepetitionTime": 1.7,
    "ImageOrientationPatientDICOM": [
        0.999517,
        0.00774078,
        -0.0300964,
        -0.0116886,
        0.991007,
        -0.133297
    ],
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20220720",
    "PhaseEncodingDirection": "j-",
    "SliceThickness": 2.5,
    "EffectiveEchoSpacing": 0.0005842639489512227,
    "TotalReadoutTime": 0.0461568519671466,
    "IntendedFor": "ses-1/func/sub-1005_ses-1_task-sst_part-mag_bold.nii.gz",
    "TaskName": "sst"
}

Does anyone have any solutions? Thank you

Hi @Vytautas_Labanauskas,

That surprises me because the BIDS URI only just got support in 24.0.0.

Can you confirm the phase encoding directions are opposite between fmap and bold?

Also the j- phase encoding should map to a AP direction, so I would confirm the file naming was done correctly.

Best,
Steven

Hi Steven,
Yes, now reading, it is surprising too. But now it is not accepted.

I am working with the notes I got, sadly no access to the scan protocol yet to confirm the phase encoding direction. With some documentation I got:
fmap:
“PhaseEncodingDirection”: “j-”
sub-1005_ses-1_acq-sst_dir-pa_epi.nii.gz

func:
“PhaseEncodingDirection”: “j”
sub-1005_ses-1_task-sst_part-mag_bold.nii.gz

Hi @Vytautas_Labanauskas,

While everything I’ve seen looks right on your end, I really can’t confirm if it’s right without testing on the data itself, and it’s also possible that it was a bug that was fixed since then (a lot of changes to SDC have been applied since 23.0.1).

How do you know it is not detected? What is your command? BIDS validator output? Have you tested on 24.0.1? True for all subjects or just this one?

Best,
Steven

Hi Steven,
It is true to all the subjects, though recently I focused on a single test subject for SDC. Strangely, the output never acknowledged fmaps (and the html outputs report no correction was applied). This is what I usually get in the log files:

Processing data from subject: sub-1005
Templateflow host cache: /mnt/scratch/projects/TECTO/fmriprep/templateflow/sub-1005
Running task 5
Commandline: singularity run --cleanenv -B /mnt/scratch/projects/TECTO/bids_func:/projectFolder -B /mnt/scratch/projects/TECTO/fmriprep/templateflow/sub-1005:/templateflow -B /mnt/scratch/projects/TECTO/fmriprep:/work /mnt/scratch/projects/TECTO/bids_func/code/singularity/fmriprep-23.0.1.sif --notrack --participant-label 1005 -w /work --output-spaces MNIPediatricAsym:res-1:cohort-1 --use-aroma --fs-no-reconall --fs-license-file /projectFolder/code/singularity/license.txt /projectFolder/raw /projectFolder/derivatives/fmriprep-23.0.1 participant
bids-validator@1.8.0

	e[33m1: [WARN] The recommended file /README is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 101 - README_FILE_MISSING)e[39m

e[36m	Please visit https://neurostars.org/search?q=README_FILE_MISSING for existing conversations about this issue.e[39m


        e[34me[4mSummary:e[24me[39m                   e[34me[4mAvailable Tasks:e[24me[39m        e[34me[4mAvailable Modalities:e[24me[39m 
        6146 Files, 58.92GB        ts                      MRI                   
        177 - Subjects             sst                                           
        2 - Sessions                                                             


e[36m	If you have any questions, please post on https://neurostars.org/tags/bids.e[39m

240729-10:45:51,376 nipype.workflow IMPORTANT:
	 Running fMRIPrep version 23.0.1

         License NOTICE ##################################################
         fMRIPrep 23.0.1
         Copyright 2023 The NiPreps Developers.
         
         This product includes software developed by
         the NiPreps Community (https://nipreps.org/).
         
         Portions of this software were developed at the Department of
         Psychology at Stanford University, Stanford, CA, US.
         
         This software is also distributed as a Docker container image.
         The bootstrapping file for the image ("Dockerfile") is licensed
         under the MIT License.
         
         This software may be distributed through an add-on package called
         "Docker Wrapper" that is under the BSD 3-clause License.
         #################################################################
240729-10:45:58,575 nipype.workflow IMPORTANT:
	 Building fMRIPrep's workflow:
           * BIDS dataset path: /projectFolder/raw.
           * Participant list: ['1005'].
           * Run identifier: 20240729-104447_2a23afd3-4f1f-43ed-a73d-5de9dce5459b.
           * Output spaces: MNIPediatricAsym:cohort-1:res-1.
           * Pre-run FreeSurfer's SUBJECTS_DIR: /projectFolder/derivatives/fmriprep-23.0.1/sourcedata/freesurfer.
240729-10:46:18,856 nipype.workflow INFO:
	 No single-band-reference found for sub-1005_ses-1_task-sst_dir-ap_part-mag_bold.nii.gz.
240729-10:46:22,282 nipype.workflow IMPORTANT:
	 BOLD series will be slice-timing corrected to an offset of 0.823s.
240729-10:46:38,356 nipype.workflow INFO:
	 fMRIPrep workflow graph with 347 nodes built successfully.
240729-10:47:04,173 nipype.workflow IMPORTANT:
	 fMRIPrep started!

I have been using this command line since I started using fmriprep. If I change IntendedFor line, BIDS validator immediately sends an error.
I can try running the newest version to see if there are any changes.

Can report, version 24.0.1 acts the same.
If I remove IntendedFor and use B0FieldSource instead I get:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/cli/workflow.py", line 114, in build_workflow
    retval["workflow"] = init_fmriprep_wf()
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 91, in init_fmriprep_wf
    single_subject_wf = init_single_subject_wf(subject_id)
  File "/opt/conda/lib/python3.9/site-packages/fmriprep/workflows/base.py", line 367, in init_single_subject_wf
    fmap_estimators = find_estimators(
  File "/opt/conda/lib/python3.9/site-packages/sdcflows/utils/wrangler.py", line 274, in find_estimators
    _e = fm.FieldmapEstimation([
  File "<attrs generated init sdcflows.fieldmaps.FieldmapEstimation>", line 7, in __init__
    self.__attrs_post_init__()
  File "/opt/conda/lib/python3.9/site-packages/sdcflows/fieldmaps.py", line 398, in __attrs_post_init__
    raise ValueError("Insufficient sources to estimate a fieldmap.")
ValueError: Insufficient sources to estimate a fieldmap.

So the fmaps are detected, right? Could it be something wrong with the nifti files instead?

Hi @Vytautas_Labanauskas,

I suppose it expects both phase encoding direction fmaps, or does not recognize that the BOLD and fmap are different phase encoding directions. Try adding the dir-<> label to your BOLD filename?

Best,
Steven

Hi Steven,
I tried editing BOLD dir-<> before, but the outcome is the same.

Hi @Vytautas_Labanauskas,

I believe that for BOLD you need both phase encoding directions in the fmaps. For DWI, you can get away with just one direction, because the B0 in the DWI can act as a fmap-input for one direction, but the BOLD contrast is too different to be used for fieldmap purposes. You can always try the built in fieldmapless method (SYN SDC) or SynBOLD-Disco (GitHub - MASILab/SynBOLD-DisCo: Synthetic BOLD images for distortion correction of fMRI without additional calibration scans).

Best,
Steven

Thank you, I will check it out.