0001 function show_slices_move( img, move, move_scale )
0002
0003
0004
0005
0006
0007
0008
0009 if ischar(img) && strcmp(img,'UNIT_TEST'); do_unit_test; return; end
0010
0011
0012 num_levs = 3;
0013
0014 mdl = img.fwd_model;
0015 elecs = length(mdl.electrode);
0016 pos = zeros(elecs,3);
0017 if exist('move') && size(move,1) == size(mdl.nodes,1)
0018 move_nodes = move;
0019 move= zeros(elecs,3);
0020 end
0021 for e = 1:elecs;
0022 if isfield(mdl.electrode(e),'pos')
0023 pos(e,:) = mean(mdl.electrode(e).pos);
0024 else
0025 elec_nodes = mdl.electrode(e).nodes;
0026 pos(e,:) = mean(mdl.nodes(elec_nodes,:),1);
0027 end
0028 if exist('move_nodes');
0029 move(e,:) = mean( move_nodes(elec_nodes,:), 1);
0030 end
0031 end
0032
0033 elec_zmax = max(pos(:,3));
0034 elec_zmin = min(pos(:,3));
0035
0036 levels = inf*ones(num_levs,3);
0037 levels(:,3) = [elec_zmax; elec_zmax-(elec_zmax - elec_zmin)/2; elec_zmin];
0038
0039 img.show_slices.img_cols = 1;
0040
0041 show_slices( img, levels );
0042
0043 isize = calc_colours('npoints');
0044 toplayer = pos(:,3) < levels(2,3);
0045 xofs = .5 + isize*(.5);
0046 xscale = (100/104)*isize/2;
0047 yofs = .5 + isize*(.5 + (num_levs-1)*toplayer);
0048 yscale = -(100/104)*isize/2;
0049 vx = pos(:,1) * xscale + xofs;
0050 vy = pos(:,2) * yscale + yofs;
0051 ecolour = [0,.3,0];
0052 hh= line(vx, vy);
0053 set(hh, 'LineStyle','none','Marker','.', ...
0054 'MarkerSize',10,'MarkerEdgeColor',ecolour);
0055
0056 pp = fwd_model_parameters( mdl );
0057 if nargin == 1;
0058 move = [];
0059 end
0060 if length(img.elem_data) > pp.n_elem
0061 move = reshape( ...
0062 img.elem_data( pp.n_elem+(1:pp.n_elec*pp.n_dims) ), ...
0063 pp.n_elec, pp.n_dims);
0064 end
0065
0066 if ~isempty( move )
0067 nodes = img.fwd_model.nodes;
0068
0069
0070 idx = 1:16;
0071 move(idx,:) = move(idx,:)- ones(16,1)*mean(move(idx,:));
0072 if length(img.fwd_model.electrode) == 32
0073 idx = 17:32;
0074 move(idx,:) = move(idx,:)- ones(16,1)*mean(move(idx,:));
0075 end
0076 hold on;
0077 if nargin < 3
0078 move_scale = 20*isize;
0079 end
0080 hh = working_quiver( vx, vy, move_scale*move(:,1), ...
0081 - move_scale*move(:,2), 0 );
0082 set(hh,'Color', [0,.3,0], 'LineWidth', 2, 'Clipping', 'off');
0083 hold off;
0084 end
0085
0086 function hh= working_quiver( varargin )
0087
0088
0089
0090
0091
0092
0093
0094 hh = quiver( varargin{:} );
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 function do_unit_test
0106 subplot(221);
0107 img = mk_image( mk_common_model('n3r2',[16,2]) );
0108 show_slices_move(img);
0109
0110 subplot(222);
0111 for i=1:length(img.fwd_model.electrode)
0112 e_node = img.fwd_model.electrode(i).nodes;
0113 move(i,:) = 0.01*mean( img.fwd_model.nodes(e_node,:),1);
0114 end
0115 show_slices_move(img,move);
0116
0117 subplot(223);
0118 show_slices_move(img,move, 1000);