Summary of what happened:
Files do not meet BIDS spec. Aiming to rename them using image orrientation and phase encoding direction from the json file.
Version:
“ConversionSoftware”: “dcm2niix”,
“ConversionSoftwareVersion”: “v1.0.20241211”,
Data formatted according to a validatable standard? Please provide the output of the validator:
Aiming to meet BIDS standard, currently have
error: NOT_INCLUDED
- /sub-FADFMRI100/ses-1/fmap/sub-FADFMRI100_ses-1_task-rest_run-001_bold-revPE.json
- /sub-FADFMRI100/ses-1/fmap/sub-FADFMRI100_ses-1_task-rest_run-001_bold-revPE.nii.gz
And many other files have the same error too.
Screenshots / relevant information:
Hi, I’m a beginner to neuroimaging analysis.
I wanted to check how phase direction works in fmap scans for BIDS datasets.
I have a dataset that looks like it has been converted using dcm2niix, and is now in a BIDS format.
The fieldmap files don’t meet the BIDS spec, so I am working out how to change them so that they do.
The fmap file names are written like sub-FADFMRI100_ses-1_task-rest_run-001_bold-revPE.nii.gz
It looks like it should be
sub-FADFMRI100_ses-1_task-rest_run-001_dir-AP_epi.nii.gz
It looks like the fmap files are the 4th option here, so I need the phase encoding direction for the file name.
This is a long way of asking, if I have the PhaseEncodingDirection (in the json file) and the image orientation (eg LAS, RPI, which I can get from the nifti file header), does this uniquely define the alphanumeric label phase encoding direction that needs to be in the filename? Is there more data I would need to use?
I wonder if it is related to this bug, bids.BIDSLayout.build_path() discards dir- label for dwi images · Issue #895 · bids-standard/pybids · GitHub , although I’m looking at fMRI not DWI.
Thanks for your help!
Hi @gabeyaw and welcome to neurostars!
Few issues here. (1) fmaps cannot have task-<>
label. (2) fmaps cannot have _bold
suffix. (3). -revPE
is not bids valid.
If you have a set of reverse phase encoded fmaps like in case 4 (Magnetic Resonance Imaging - Brain Imaging Data Structure 1.10.0), then you should have a file name such as
sub-FADFMRI100_ses-1_dir-<>_run-001_epi.json/nii.gz
I cannot say what your dir-<>
label should be without seeing the PhaseEncodingDirection
of the json, but typically j-
is dir-AP
and j
is dir-PA
.
Best,
Steven
Hi Steven, thanks for the welcome and quick reply!
Apologies, I previously fixed issue number 2 that you mentioned, I just didn’t type the correct file name in.
sub-FADFMRI100_ses-1_run-001_dir-AP_epi.nii.gz
would be the corrected file name.
For this specific scan it is j- phase encoding direction, so it would be dir_AP.
Because I need to correct most of the dataset, I’m just curious what you mean by typically? Are there any other factors it’s dependant on? I believe all scans have the phase encoding direction, but I will check
Hi @gabeyaw,
(From chatGPT)
To determine whether j-
corresponds to AP or PA, you must consider:
- Image orientation matrix (qform/sform in NIfTI):
- This tells how voxel axes map to world (scanner/anatomical) space.
- For example,
j
might map to anterior-posterior or left-right depending on the scan orientation.
- Scanner coordinate system:
- For most brain MRI scans:
- If the image is in RAS (Right-Anterior-Superior) orientation:
j
often corresponds to the A-P axis.
- So
j-
would mean phase encoding from P to A (i.e., “dir-PA”).
- But in other orientations (e.g., head tilted, oblique FOV),
j
might correspond to L-R or S-I.
1 Like
Hi Steven,
Thanks for your response, I’m planning to write some code to fix the file names, but I just wanted to double check I understood the conversion, here are the steps I think to follow:
To determine the direction of the phase encoding for the file name:
- Extract the NIfTI image qform_xorient, qform_yorient & qform_zorient values using fslhd.
- Look at the BIDS json sidecar file, extract the phaseEncodingDirection.
- Use the appropriate qform orient and flip if there is a minus.
So for an example file:
NIfTI header:
qform_xorient Right-to-Left
qform_yorient Posterior-to-Anterior
qform_zorient Inferior-to-Superior)
BIDS json:
“PhaseEncodingDirection”: “j-”,
j- means use qform_yorient, and there is a minus, so the file name should contain dir-AP.
Thanks!