remove_nodes

PURPOSE ^

REMOVE_NODES Remove nodes from a fwd_model.

SYNOPSIS ^

function [fmdl, c2f_idx] = remove_nodes(fmdl, idx, elec_opt)

DESCRIPTION ^

REMOVE_NODES   Remove nodes from a fwd_model.

  fmdl = REMOVE_NODES(fmdl, idx) removes fmdl.nodes(idx,:)
     fmdl : EIDORS fwd_model
     idx  : indices (integer or logical) into fmdl.nodes

  fmdl = REMOVE_NODES(... , elec_opt) specifies treatment of
    electrodes (fmdl.electrode) affected by the node removal:
     'warn'      - (default) warns about empty electrodes, but keeps them
     'keep'      - keeps empty electrodes
     'remove'    - removes empty electrodes
     'quiet'     - don't warn about changes to electrodes
    These options have no impact on the actual node removal.

  [fmdl, c2f_idx] = REMOVE_NODES(...) also provides indices of elem_data 
  to keep in an image.

  REMOVE_NODES removes affected edges/faces from fmdl.boundary, but does
  not recalculate it.

 See also: REMOVE_ELEMS, CROP_MODEL, REMOVE_UNUSED_NODES

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [fmdl, c2f_idx] = remove_nodes(fmdl, idx, elec_opt)
0002 %REMOVE_NODES   Remove nodes from a fwd_model.
0003 %
0004 %  fmdl = REMOVE_NODES(fmdl, idx) removes fmdl.nodes(idx,:)
0005 %     fmdl : EIDORS fwd_model
0006 %     idx  : indices (integer or logical) into fmdl.nodes
0007 %
0008 %  fmdl = REMOVE_NODES(... , elec_opt) specifies treatment of
0009 %    electrodes (fmdl.electrode) affected by the node removal:
0010 %     'warn'      - (default) warns about empty electrodes, but keeps them
0011 %     'keep'      - keeps empty electrodes
0012 %     'remove'    - removes empty electrodes
0013 %     'quiet'     - don't warn about changes to electrodes
0014 %    These options have no impact on the actual node removal.
0015 %
0016 %  [fmdl, c2f_idx] = REMOVE_NODES(...) also provides indices of elem_data
0017 %  to keep in an image.
0018 %
0019 %  REMOVE_NODES removes affected edges/faces from fmdl.boundary, but does
0020 %  not recalculate it.
0021 %
0022 % See also: REMOVE_ELEMS, CROP_MODEL, REMOVE_UNUSED_NODES
0023 
0024 % (C) 2024 Bartek Grychtol. License: GPL version 2 or version 3
0025 % $Id: remove_nodes.m 7002 2024-11-24 13:11:35Z aadler $
0026 
0027 
0028 
0029 if ischar(fmdl) && strcmp(fmdl, 'UNIT_TEST'), do_unit_test; return, end
0030 if nargin < 3, elec_opt = ''; end
0031 
0032 node_idx = false([num_nodes(fmdl), 1]);
0033 node_idx(idx) = true;
0034 elem_idx = any(node_idx(fmdl.elems),2);
0035 
0036 [fmdl, c2f_idx] = remove_elems(fmdl, elem_idx, elec_opt);
0037 
0038 function do_unit_test
0039 
0040 f0= mk_common_model('a2c2',4);
0041 f0= f0.fwd_model;
0042 fr= remove_nodes(f0, [10:13]);
0043 unit_test_cmp('2D- 1a',fr.nodes(20,:), f0.nodes(24,:));
0044 unit_test_cmp('2D- 1b',fr.elems(20,:),[24,11,12]);
0045 
0046 fr= remove_nodes(f0, [26:33],'remove');
0047 unit_test_cmp('2D- 2a',fr.nodes(25,:), f0.nodes(25,:));
0048 unit_test_cmp('2D- 2b',fr.nodes(26,:), f0.nodes(34,:));
0049 unit_test_cmp('2D- 2c',f0.elems(40,:),[20,19,33]);
0050 unit_test_cmp('2D- 2d',fr.elems(40,:),[14,25,33]);
0051 unit_test_cmp('2D- 2e',num_elecs(fr),2);
0052 
0053 fr= remove_nodes(f0, [26:33],'keep');
0054 unit_test_cmp('2D- 3a',fr.nodes(25,:), f0.nodes(25,:));
0055 unit_test_cmp('2D- 3b',fr.nodes(26,:), f0.nodes(34,:));
0056 unit_test_cmp('2D- 3c',f0.elems(40,:),[20,19,33]);
0057 unit_test_cmp('2D- 3d',fr.elems(40,:),[14,25,33]);
0058 unit_test_cmp('2D- 3e',num_elecs(fr),4);
0059 
0060 f0= mk_common_model('n3r2',[16,2]);
0061 f0= f0.fwd_model;
0062 fr= remove_nodes(f0, [59:63]);
0063 unit_test_cmp('3D- 1a',fr.nodes(80,:), f0.nodes(85,:));
0064 unit_test_cmp('3D- 1b',fr.elems(80,:),[41,42,76,18]);
0065 
0066 fr= remove_nodes(f0, [22:27],'remove');
0067 unit_test_cmp('2D- 2a',fr.nodes(21,:), f0.nodes(21,:));
0068 unit_test_cmp('2D- 2b',fr.nodes(22,:), f0.nodes(28,:));
0069 unit_test_cmp('2D- 2c',f0.elems(40,:),[10,73,74,38]);
0070 unit_test_cmp('2D- 2d',fr.elems(40,:),[10,67,68,32]);
0071 unit_test_cmp('2D- 2e',num_elecs(fr),29);
0072 
0073 fr= remove_nodes(f0, [22:27],'keep');
0074 unit_test_cmp('2D- 3a',fr.nodes(21,:), f0.nodes(21,:));
0075 unit_test_cmp('2D- 3b',fr.nodes(22,:), f0.nodes(28,:));
0076 unit_test_cmp('2D- 3c',f0.elems(40,:),[10,73,74,38]);
0077 unit_test_cmp('2D- 3d',fr.elems(40,:),[10,67,68,32]);
0078 unit_test_cmp('2D- 3e',num_elecs(fr),32);
0079

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