mesh_check - Check for mesh data in p struct Usage: [n,exists] = mesh_check(p,meshtype) p is the eeg_toolbox struct (see eeg_toolbox_defaults) and meshtype is a string argument that is compared with all cells of p.mesh.data.meshtype. If it matches, the return value 'n' is the matching cell, ie, p.mesh.data.meshtype{n} and the boolean 'exists' variable is true. This function is called from mesh_open and other mesh utilities to facilitate efficient handling of the p.mesh.data struct.
0001 function [n,exists] = mesh_check(p,meshtype) 0002 0003 % mesh_check - Check for mesh data in p struct 0004 % 0005 % Usage: [n,exists] = mesh_check(p,meshtype) 0006 % 0007 % p is the eeg_toolbox struct (see eeg_toolbox_defaults) 0008 % and meshtype is a string argument that is compared 0009 % with all cells of p.mesh.data.meshtype. If it matches, 0010 % the return value 'n' is the matching cell, ie, 0011 % p.mesh.data.meshtype{n} and the boolean 'exists' 0012 % variable is true. This function is called from 0013 % mesh_open and other mesh utilities to facilitate 0014 % efficient handling of the p.mesh.data struct. 0015 % 0016 0017 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0018 0019 % Licence: GNU GPL, no implied or express warranties 0020 % History: 02/2002, Darren.Weber_at_radiology.ucsf.edu 0021 % 02/2004, Darren.Weber_at_radiology.ucsf.edu 0022 % check if the current cell is empty 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 n = 1; % this is the first mesh in p.mesh.data 0026 exists = 0; 0027 0028 if ~isempty(p.mesh.data), 0029 if isfield(p.mesh.data,'meshtype'), 0030 0031 Nmeshes = length(p.mesh.data.meshtype); 0032 0033 % new mesh can be added at the end 0034 n = Nmeshes + 1; 0035 0036 % check if the p.mesh.current is empty 0037 if p.mesh.current <= Nmeshes, 0038 if isempty(p.mesh.data.meshtype{p.mesh.current}), 0039 n = p.mesh.current; 0040 end 0041 end 0042 0043 % check whether any other cells contain the same mesh data so it 0044 % can be replaced 0045 indices = strcmp(p.mesh.data.meshtype,meshtype); 0046 found = find(indices); 0047 if found, 0048 n = found(1); 0049 exists = 1; 0050 end 0051 0052 end 0053 end 0054 0055 return