0001 function [hf,hh] = show_fem_move( img, move, scale, options )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if ischar(img) && strcmp(img,'UNIT_TEST'); do_unit_test; return; end
0013
0014
0015 if nargin == 1
0016 move = [];
0017 scale = 20;
0018 options = [0,0,[]];
0019 elseif nargin == 2
0020 scale = 20;
0021 options = [0,0,[]];
0022 elseif nargin == 3
0023 options = [0,0,[]];
0024 end
0025
0026
0027 fwdp = fwd_model_parameters( img.fwd_model );
0028 try
0029 fwdp.n_elem = size(img.fwd_model.coarse2fine,2);
0030 end
0031
0032 if isfield(img,'elem_data')
0033 if length(img.elem_data) > fwdp.n_elem
0034 move = reshape( ...
0035 img.elem_data( fwdp.n_elem+(1:fwdp.n_elec*fwdp.n_dims) ), ...
0036 fwdp.n_elec, fwdp.n_dims);
0037 img.elem_data = img.elem_data(1:fwdp.n_elem);
0038 end
0039 else
0040 img = data_mapper(img);
0041 move = reshape( img.movement.electrode_data, ...
0042 fwdp.n_elec, fwdp.n_dims);
0043 end
0044
0045 hf = show_fem(img, options);
0046
0047
0048 if ~isempty(move)
0049
0050 e_nodes = [];
0051 electr= img.fwd_model.electrode;
0052 nodes = img.fwd_model.nodes;
0053 switch size(move,1)
0054 case length(electr)
0055 for i=1:length(electr)
0056 if isfield(electr(i), 'pos')
0057 e_nodes(i,:) = mean(electr(i).pos);
0058 else
0059 e_nodes(i,:) = mean(nodes(electr(i).nodes,:),1);
0060 end
0061 end
0062
0063 case num_nodes(img)
0064
0065 e_nodes = [electr(:).nodes];
0066 if size(move,1) == fwdp.n_node;
0067 move = move(e_nodes,:);
0068 end
0069 e_nodes = nodes(e_nodes,:);
0070
0071 otherwise;
0072 error('movement vector doesn''t match model');
0073 end
0074 move = move- ones(size(move,1),1)*mean(move);
0075
0076
0077 hold on;
0078 if nargin < 3
0079 scale = 20;
0080 end
0081 hh = working_quiver(e_nodes, scale*move);
0082 set(hh,'Color', [0,.3,0], 'LineWidth', 2, 'Clipping', 'off');
0083 hold off;
0084 end
0085
0086 axis('off');
0087 axis('image');
0088
0089
0090 function hh= working_quiver( nn,mm )
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 hh = quiver( nn(:,1),nn(:,2), mm(:,1),mm(:,2),0);
0101
0102 function do_unit_test;
0103 subplot(231);
0104 img = mk_image(mk_common_model('a2c2',8));
0105 img.elem_data = [img.elem_data;.01*randn(16,1)];
0106 show_fem_move(img);
0107 title('move at electrodes');
0108
0109 subplot(232);
0110 img = mk_image(mk_common_model('a2c2',8));
0111 show_fem_move( img, img.fwd_model.nodes*[-1,0;0,1], .2);
0112 title('move at electrodes (via all move)');
0113
0114 subplot(233);
0115 img = mk_image(mk_common_model('a2C2',8));
0116 img.elem_data = [img.elem_data;.01*randn(16,1)];
0117 show_fem_move(img);
0118 title('move at electrodes ctrs');
0119
0120 subplot(234);
0121 img = mk_image(mk_common_model('a2C0',8));
0122 img.elem_data(1:2) = 1.1;
0123 show_fem_move( img, img.fwd_model.nodes*[-1,0;0,1], .2);
0124 title('move at electrodes nodes');
0125
0126 subplot(235);
0127 img = mk_image(mk_common_model('n3r2',[16,2]));
0128 img.elem_data(400)= 0.9;
0129 img.elem_data = [img.elem_data;.01*randn(3*32,1)];
0130 show_fem_move(img); view([-14,62]);
0131 title('BUG:move at electrodes ctrs');
0132
0133 subplot(236);
0134 img = mk_image(mk_common_model('n3r2',[16,2]));
0135 move = img.fwd_model.nodes*diag([-1,1,1]);
0136 show_fem_move( img, move, .2); view([-14,62]);
0137 title('BUG:move at electrodes ctrs');