Creating surface dataset from .gii files

26 views
Skip to first unread message

samantha audrain

unread,
Apr 25, 2024, 1:40:32 PM4/25/24
to CoSMoMVPA

Hi there,

 

I am trying to create a surface dataset from a .gii file. However, cosmo_surface_dataset isn't compatible with .gii files. Is there a way to get around this?

 

I can read in the .gii file using the gifti function in matlab but I am unsure of how to format it as a surf_ds. My surface files were created with HippUnfold, which uses .gii files. 


Is it possible to do this or am I out of luck?

 

Thanks!

 

Sam 

Nick Oosterhof

unread,
Apr 26, 2024, 6:03:08 AM4/26/24
to samantha audrain, CoSMoMVPA
Greetings,


On 25 Apr 2024, at 19:40, samantha audrain <samanth...@gmail.com> wrote:

I am trying to create a surface dataset from a .gii file. However, cosmo_surface_dataset isn't compatible with .gii files. Is there a way to get around this?

 

I can read in the .gii file using the gifti function in matlab but I am unsure of how to format it as a surf_ds. My surface files were created with HippUnfold, which uses .gii files. 

There is actually support for gifti files using cosmo_surface_datset, using this library: https://github.com/gllmflndn/gifti

(I see now the documentation did not mention the option, I just added it).

Have you tried it?

samantha audrain

unread,
Apr 26, 2024, 10:41:46 AM4/26/24
to CoSMoMVPA
Hello and thanks for your response! 

Can you clarify regarding the support available for gifti files using cosmo_surface_dataset? I am aware of the gifti library and I can read my gifti in to matlab using it. But how do I then get cosmo_surface_dataset to turn it into the surf_ds format?  When I feed the cosmo_surface_dataset function the imported gifti file, it gives me the following error:

Error using cosmo_surface_dataset>find_single_or_error
unknown object of type gifti

Or is there some other way I should be using the gifti library you mentioned?

Nick Oosterhof

unread,
Apr 26, 2024, 1:10:54 PM4/26/24
to samantha audrain, CoSMoMVPA

On 26 Apr 2024, at 16:41, samantha audrain <samanth...@gmail.com> wrote:

Can you clarify regarding the support available for gifti files using cosmo_surface_dataset? I am aware of the gifti library and I can read my gifti in to matlab using it. But how do I then get cosmo_surface_dataset to turn it into the surf_ds format?  When I feed the cosmo_surface_dataset function the imported gifti file, it gives me the following error:

Error using cosmo_surface_dataset>find_single_or_error
unknown object of type gifti

Or is there some other way I should be using the gifti library you mentioned?

Currently cosmo_surface_dataset detects a gifti object ``g`` through:

- g must be a gifti object (from the gifti library), that is isa(g, ‘gifti’) must be struct
- g must have a field cdata. At the moment this function was written that was what I observed.

Is the structure of your gifti object different? What does it look like?

samantha audrain

unread,
Apr 30, 2024, 9:53:25 AM4/30/24
to CoSMoMVPA
It's a gifti object but isn't a struct, isa(g, 'struct') returns 0. And there is no cdata field. 

intermediate_fn=fullfile(surface_path,...
sprintf('sub-pilot5_hemi-L_space-T2w_den-0p5mm_label-hipp_midthickness.surf.gii'));
g=gifti(intermediate_fn)

Screenshot 2024-04-30 at 9.32.32 AM.png

Nick Oosterhof

unread,
Apr 30, 2024, 12:17:10 PM4/30/24
to samantha audrain, CoSMoMVPA

On 30 Apr 2024, at 15:53, samantha audrain <samanth...@gmail.com> wrote:

It's a gifti object but isn't a struct, isa(g, 'struct') returns 0. And there is no cdata field. 

intermediate_fn=fullfile(surface_path,...
sprintf('sub-pilot5_hemi-L_space-T2w_den-0p5mm_label-hipp_midthickness.surf.gii'));
g=gifti(intermediate_fn)

gifti comes in many forms. For CoSMoMVPA two are relevant:

- anatomical datasets with faces and vertices. These can be passed in as the (second) surfs argument in cosmo_surficial_neighborhood. Your .surf.gii file would fall in this category. (Note that CoSMoMVPA does not use the .mat field). 
- functional datasets, with data for all or a subset of the nodes. These may have the .func.gii extension, although that is just a convention. Such files can be used as input to cosmo_surficial_dataset, and also as the ds (first) argument in cosmo_surficial_neighborhood. 

For searchlights, one could also select functional data in the volume while still using anatomical surface dataset, also using cosmo_surficial_dataset - this may preserve more information leading to more sensitivity. This approach was used in (shameless self-promotion) https://www.diedrichsenlab.org/pubs/Oosterhof_Neuroimage_2011.pdf

samantha audrain

unread,
Apr 30, 2024, 3:53:49 PM4/30/24
to CoSMoMVPA
Ah I see now, I was confused by the terminology in my newbie state. All is working now, thanks for pointing me in the right direction! And for the paper. 
Reply all
Reply to author
Forward
0 new messages