gallantlab / pycortex

Pycortex is a python-based toolkit for surface visualization of fMRI data
https://gallantlab.github.io/pycortex
BSD 2-Clause "Simplified" License
577 stars 136 forks source link

Save Vertex Object as GIfTI #326

Open amyh101 opened 5 years ago

amyh101 commented 5 years ago

Hi all! Thanks for the awesome toolbox! I am currently tying to export vertex data as a GIfTI and am wondering if there is any easy way to do with within your toolbox.

I am able to generate Vertex data for S1 and can view the data within python (e.g. vertex_data.data). Is there an easy way to export the data as cdata in a gii file format? I noticed this seems possible in the Volume object to save as .nii, but I was hoping there is a correlate for the vertex data.

Alternatively, is there a different file format that might afford me similar capability to manipulate and plot the vertex data in other software packages (e.g. matlab)?

Thanks!

marklescroart commented 5 years ago

Pardon the delay; there isn't currently a ready mechanism to save functional data in .gii format. It's pretty straightforward to save the relevant data from a Vertex object to an hdf file, though (using h5py or other libraries). pycortex uses h5py internally, so you should have it installed already. Matlab can load hdf files (using h5read or possibly other functions). Technically, Matlab version 7.3 .mat files ARE hdf files with a bit of extra header info (and they can be read by h5py into python).

marklescroart commented 5 years ago

BTW, I've taken a brief stab at adding a save_gii() function to the Vertex object (a reasonable request), but it's a bit more annoying than I have time to finish now, so please leave this issue open and I or someone else will return to it later.

amyh101 commented 5 years ago

Great! thank you for the suggested workaround that seems to do the trick. Thanks!