Home > bioelectromagnetism > mesh_bem_shells.m

mesh_bem_shells

PURPOSE ^

mesh_bem_shells - Returns BEM scalp, skull and cortex meshes

SYNOPSIS ^

function[p] = mesh_bem_shells(IMG,FS)

DESCRIPTION ^

 mesh_bem_shells - Returns BEM scalp, skull and cortex meshes
 
[p] = mesh_bem_shells(IMG,FS)
 
 MRI volumes to process, eg:
 IMG.path   = '\data\freesurfer\subjects\c01\mri\analyze\';
 IMG.scalp  = 'c01_orig_axial_ras';
 IMG.oskull = 'c01_orig_axial_ras_bet_skull';
 IMG.iskull = 'c01_orig_axial_ras_bet';
 IMG.intensity.scalp = 
 
 The *_bet_skull volume should be converted to a binary mask
 and a mask of the *_bet volume should be subtracted from it.
 In addition, consider dilating the *_bet_skull volume and
 multiplying it by a FAST segmentation of the skull/csf (seg0)
 to remove extraneous data.
 
 Freesurfer surface to process, eg:
 FS.path   = '\data\freesurfer\subjects\c01\surf\';
 FS.file   = 'rh.white.asc';
 
 Except for the scalp, this function assumes extensive 
 MRI preprocessing with:
 
 FreeSurfer         http://surfer.nmr.mgh.harvard.edu/
 FSL tools (BET)    http://fmrib.ox.ac.uk/
 
 The return meshes are in p.mesh.data
 
 If you only want a scalp surface from an MRI volume,
 you can copy the scalp section of the code from this 
 function into your own script.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function[p] = mesh_bem_shells(IMG,FS)
0002 
0003 % mesh_bem_shells - Returns BEM scalp, skull and cortex meshes
0004 %
0005 %[p] = mesh_bem_shells(IMG,FS)
0006 %
0007 % MRI volumes to process, eg:
0008 % IMG.path   = '\data\freesurfer\subjects\c01\mri\analyze\';
0009 % IMG.scalp  = 'c01_orig_axial_ras';
0010 % IMG.oskull = 'c01_orig_axial_ras_bet_skull';
0011 % IMG.iskull = 'c01_orig_axial_ras_bet';
0012 % IMG.intensity.scalp =
0013 %
0014 % The *_bet_skull volume should be converted to a binary mask
0015 % and a mask of the *_bet volume should be subtracted from it.
0016 % In addition, consider dilating the *_bet_skull volume and
0017 % multiplying it by a FAST segmentation of the skull/csf (seg0)
0018 % to remove extraneous data.
0019 %
0020 % Freesurfer surface to process, eg:
0021 % FS.path   = '\data\freesurfer\subjects\c01\surf\';
0022 % FS.file   = 'rh.white.asc';
0023 %
0024 % Except for the scalp, this function assumes extensive
0025 % MRI preprocessing with:
0026 %
0027 % FreeSurfer         http://surfer.nmr.mgh.harvard.edu/
0028 % FSL tools (BET)    http://fmrib.ox.ac.uk/
0029 %
0030 % The return meshes are in p.mesh.data
0031 %
0032 % If you only want a scalp surface from an MRI volume,
0033 % you can copy the scalp section of the code from this
0034 % function into your own script.
0035 %
0036 
0037 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
0038 
0039 % Licence:  GNU GPL, no implied or express warranties
0040 % History:  10/2002, Darren.Weber_at_radiology.ucsf.edu, created
0041 %
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 
0044 p = eeg_toolbox_defaults;
0045 p.mesh.path = IMG.path;
0046 p.mesh.file = 'BrainStorm_subjecttess.mat';
0047 
0048 fprintf('\n\n**************************************\nProcessing %s\n\n',IMG.path);
0049 
0050 
0051 % LOAD FREESURFER CORTEX
0052 cd(FS.path)
0053 FS.surf = mesh_freesurfer2matlab(FS.file);
0054 Nsurf = 1;
0055 if isfield(FS.surf,'vertices'),
0056     p.mesh.data.meshtype{Nsurf} = 'cortex';
0057     p.mesh.data.vertices{Nsurf} = FS.surf.vertices;
0058     p.mesh.data.faces{Nsurf}    = FS.surf.faces;
0059     %patch('vertices',FS.surf.vertices,'faces',FS.surf.faces,'FaceColor',[.8 .0 .0],'Edgecolor','none');
0060 end
0061 
0062 % TESSELATE SKULL/SCALP SURFACES
0063 
0064 cd(IMG.path)
0065 
0066 % --- Tesselate Inner skull
0067 fprintf('\n\n**************************************\nProcessing "Inner Skull"\n\n');
0068 Nsurf = 2;
0069 intensity = IMG.intensity.iskull;
0070 tolerance = IMG.tolerance.iskull;
0071 avw = avw_img_read(IMG.iskull);
0072 ISkull = mesh_shrinkwrap(avw.img,[],0,0,intensity,tolerance,50,0.5,0.4);
0073 if isfield(ISkull,'vertices'),
0074     p.mesh.data.meshtype{Nsurf} = 'inner_skull';
0075     p.mesh.data.vertices{Nsurf} = ISkull.vertices;
0076     p.mesh.data.faces{Nsurf}    = ISkull.faces;
0077     %patch('vertices',ISkull.vertices,'faces',ISkull.faces,'FaceColor',[.6 .0 .0],'Edgecolor',[.8 .8 .8],'FaceAlpha',.2); axis tight; hold on
0078 end
0079 
0080 % --- Tesselate Outer skull
0081 fprintf('\n\n**************************************\nProcessing "Outer Skull"\n\n');
0082 Nsurf = 3;
0083 intensity = IMG.intensity.oskull;
0084 tolerance = IMG.tolerance.oskull;
0085 avw = avw_img_read(IMG.oskull);
0086 OSkull = mesh_shrinkwrap(avw.img,[],1,0,intensity,tolerance,10,0.005,0.1);
0087 if isfield(OSkull,'vertices'),
0088     p.mesh.data.meshtype{Nsurf} = 'outer_skull';
0089     p.mesh.data.vertices{Nsurf} = OSkull.vertices;
0090     p.mesh.data.faces{Nsurf}    = OSkull.faces;
0091     %patch('vertices',OSkull.vertices,'faces',OSkull.faces,'FaceColor',[.6 .0 .0],'Edgecolor',[.8 .8 .8],'FaceAlpha',.2); axis tight; hold on
0092 end
0093 
0094 % --- Tesselate Scalp ---
0095 fprintf('\n\n**************************************\nProcessing Scalp\n\n');
0096 Nsurf = 4;
0097 intensity = IMG.intensity.scalp;
0098 tolerance = IMG.tolerance.scalp;
0099 avw = avw_img_read(IMG.scalp);
0100 scalp = mesh_shrinkwrap(avw.img,[],0,0,intensity,tolerance,50,0.5,0.4);
0101 if isfield(scalp,'vertices'),
0102     p.mesh.data.meshtype{Nsurf} = 'scalp';
0103     p.mesh.data.vertices{Nsurf} = scalp.vertices;
0104     p.mesh.data.faces{Nsurf}    = scalp.faces;
0105     %patch('vertices',scalp.vertices,'faces',scalp.faces,'FaceColor',[.6 .0 .0],'Edgecolor',[.8 .8 .8],'FaceAlpha',.2); axis tight; hold on
0106 end
0107 
0108 
0109 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003