[FieldTrip] Antw: Creating a head model using OPENMEEG - Intersecting mesh error

Daniel Wong dan.wong.c at utoronto.ca
Mon Jan 20 19:10:51 CET 2014


You can try using the new iso2mesh meshing option that was recently  
added by myself, Sarang Dalal, and Robert Oostenveld:

cfg.method = 'iso2mesh';
cfg.numvertices = 10000;   % We'll decimate later - this gives nicer results
bnd = ft_prepare_mesh(cfg,seg);

% Decimate to a 1000, 2000, 3000 node mesh (scalp, skull, brain)
[bnd(1).pnt, bnd(1).tri] = meshresample(bnd(1).pnt, bnd(1).tri,  
1000/size(bnd(1).pnt,1));
[bnd(2).pnt, bnd(2).tri] = meshresample(bnd(2).pnt, bnd(2).tri,  
2000/size(bnd(2).pnt,1));
[bnd(3).pnt, bnd(3).tri] = meshresample(bnd(3).pnt, bnd(3).tri,  
3000/size(bnd(3).pnt,1));

The latest version of OpenMEEG automatically fixes mesh orientations,  
but if you have an older version of OpenMEEG, you'll need to set  
bnd(ii).tri = bnd(ii).tri(:,[3 2 1]) to fix the orientation error that  
you'll get - at least until we hard code that fix into FieldTrip.

Also, assuming your meshes look like they should (use ft_plot_mesh to  
check), if you still have a problem with meshes intersecting each  
other, you will find a subfunction called decouplesurf that is  
temporarily stashed  at the end of prepare_mesh_segmentation.m.  Copy  
this function into a new m-file (decouplesurf.m) and use it to fix  
those intersections as follows:

bnd = decouplesurf(bnd);

Note, this will not fix self-intersections. If you're really having a  
bad day, try using the iso2mesh toolbox meshcheckrepair function:
% Check and repair mesh
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri, 'dup');
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri,  
'isolated');
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri,  
'deep');
[bnd(ii).pnt, bnd(ii).tri] = meshcheckrepair(bnd(ii).pnt, bnd(ii).tri,  
'meshfix');

This info should eventually find its way onto the FieldTrip tutorial pages...


Best Regards,
Daniel Wong

Daniel Wong, PhD (IBBME, University of Toronto)
Postdoctoral Researcher
Department of Psychology
University of Konstanz





More information about the fieldtrip mailing list