Save Nilearn surface GLM output to connectome wb compatible format

Hi experts,

I’m trying to save a surface GLM contrast map to disk and I want to visualize it in wb_view. The nilearn tutorial way of doing it is to save the the data and mesh separately into giftis but this encounters problems when I tried to open it in wb_view: file extension not supported. Even if I manually edited the extension to shape.gii or surf.gii, it complains that the data file has no structure info (see screenshot), which I suspect is related to the mesh information being saved separately.

I have also tried to use nibabel to do the I/O with no luck. Is there a way to save the SurfaceImage object directly in one file or any workarounds? Thanks!

Mengya

Screenshots / relevant information:

image


Hi,
Sorry gifti is the community standard. With nibabel, you should be able to save the images in cifti format that should work with wb_view.
HTH,
Bertrand

Thanks for the quick reply Bertrand!

I’m very new to nibabel, can you point me to the right functions to try, specifically, how to save mesh and data into one file (assuming that’s what I need to do?)?

Also, correct me if I’m wrong, I thought surf.gii is a gifti format?

Mengya

Hi @mz385,

Giftis are indeed supported in wb_view. But you need to load the geometry mesh (a surf.gii mesh file) before loading scalar maps to load on it (shape.gii).

Best,
Steven

Steven’s answer is the right one. For completeness, what I ended up having to do was to rename mesh file to surf.gii and data file to shape.nii (nilearn doesnt automatically do that). Then I have to select all of them to open in wb_view, and specify their structures, e.g. cortextleft for left hemi. You can save the files again then next time wb_view would automatically recognize the structure.

1 Like