load preprocessed fMRI in fsaverage6 space in matlab

50 views
Skip to first unread message

Yijun Liu

unread,
May 10, 2024, 2:30:22 AM5/10/24
to CBIG users
Hi all,

I preprocessed GSP fMRI dataset using the scripts in https://github.com/ThomasYeoLab/Standalone_CBIG_fMRI_Preproc2016. The final step applis CBIG_preproc_native2fsaverage.csh to map the fMRI to fsaverage6 surface space. 

Now I'm trying to load the output surface .nii.gz fMRI in MATLAB. I expect to see the data in 2D format (#vertices * #time). However, I found that 

(1) cifti_read was not able to load the data as 2D surface fMRI in the same way as HCP data (error "cannot open as nifti file, hdr size = 134777631, should be 348 or 540") 

(2) freesurfer's MRIread function was able to load the .nii.gz file, however, it read as 4D (1 * 6 * 6827 * 120 for one hemisphere) instead of 2D. The last dimension matches #time points of the fMRI. However, I'm not sure how to reshape it to the correct format. Since 6 * 6827 = 40962 which is the number of surface vertices in fsaverage6 space, I wonder if it is correct to just do "data = reshape(data, [40962, 120])" in MATLAB for each hemisphere's data?

Regards.
Yijun

yanhongwei_a

unread,
May 12, 2024, 9:55:03 PM5/12/24
to CBIG users
Hi Yijun,

(1) the output surface in .nii.gz are in NIFTI format, you cannot open it with cifiti_read because cifti_read is for CIFTI files.

(2) You are right about reshaping the surface. CBIG_preproc_native2fsaverage.csh uses mri_vol2surf to project fMRI data onto the surface, and uses mri_surf2surf to perform mapping between surfaces. FreeSurfer performed reshaping for logistical reasons. You can find more information on Freesurfer's wiki page: https://surfer.nmr.mgh.harvard.edu/fswiki/mri_vol2surf

Regards,
Hongwei

yanhongwei_a

unread,
May 12, 2024, 10:35:03 PM5/12/24
to CBIG users
Hi Yijun and CBIG_users,

Here are some additional information on reading surface output from CBIG_preproc_native2fsaverage.csh.

The function CBIG_preproc_native2fsaverage.csh uses mri_vol2surf to project fMRI data onto the surface, and uses mri_surf2surf to perform mapping between surfaces. The output file for both Freesurfer functions are in NFITI(.nii.gz) format. NIFTI is typically used as a volume file format. When using it to store surface data, reshaping the surface data is necessary to avoid exceeding the maximum number of elements allowed in the NIFTI format. For more information, see: https://surfer.nmr.mgh.harvard.edu/fswiki/mri_vol2surf 

Here is an example about how to read the surface output in MALAB. Suppose your data file (lh.surf_in_fsaverage6.nii.gz) has 120 timepoints in fsaverage6 space. Then the following code in MATLAB using MRIread.m (from FreeSurfer) should work:

>> data = MRIread('lh.surf_in_fsaverage6.nii.gz'); 
>> data_mat = reshape(data.vol(:), [40962, 120]); 

data_mat is a matrix where each column corresponds to the timecourse of a fsaverage6 vertex.

Regards,
Hongwei

On Monday, May 13, 2024 at 9:55:03 AM UTC+8 yanhongwei_a wrote:
Hi Yijun,

(1) the output surface in .nii.gz are in NIFTI format, you cannot open it with cifiti_read because cifti_read is for CIFTI files.

(2) You are right about reshaping the surface. CBIG_preproc_native2fsaverage.csh uses mri_vol2surf to project fMRI data onto the surface, and uses mri_surf2surf to perform mapping between surfaces. FreeSurfer performed reshaping for logistical reasons. You can find more information on Freesurfer's wiki page: https://surfer.nmr.mgh.harvard.edu/fswiki/mri_vol2surf

Regards,
Hongwei

Yijun Liu

unread,
May 13, 2024, 4:51:30 PM5/13/24
to yanhongwei_a, CBIG users
Hi Hongwei,

Thanks a lot for your detailed explanation!

Yijun

--
You received this message because you are subscribed to a topic in the Google Groups "CBIG users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cbig_users/AbCQgMXOqeA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cbig_users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cbig_users/b0c4836c-8295-4633-8836-6a7ff05a9ca2n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages