gifti
- François Leroy
- Posts: 30
- Joined: Wed Feb 22, 2006 5:22 pm
gifti
Hi,
Is it possible to load meshes in GIFTI format in 3.1 brainvisa/anatomist release?
François
Is it possible to load meshes in GIFTI format in 3.1 brainvisa/anatomist release?
François
- Yann Cointepas
- Posts: 316
- Joined: Tue Jan 20, 2004 2:56 pm
- Location: Neurospin, Saint Aubin, France
- Contact:
Re: gifti
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.
- Olivier Coulon
- Posts: 176
- Joined: Fri Feb 27, 2004 11:48 am
- Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
- Contact:
Re: gifti
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
It is in the "Tools->Converter->Gifti to Brainvisa" process.
Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
-
- Posts: 44
- Joined: Wed Mar 15, 2006 10:29 am
- Location: Institut des Neurosciences de la Timone
- Contact:
Re: gifti
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
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
- Olivier Coulon
- Posts: 176
- Joined: Fri Feb 27, 2004 11:48 am
- Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
- Contact:
Re: gifti
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
Although there is no design limitation for multiple meshes, it is not recommended and has not been implemented yet.
Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
-
- Posts: 44
- Joined: Wed Mar 15, 2006 10:29 am
- Location: Institut des Neurosciences de la Timone
- Contact:
Re: gifti
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
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
- Olivier Coulon
- Posts: 176
- Joined: Fri Feb 27, 2004 11:48 am
- Location: MeCA research group, Institut de Neurosciences de La Timone, Marseille, France
- Contact:
Re: gifti
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
In the meantime, you can easily write a .mesh file from SPM, I guess.
Olivier
Olivier Coulon
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
Institut de Neurosciences de La Timone,
Aix-Marseille Université,
Marseille, france
https://meca-brain.org
-
- Posts: 44
- Joined: Wed Mar 15, 2006 10:29 am
- Location: Institut des Neurosciences de la Timone
- Contact:
Re: gifti
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
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
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Re: gifti
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
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
-
- Posts: 44
- Joined: Wed Mar 15, 2006 10:29 am
- Location: Institut des Neurosciences de la Timone
- Contact:
Re: gifti
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
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