Home > vbmeg > external > iso2mesh > sample > demo_cgalmesher.m

demo_cgalmesher

PURPOSE ^

This example calls cgalmesher to mesh a segmented

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 This example calls cgalmesher to mesh a segmented
 brain volume. The segmentation was done by FreeSurfer
 and there are 41 different types of tissues. Each tissue
 type is labeled by a unique integer.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % This example calls cgalmesher to mesh a segmented
0002 % brain volume. The segmentation was done by FreeSurfer
0003 % and there are 41 different types of tissues. Each tissue
0004 % type is labeled by a unique integer.
0005 
0006 fprintf(1,'loading segmented brain image...\n');
0007 for i=1:256
0008   brain(:,:,i)=imread('brain_seg.tif',i);
0009 end
0010 brain=uint8(brain);
0011 
0012 % call cgalmesher to mesh the segmented volume
0013 % this will take 30 seconds on an Intel P4 2.4GHz PC
0014 
0015 fprintf(1,'meshing the segmented brain (this may take a few minutes) ...\n');
0016 
0017 [node,elem,face]=v2m(brain,[],2,100,'cgalmesh');
0018 
0019 figure
0020 hs=plotmesh(node,face,'y>100');
0021 
0022 axis equal;
0023 title('cross-cut view of the generated surface mesh');
0024 
0025 % find the sub-region number 3, it happens to be the right-hemisphere
0026 % cerebellum white matter. Use volface to extract the white matter surface.
0027 
0028 fprintf(1,'extracting the right-hemisphere cerebellum white matter surface\n')
0029 
0030 LHwhitemat=elem(find(elem(:,5)==5),:);
0031 wmsurf=volface(LHwhitemat(:,1:4));
0032 
0033 figure;
0034 hs=plotmesh(node,wmsurf);
0035 axis equal;
0036 title('pre-smoothed cerebellum white matter surface');
0037 
0038 
0039 fprintf(1,'performing mesh smoothing on the white matter surface\n')
0040 
0041 [no,el]=removeisolatednode(node,wmsurf);
0042 wmno=sms(no(:,1:3),el,3,0.5);
0043 
0044 figure;
0045 hs=plotmesh(wmno,el);
0046 axis equal;
0047 title('smoothed cerebellum white matter surface of the right-hemisphere');
0048 
0049 
0050 fprintf(1,'generate volumetric mesh from the smoothed cerebellum white matter surface \n')
0051 
0052 [wmnode,wmelem,wmface]=s2m(wmno(:,1:3),el(:,1:3),1,200);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005