Page 1 of 1

gifti

Posted: Fri Jun 06, 2008 11:25 am
by François Leroy
Hi,
Is it possible to load meshes in GIFTI format in 3.1 brainvisa/anatomist release?
:?:
François

Re: gifti

Posted: Fri Jun 06, 2008 4:09 pm
by Yann Cointepas
Yes but only through BrainVISA (i.e. not directly with Anatomist or Aims) because we have BrainVISA processes to convert between GIFTI and Mesh (mainly done by Olivier Coulon) but there is no Aims reader for GIFTI.

Re: gifti

Posted: Thu Jun 12, 2008 1:24 pm
by Olivier Coulon
Hi, it is indeed possible, and if you do use the converter I would appreciate any feedback.
It is in the "Tools->Converter->Gifti to Brainvisa" process.

Olivier

Re: gifti

Posted: Thu Mar 12, 2009 2:31 pm
by guillaume
Hi everybody,

I converted a grey/white surface from BV with the process of Olivier and loaded it in matlab with the gifti class of SPM8b.
Everything worked well, thanks!

It doesnt work with multiple mesh (like in a graph), but it is possible to convert a multiple mesh file to multiple files with Aims.

Guillaume

Re: gifti

Posted: Thu Mar 12, 2009 3:11 pm
by Olivier Coulon
Good to hear ! I did not know there was already a gitfti class in spm...
Although there is no design limitation for multiple meshes, it is not recommended and has not been implemented yet.

Olivier

Re: gifti

Posted: Wed Apr 22, 2009 10:42 am
by guillaume
Hi,
here are some news about the gifti coverter:

It seems to me that the GiftiToBrainvisaConerter has a problem in the index of the faces, it doesn t work on my example.

I ve written a basic converter in matlab which returns a gifti tesselation in the space of the volume given (usually the MRI from which has been extracted the mesh) and in the referential of SPM8:


function gifti_out=BVmesh2SPMgifti(mesh_file,vol_file)
%convert .mesh tesselation from BrainVISA into a gifti in the SPM
%referential
gifti_out=gifti;
[vert, faces, gifti_out.normals, vertex_number, faces_number] = loadmesh(mesh_file);
gifti_out.faces=faces+1;
N= nifti(vol_file);
gifti_out.mat=N.mat;
dim=size(N.dat);
vox_size=abs(diag(N.mat(1:3,1:3)));
minf_mat=[1/vox_size(1), 0, 0, 1; 0, -1/vox_size(2), 0, dim(2); 0, 0, -1/vox_size(3), dim(3); 0, 0, 0, 1 ];


vert(:,4) = 1;
new = vert * minf_mat';
gifti_out.vertices = new(:,1:3);


function SPMgifti2BVmesh(gifti,mesh_file,vol_file)
%convert a gifti in the SPM referential into a .mesh tesselation for
%BrainVISA

N= nifti(vol_file);
dim=size(N.dat);
vox_size=abs(diag(N.mat(1:3,1:3)));
minf_mat=[1/vox_size(1), 0, 0, 1; 0, -1/vox_size(2), 0, dim(2); 0, 0, -1/vox_size(3), dim(3); 0, 0, 0, 1 ];

vert=gifti.vertices;
vert(:,4) = 1;
if gifti.mat==eye(4);
vert = vert * inv(N.mat)';
end
new = vert * inv(minf_mat)';

vertex = new(:,1:3);

savemesh(mesh_file,vertex,gifti.faces-1,gifti.normals,'binar')



ps: the loadmesh function is in the BV_path/brainvisa/matlab/mesh and the gifti function comes from the matlab gifti class http://www.artefact.tk/software/matlab/gifti/ which is also included in the SPM8 distribution, with the nifti calss

Guillaume

Re: gifti

Posted: Wed Apr 22, 2009 1:55 pm
by Olivier Coulon
Hi Guillaume, I am abroad with my family until early May, so I cannot do anything about it until then. I 'd be surprised if the problem came from the index of the faces, though... I will have a look at that.
In the meantime, you can easily write a .mesh file from SPM, I guess.

Olivier

Re: gifti

Posted: Wed Apr 22, 2009 2:32 pm
by guillaume
Hi Olivier,

the code in my last post converts BV .mesh to .gifti and vice-versa, so my problem is solved.
This was a sort of 'contribution'...

Have good time during your holidays!

Guillaume

Re: gifti

Posted: Wed Apr 22, 2009 5:19 pm
by riviere
Hi,
As you are using meshes within Matlab, would it not be a problem due to Matlab indexing arrays from 1 and not from 0 as it is logical in any other computer language ? (naive question...)
Denis

Re: gifti

Posted: Wed Apr 22, 2009 5:30 pm
by guillaume
Hi Denis,

this is why I said the problem would come from the faces index in GiftiToBrainvisaConerter...
I ve tried to save the gifti with faces-1 in matlab before the conversion with GiftiToBrainvisaConerter but that doesnt solve the problem.

Once more, the matlab code in my previous post works well, and i save the faces with savemesh(... ,faces-1, ...).
Gui