fMRIprep is not doing Susceptibility Distortion Correction

Summary of what happened:

I am encountering an issue in fMRIprep where the Susceptibility Distortion Correction is not being generated. I suspect this is because the field map sequence didn’t convert correctly when I used dcm2bids. Specifically, the ‘IntendedFor’ tags in the .json files seem incorrect. After researching on Neurostars, I found two errors in my field map’s .json file:

  1. The ‘IntendedFor’ field had a lowercase ‘i’ instead of an uppercase ‘I’.
  2. The tag contained “bids::sub-SubjectName” as part of the ‘IntendedFor’ field.

Following a suggestion from Neurostars (by Steven), I first removed “bids::sub-SubjectName” from the ‘IntendedFor’ tag in the field map’s .json file and reran fMRIprep. Although fMRIprep ran without errors, the Susceptibility Distortion Correction still did not generate. Next, I changed the lowercase ‘i’ in ‘IntendedFor’ to an uppercase ‘I’, but this caused fMRIprep to throw an error: "bids-validator’ error … returned non-zero exit status 1.

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

To conver dicom to bids in dcm2bids, following comand I used (Note: SEEG02 is the data folder name):
dcm2bids -d sourcedata/sub-SEEG02/ -p SEEG02 -s 01 -c code/dcm2bids_config.json --auto_extract_entities

For fMRIprep, below comand used:
singularity run --cleanenv \
    /data_PATH/software/fmriprep-23.1.4.simg \
    /data_PATH/nifti/rawdata 
    /data_PATH/nifti/derivatives/fmriprep-23.1.4 participant \
    --participant-label SEEG02 \
    -w /working/snray \
    --fs-license-file /home/snray/Documents/freesurfer_license_sr.txt \
    --output-spaces T1w MNI152NLin6Asym:res-2 fsaverage5 fsLR:den-32k \
    --cifti-output \
    --nthreads 6 \
    --omp-nthreads 3 \
    --verbose

Version:

“Dcm2bidsVersion”: “3.2.0”,
“dcm2niix”: “v1.0.20240202”,
“fmriprep”: 23.1.4

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

for dcm2nii, directly in the terminal and for fMRIprep: Singularity

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

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 43, in main
    parse_args()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/parser.py", line 812, in parse_args
    validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/utils/bids.py", line 185, in validate_input_dir
    subprocess.check_call(['bids-validator', str(bids_dir), '-c', temp.name])
  File "/opt/conda/envs/fmriprep/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['bids-validator', '/data/ucsfocd/data/mri/SEEG_subjects/nifti/rawdata', '-c', '/tmp/tmpkpsinw1e.jsonb']' returned non-zero exit status 1.
![Screenshot 2024-09-22 at 1.53.57 PM|689x371](upload://zkYQ5mFIyb0fiFaOjzuzZZ3OAFa.png)
![BIDS_Validator_error|690x336](upload://PuWPUa20JPrwEWllcBSpWtD516.jpeg)

Screenshots / relevant information:



Hi @RaySneha,

Could you provide contents of the run-01_bold.json and dir-PA_run-01_epi.json files? Is there a validator output in the log before the traceback you posted in this issue?

Best,
Steven

Thank you Steven, please find the attached .json files for the same. Note: I just changed the extension to .txt as it was not getting uploaded.

_task-rest_acq-abcd_run-01_bold.json.txt (2.7 KB)
_acq-pepolar_dir-PA_run-01_epi.json.txt (3.9 KB)

Hi @RaySneha,

The fmap JSON still has the BIDS URI at the beginning of each IntendedFor entry, and there is no “ses” folder level in each entry. The bold JSON is missing the TaskName field.

Best,
Steven

Dear Steven,

Thank you so much for helping me on it.
I’ve uploaded the .json file generated by dcm2bids. Previously, I had removed the BIDS URI from the start of each “IntendedFor” entry and added the “ses” folder level in the field map JSON file. But it didn’t helped.

For the bold JSON, the “TaskName” was missing, so now I manually added it. However, fMRIprep still isn’t generating the Susceptibility Distortion Correction. I’ve uploaded the modified JSON file—please review it and kindly help with this issue.

Best Regards
Sneha
_acq-pepolar_dir-PA_run-01_epi.json.txt (3.8 KB)
_task-rest_acq-abcd_run-01_bold.json.txt (2.7 KB)

Hi @RaySneha,

I would need to see the output of the BIDS validator on the updated dataset and some fmriprep logs to help. I am also worried that you have your multiecho data coded as separate runs (8 runs seems like a lot of data) instead of separate echos.

Best,
Steven

1 Like

Hi,
The Bids validator shows no error after updating the “TaskName” manually. please have a look the attached image.

Please find the fMRIprep log that generated inside the subject/log folder.

fmriprep.txt (2.3 KB)

Regarding the multiecho, yes, that actually for two run (each had 4 echos). I do that by manually editing. And for now, I do not consider the multi echo data for fMRIpre analysis. so we could ignore this for the time being.

Do you have the full output log that would be written to the terminal or .out file (if using a job scheduler)? And regarding the multi-echo, just make sure to fix that before doing preprocessing. How about the dir-AP_epi.json?

1 Like

Hi,

Please find the attached the output log of fmriprep generated in terminal. Regarding the fmap, I have manually edited the AP .json file similar to PA (Please find the attcahed dir-AP_epi.json) Currently, I am not including the multi-echo runs for running fmriprep, I just removed the them before preprocessing.
fmriprep_log_from_terminal.txt (413.9 KB)
sub-SEEG02_ses-01_acq-pepolar_dir-AP_run-01_epi.txt (3.8 KB)

Thanks,
Sneha

Hi @RaySneha,

You need to capitalize the “i” in IntendedFor.

Best,
Steven

1 Like

I tried capitalizing ‘I’ of “intendedFor” but every time fMRIPrep gives error (please find the attched log from terminal showing error for ‘IntendedFor’). Do you think this is happening due to bids conversion using dcm2bids??
fmriprep_log_terminal_‘IntendedFor’_error.txt (5.0 KB)

Thanks,
Sneha

Hi @RaySneha,

I’ve used dcm2bids numerous times with no problem. The tree structure from your picture before only showed run-01, so it is erroring out because the IntendedFor is also pointing to non-existent run-02 and above, and to the multiecho data which you appear to have deleted from the directory.

Best,
Steven

1 Like

I see…! Previously, I tried by deleting other runs and multi-echos but fmriprep didn’t generated SDC. Now, again I tried running as suggested by deleting non-existent runs, fMRIPrep is running now. I will update as soon as it finishes.

Thank you for assisting me.
Best regards,
Sneha

Dear Steven,

Thank you for all your suggestions and help. I’m happy to inform you that fMRIprep ran successfully, and the Susceptibility Distortion Correction was generated. There were multiple issues, and I’ve listed the corrections I made based on your suggestions, so it may help other users who face same issue:

  1. The ‘IntendedFor’ field had a lowercase ‘i’, which I corrected to an uppercase ‘I’.
  2. I removed the “bids::sub-SubjectName” from the ‘IntendedFor’ field.
  3. The ‘ses’ folder level was missing in each ‘IntendedFor’ entry, so I added it.
  4. The “TaskName” was missing in the bold JSON, which I added manually.
  5. In the ‘IntendedFor’ field, I kept only the sequence names used for fMRIprep analysis and removed the ones not considered.

Thanks again for your help!

@Steven I’ve encountered the same problem with SDC not running. I can confirm that I do not have the bids::sub attached to my capitalized "I"ntendedFor field. I also do not have ses folder. BIDS validator doesn’t throw any error. Attached is the file structure and the fmap json.


sub-220801_acq-func_dir-AP_epi.txt (2.5 KB)

Thanks a lot!

Hi @Catherine_Tang,

Please share the PA fmap json too.

Best,
Steven

@Steven here it is!

Hm, at first look it seems okay. Can you share your command, version, and bids validator output?

the fmriprep version: 24.1.0, fmriprep command is: fmriprep-docker /data/bids /data/test participant --participant-label 220908 --fs-license-file /home/user/license.txt --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym
the bids-validator output:

Can you share the fmriprep running log too? And also, I notice the participant label in your command doesn’t match the files you are showing. Can you confirm the file structure looks similar for that subject, given the validator suggests there are different files across subjects?