rs-fMRI multi-volume EPI - FMRIPREP preprocessing: Skipping processing of all BOLD volumes

Summary of what happened:

Hello,

I am hoping that someone can help me with the fmriprep preprocessing of my data that contains resting-state fMRI EPI images with number of volumes (.nii) and defaced T1-weighted structural image (.nii).

When I run the fmriprep (at present, just a single subject), it discards all the rs-fMRI related volumes (240 in total), as shown in the following figure.

However, it does complete the preprocessing of the T1w image. Please see the following figure.

I have tried passing “–ignore slicetiming” and also setting “–dummy-scans” to zero, with no success.

The following two figures shows my BIDS directory.


It appears to me to satisfy the requirement provided at Magnetic Resonance Imaging - Brain Imaging Data Structure v1.9.0 as well as the following response’s screenshot, taken from How to run multi-echo data on fMRIPrep-docker? - #5 by Andrea1

Could you please kindly assist me on resolving this is issue or advise if I am taking wrong steps in my preprocessing.

Thank you very much for your time and looking forward to hearing from you.

Sincerely,
Soheil

Hi @Soheil , The first thing is to check that your data is on BIDS format. Is that the case?
To use FMRIPREP, do you have access of a High Performance Computing Cluster (HPC)? OR do you plan to use it on your personal computer, with Docker for instance?

Hi jsein,

Thank you very much for your quick response.

I answer the second half of your question first. Yes, I do have access to HPC. I am running my code using Singularity.

I just checked this single subject on BIDS validator and it failed with following error (a single subject with 240 volumes)

It was good to check this. How did you get those NIFTI files? Did you convert DICOM images to NIFTI? Which convertor did you use?

I haven’t converted them. They were in their current format when I downloaded them. I have never had any issues with ‘DICOM’ formatted files. This is a first time that I am using multi-volume files.

Here is the description of their data

It comes from this study A multi-site, multi-disorder resting-state magnetic resonance image database | Scientific Data

I see. Which database is the participant that you try to preprocess from? I see that the database 4 is already in BIDS format. Are you able to read this nifti file with a neuroimaging viewer such as FSLeyes, AFNI or SPM?

Thank you very much for your time @jsein

I am using the database4 (downloaded through Synapse).

Yes, I can read the nifti files. Please see below the screenshots (FSLeyes) related to volumes 1 and 98, respectively (single subject).


Can you show more details of the BIDS validator error?
Could you also show the tree of the dataset you try to preprocess through fmriprep?

Clearly the bold nifti image looks normal through FSLeyes.

Please find below, the BIDS validator’s expanded window along with the BIDS tree (just a single subject).


The validator’s message continues, covering all 240 .nii files. Please let me know if you would rather like to see the entire messages/tree and I will send them in multiple screenshots.

The files did not come with a .json file. I prepared them using the minimal information below.
The content of rs-fMRI BOLD .json file (same repeated for the remainder of 240 files).
{“RepetitionTime”: 2.5, “TaskName”: “rest”}

Please note that the above TR is associated with one of the site (i.e., the site which this single subject comes from).

The error is pretty clear: BOLD images are 4D. If each file is a single volume, then they are not in BIDS format. The use of echo- here is a misuse of the entity. Echos are not TRs, but recordings of the same TRs at different echo times.

Combining is pretty quick with nibabel (just written, not tested):

import json
import numpy as np
import nibabel as nb

file_fmt = 'sub-{subject}_task-rest_run-1_echo-{vol}_bold.{ext}'

subject = '0004'
nvols = 240

with open(file_fmt.format(subject=subject, vol=1, ext='json') as fobj:
    sidecar = json.load(fobj)

TR = sidecar['RepetitionTime']

images = [nb.load(file_fmt.format(subject=subject, vol=vol, ext='nii')) for vol in range(1, nvols + 1)]
data = [img.dataobj for img in images]
header = images[0].header
zooms = header.get_zooms()[:3] + (TR,)

out_img = nb.Nifti1Image(np.stack(data), None, header)
out_img.header.set_zooms(zooms)

fixed_fmt = 'sub-{subject}_task-rest_run-1_bold.{ext}'
out_img.to_filename(fixed_fmt.format(subject=subject, ext='nii.gz'))

with open(fixed_fmt.format(subject=subject, ext='json'), 'w') as fobj:
    json.dump(sidecar, fobj)

May need minor fixups, and you should look at the results carefully to make sure you trust them. You could also use tools like fslmerge and fsledithd to do all this.

1 Like

Dear @effigies thank you very much for your kind note. I will try the options you advised. I will reach out again to share if I succeeded or I would need some further assistance.

Once again, thank you @jsein and @effigies .

Have a pleasant day.

1 Like

Dear @effigies Dear @jsein,

You are awesome!

I followed the instructions and succeeded with fmriprep (one single subject at present). Please see the fmriprep (files’) output below.

I have also examined the merged file (using fslmerge) output which looked pretty OK, as shown below.

And just for the reference, please see the subject’s T1w below.

Further to these, I have also applied the post-processing (i.e., normalization, confound regression, bandpass filtering, etc.) on the fmriprep output (rs-fMRI). It all went well.

Once again, thank you very much for your time and invaluable assistance.

First beer on me, if and when by any chance encounter we cross each others’ path somewhere than Internet!

Have a pleasant day/evening.

Sincerely,
Soheil

2 Likes