Back to the main page.

Bug 1510 - BEM meshes seem to be intersecting in MEG forward model with openmeeg

Status CLOSED WONTFIX
Reported 2012-06-08 10:49:00 +0200
Modified 2015-07-20 10:19:28 +0200
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Imali Thanuja Hettiarachchi - 2012-06-08 10:49:03 +0200

On 8 Jun 2012, at 3:05, IMALI THANUJA HETTIARACHCHI wrote: Dear All, I started with fieldTrip recently and I am trying to create a BEM headmodel using the mri data (standard_mri.mat) available on the website. I use the following code load standard_mri.mat mri_orig=mri; % Realign the data to the CTF system cfg = []; cfg.method = 'interactive'; % use n,l,r fudicials mri_realign = ft_volumerealign(cfg, mri_orig); cfg = []; cfg.resolution = 1; % mm cfg.dim = mri_orig.dim; mri_reslice = ft_volumereslice(cfg, mri_realign); %% Segmenting the data cfg = []; cfg.output= {'scalp','skull','brain'}; cfg.coordinates = 'ctf'; cfg.keepintermediate = 'no'; [mri_segment] = ft_volumesegment(cfg, mri_reslice); mri_combine = mri_reslice; mri_combine.seg = mri_segment.scalp + 3*mri_segment.skull + 6*mri_segment.brain; mri_combine.mask = (mri_combine.seg)>0; %% Plot data cfg = []; cfg.interactive = 'no'; cfg.method='slice'; cfg.funparameter = 'seg'; cfg.funcolormap = 'jet'; cfg.funcolorlim = [0 7]; cfg.opacitylim = [0 1.5]; cfg.maskparameter = 'mask'; figure , ft_sourceplot(cfg,mri_combine); %% Generating the mesh cfg=[]; cfg.tissue=[1 2 3]; cfg.numvertices=[5000 3000 800]; cfg.sourceunits=mri_segment.unit; scalp=(mri_segment.scalp)&~(mri_segment.skull | mri_segment.brain); skull=2*(mri_segment.skull); brain=3*(mri_segment.brain); mri_segment.seg= scalp+skull+brain; bnd = ft_prepare_mesh(cfg, mri_segment); %% View meshes a transparent plot figure (2) tr1=TriRep(bnd(1).tri,bnd(1).pnt(:,1),bnd(1).pnt(:,2),bnd(1).pnt(:,3)); tr2=TriRep(bnd(2).tri,bnd(2).pnt(:,1),bnd(2).pnt(:,2),bnd(2).pnt(:,3)); tr3=TriRep(bnd(3).tri,bnd(3).pnt(:,1),bnd(3).pnt(:,2),bnd(3).pnt(:,3)); trisurf(tr1,'facealpha',0.1); hold on trisurf(tr2,'facealpha',0.2); hold on trisurf(tr3) %% BEM Computation-calculating the related electromagnetic model Cskin_surface= 0.33; %scalp Couter_skull_surface=0.0042; %skull Cinner_skull_surface=0.33; %brain vol=[]; for i=1:3 vol.bnd(i).tri=bnd(i).tri; vol.bnd(i).pnt=bnd(i).pnt; end vol.cond=[Cskin_surface Couter_skull_surface Cinner_skull_surface]; cfg=[]; cfg.method = 'openmeeg'; vol = ft_prepare_headmodel(cfg, vol); When I run the code at the stage of generating the headmodel with ft_prepare_headmodel, I get an error as; ??? Error using ==> surface_nesting at 24 the compartment nesting cannot be determined Error in ==> ft_headmodel_bem_openmeeg at 96 order = surface_nesting(vol.bnd, 'insidefirst'); With the limited experience with fieldTrip and headmodels I assume that this is because the meshes are overlapping.


Jan-Mathijs Schoffelen - 2014-05-13 11:50:20 +0200

Addressing some old open bugs... The reported error indeed could very well be caused by intersection of the meshes. Note that the segmentation tools that come packaged with FieldTrip may not be state-of-the-art. In combination with the quality of the MR-data some time may need to be spent on getting the meshes right. At the moment this would be the user's responsibility.


Jan-Mathijs Schoffelen - 2015-07-20 10:19:28 +0200

Closed several bugs at once.