How to resample functional data in gifti files: “…bold.func.gii” from fmriprep and convert gifti files to nifti?

Hello everyone,

Could you help me with my problem? I want to know how to resample functional data in gifti files: “…bold.func.gii” from fmriprep and convert gifti files to nifti?

To begin with, I want clarify my goal here:

  1. I want to resample my pre-processed functional data in fsaverage6 obtained from fmriprep into fsaverage4;
  2. and then convert these resampled gifti file into nifti file. Since I want to used a toolbox proposed by previous studies, and the toolbox only support nifti file such as “lh.sub_001_bld013_rest_reorient_skip_faln_mc_g1000000000_bpss_resid_fsaverage6_sm6_fsaverage4.nii.gz”.

My current idea is to use the mri_surf2surf function to resample sub_xxx_fsaverage6_bold.func.gii file into fsaverage4, and then use mri_surf2vol function to complete the format conversion of gifti-to-nifti. Since I’m very new to fmriprep and Freesufer analysis, the idea is likely to be problematic, please let me know if anyone has a better solution.

I tried the following command:
mri_surf2surf --srcsubject sub-n1005 --srcsurfval /home/user01/Project/HCprep/derivatives/fmriprep/sub-n1005/ses-1/func/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_bold.func.gii --trgsubject fsaverage4 --trgsurfval /home/user01/Project/HCprep/resampled/sub-n1005/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_to_fsaverage4.gii --hemi lh

Parameter description:

1. --srcsubject: this is the freesurfer output folder from fmriprep (in ...derivatives/freesurfer/...)

3. --srcsurfval: the input file from fmriprep --output-space fsaverage6 to be resampled. The input file save the time series information and can be read by gifti.m matlab function.

4. --trgsubject: I want to resample the data to fsaverage4 as I mentioned before.

Version:

system: centos 7
docker version: 20.10.21
fMRIPrep version: 21.0.4
Freesufer version: 7.2.0

Then I got these errors:

sysname  Linux
hostname cn5
machine  x86_64
user     user01
srcsubject = sub-n1005
srcval     = /home/user01/Project/HCprep/derivatives/fmriprep/sub-n1005/ses-1/func/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_bold.func.gii
srctype    = 
trgsubject = fsaverage4
trgval     = /home/user01/Project/HCprep/resampled/sub-n1005/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_to_fsaverage4.gii
trgtype    = 
srcsurfreg = sphere.reg
trgsurfreg = sphere.reg
srchemi    = lh
trghemi    = lh
frame      = 0
fwhm-in    = 0
fwhm-out   = 0
label-src  = (null)
label-trg  = (null)
OKToRevFaceOrder  = 1
UseDualHemi = 0
Reading source surface reg /home/user01/Project/HCprep/derivatives/fmriprep/sourcedata/freesurfer/sub-n1005/surf/lh.sphere.reg
Loading source data
MRISreadGiftiAsMRI: malformed time-series data array in file /home/user01/Project/HCprep/derivatives/fmriprep/sub-n1005/ses-1/func/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_bold.func.gii: nvertices=1 ncols=40962 expected num_vertices=1
ERROR: could not read /home/user01/Project/HCprep/derivatives/fmriprep/sub-n1005/ses-1/func/sub-n1005_ses-1_task-rest_hemi-L_space-fsaverage6_bold.func.gii as type 27

Does this error means that I should split the time points and resample each time point individually?I have spent a long time browsing the related posts on the forum, but I still haven’t found a solution.
Any help will be appreciated, thanks a million!

Lilf