I’m struggling to get SDC working with case 1 from BIDS spec v1.7.
When fmriPrep runs, I get:
220512-10:54:01,254 nipype.workflow INFO:
B0 field inhomogeneity map will be estimated with the following 1 estimators: [<EstimatorType.PHASEDIFF: 3>].
220512-10:54:01,444 nipype.workflow INFO:
Using single-band reference file(s) sub-DPOP006_ses-1_task-rest_run-7_sbref.nii.gz.
220512-10:54:01,444 nipype.workflow CRITICAL:
None of the available B0 fieldmaps are associated to </bidsdir/sub-DPOP006/ses-1/func/sub-DPOP006_ses-1_task-rest_run-7_bold.nii.gz>
My bidsdir passes validation and I have setup IntendedFor for all three fmap images.
I have the echo times included and added the B0FieldIdentifier.
It looks to me like the preprocessing of fieldmaps is working. It’s just not getting associated with my bold image.
Both mag (1 and 2) images and phasediff image, side cars have IntendedFor:
Not sure if this will do the trick, but can you try to put the IntendedFor argment in brackets? That is, [‘ses-1…nii.gz’]. Otherwise, could you post your full command you are using to call fMRIPrep?
I recently encountered this ! If you drop B0FieldIdentifier, it will use the IntendedFor field appropriately. Otherwise, It prioritizes B0FieldIdentifier which requires B0FieldSource:
Oh that makes sense sort of. I don’t understand the B0FieldIndentifier and B0FieldSource and found it odd that I needed to include IntendedFor. I’ll read the doc you linked.
B0FieldIdentifier and B0FieldSource duplicate the capabilities of the original IntendedFor approach (see below), while permitting more complex use cases. It is RECOMMENDED to use both approaches to maintain compatibility with tools that support older datasets.
Removing the B0FieldIdentifer key from my fmaps and keeping only IntendedFor did the trick.
However, I’d like to not use that system if possible. It makes my code more complex to have to know the associated bolds in advance of making the BIDS structure.
I don’t understand how the B0FieldIdentifer and B0FieldSource are supposed to work.
My guess, is that I add to the 3 field maps files (mag1, mag2, phase_diff) "B-FieldIdentifer": "phasediff_fmap0"
Then to the BOLD image’s json, I add "B0FieldSource": "phasediff_fmap0".
That idea did not work as I received the same message to stdout, that no fieldmap was associated with the bold image.
To confirm: the first link is to common MR metadata fields for inclusion in the sidecar JSON files, rather than DICOM fields. It references relevant DICOM fields in the field description, to help in populating the field.
EDIT: The link corresponds to page 311 in the provided PDF.
To your question of using B0FieldIdentifier and B0FieldSource: Yes, you’d want to place the B0FieldSource field in the BOLD images’ JSON sidecar ! The _phasediff.json sidecar should look like this example
I’d expect that to work appropriately. There have been previous reports of the reverse situation (i.e., not working with IntendedFor only), but since these reports occur sporadically, I’m wondering if the working directory wasn’t accidentally re-used. Can you confirm that you re-ran both cases in a clean environment ?
Awesome… I was putting not only the “key” but also the value phasediff_fmap0 in the BOLD’s json.
The run with IntendedFor properly associated but then I got the dreaded error: KeyError: "Metadata term 'RepetitionTime' unavailable for file /bidsdir/sub-DPOP007/ses-2/func/sub-DPOP007_ses-2_task-rest_run-7_bold.nii.gz."
Of course that TR time is there perfectly from dcm2niix. Perhaps this is a bug that will go away.
In your case, it should correspond to what you had suggested previously:
{
"B0FieldSource": "phasediff_fmap0"
}
I agree, though, that there could be more relevant examples here! I imagine the challenge is that these B0Field fields can handle more complexity; i.e., an image being its own B0FieldSource, as alluded to in the current definitions.
Yeah that’s what I tried…no love. Same critical error of no association and a new one about missing TR time.
I’m about to jump out the window…
Proof I’m not crazy
The error I get from stdout.
220512-17:23:33,390 nipype.workflow INFO:
B0 field inhomogeneity map will be estimated with the following 1 estimators: [<EstimatorType.PHASEDIFF: 3>].
220512-17:23:33,600 nipype.workflow INFO:
Using single-band reference file(s) sub-DPOP007_ses-2_task-rest_run-7_sbref.nii.gz.
220512-17:23:33,600 nipype.workflow CRITICAL:
None of the available B0 fieldmaps are associated to </bidsdir/sub-DPOP007/ses-2/func/sub-DPOP007_ses-2_task-rest_run-7_bold.nii.gz>
Can you confirm that you’re not re-using an existing working directory?
Also, based on previous questions, I’d guess this might be a file permissions issue. But to confirm: if you include the IntendedFor field, you see neither of the described issues ?