remove_instrument_electrodes

PURPOSE ^

pre-delete all 'instrument' nodes

SYNOPSIS ^

function fmdl = remove_instrument_electrodes(fmdl)

DESCRIPTION ^

 pre-delete all 'instrument' nodes
 system matrix can't handle them
 NOTE: instrument nodes must be at end

 Used by system_mat_instrument

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fmdl = remove_instrument_electrodes(fmdl)
0002 % pre-delete all 'instrument' nodes
0003 % system matrix can't handle them
0004 % NOTE: instrument nodes must be at end
0005 %
0006 % Used by system_mat_instrument
0007 
0008 % (C) 2023 Andy Adler. Licence GPL v2 or v3
0009 
0010    if ~isfield(fmdl,'electrode')
0011       return % nothing to do
0012    end
0013    rmelec = [];
0014    for i=num_elecs(fmdl):-1:1
0015       try
0016          enodes = fmdl.electrode(i).nodes;
0017          if ischar(enodes) && strcmp(enodes,'instrument');
0018             rmelec(end+1) = i;
0019          end
0020       end
0021    end
0022    fmdl.electrode(rmelec)= [];
0023 
0024    if ~isfield(fmdl,'stimulation')
0025       return % nothing to do
0026    end
0027 
0028    for i=1:length(fmdl.stimulation)
0029       fmdl.stimulation(i).stim_pattern(rmelec) = []; 
0030       fmdl.stimulation(i).meas_pattern(:,rmelec) = []; 
0031       try % if it exists
0032       fmdl.stimulation(i).volt_pattern(rmelec) = []; 
0033       end
0034    end
0035 
0036

Generated on Sun 29-Dec-2024 11:41:59 by m2html © 2005