Plotting fMRIPrep surface files in Nilearn

Hi all,

I am trying to follow a tutorial for running seed-to-voxel connectivity on surface functional files with my own data. Specifically, I have rs-fMRI preprocessed by fMRIPrep (91k cifti outputs), then postprocessed with XCP_ABCD, leading to a smooth denoised cifti2 file in fsaverage space (e.g. sub-XX_task-rest_space-fsLR_den-91k_desc-residual_smooth_bold.dtseries.nii).

When I try to load it in Nilearn [e.g. timeseries = surface.load_surf_data(FUNC_FILE)], I get an error since it’s not a .gii, so I instead load it with image.load_img.

After transposing the timeseries to match the expected shape output from loading surfaces, I do the rest of the tutorial as is, but fail when I get to the seed-to-voxel stat-map plotting, since the density of the func file (91k res) does not match the surface mesh. I cannot seem to find a fsaverage 91k surface mesh to plot. Is there a way for me to plot my stat maps? Happy to provide more info as needed.

Thanks,
Steven

1 Like

Hi @Steven,

I might have misunderstood what you’re trying to do, but any chance vol_to_surf (see doc) could be useful here? Instead of using load_img, you would pass your image and mesh to vo_to_surf which will return the texture that you want to plot.

HTH
Nicolas

Hi @NicolasGensollen ,

Thanks for responding. Unfortunately, vol_to_surf returns an error, the same one as when I tried to load the file as a surface file directly:

TypeError: Data given cannot be loaded because it is not compatible with nibabel format:
Cifti2Image($NAME OF FUNC FILE)

OK, I got it wrong. I thought you converted your cifti image.
I think this post could be useful (especially the answers from @emdupre and @effigies), as well as this notebook (also linked in the post).

HTH
Nicolas

2 Likes

Thanks @NicolasGensollen,

This has definitely helped me understand more of the I/O of CIFTI files, but I am still running into an error where the func files (91k) do not match the resolution of surface meshes. I’ve looked for something that may work in both the subject’s anatomical derivatives as well as the fsLR templateflow cache. Maybe this is something that should be asked to fMRIPrep devs (@oesteban?), but one would think that the fsLR surface mesh at the appropriate resolution would be provided at some point in the workflow, right?

Best,
Steven

Most of the CIFTI implementation was done by @mgxd - he’s probably the best shot at this.

@Steven funny enough, we just added a few surface meshes to templateflow that can be used to visualize fsLR surface data.

tpl-fsLR/tpl-fsLR_den-32k_hemi-?_midthickness.surf.gii
tpl-fsLR/tpl-fsLR_den-32k_hemi-?_inflated.surf.gii
tpl-fsLR/tpl-fsLR_den-32k_hemi-?_veryinflated.surf.gii

You’ll need to either

  1. upgrade to the new templateflow release (0.7.2)
  2. update the templateflow skeleton
import templateflow.conf as tfc
tfc.update()
2 Likes

Hi @mgxd,

Thanks for the response. However, the 32k resolution of these meshes wouldn’t match the 91k of the CIFTI file, right? I would like to avoid resampling, if possible.

Steven

Yes it should - the 91k CIFTI is comprised of:

  • ~30k cortex vertices for each hemisphere
  • ~30k subcortical voxels
1 Like

Updating templateflow and using the new fsLR files worked, thanks!

2 Likes