show_slices_move

PURPOSE ^

SHOW_SLICES_MOVE Shows planar slices of a 3D FEM with movement vectors

SYNOPSIS ^

function show_slices_move( img, move, move_scale )

DESCRIPTION ^

 SHOW_SLICES_MOVE   Shows planar slices of a 3D FEM with movement vectors
 if electrodes are visible on the slice.
 Args:     img  - eidors_obj type image
           move - new position vectors for nodes [x,y,z] after movement

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function show_slices_move( img, move, move_scale )
0002 % SHOW_SLICES_MOVE   Shows planar slices of a 3D FEM with movement vectors
0003 % if electrodes are visible on the slice.
0004 % Args:     img  - eidors_obj type image
0005 %           move - new position vectors for nodes [x,y,z] after movement
0006 
0007 % $Id: show_slices_move.html 2819 2011-09-07 16:43:11Z aadler $
0008 
0009 num_levs = 3;
0010 
0011 mdl = img.fwd_model;
0012 elecs = length(mdl.electrode);
0013 pos = zeros(elecs,3);
0014 if exist('move') && size(move,1) == size(mdl.nodes,1)
0015     move_nodes = move;
0016     move= zeros(elecs,3);
0017 end
0018 for e = 1:elecs;
0019     elec_nodes = mdl.electrode(e).nodes;
0020     pos(e,:) = mean(mdl.nodes(elec_nodes,:),1);
0021     if exist('move_nodes');
0022         move(e,:) = mean( move_nodes(elec_nodes,:), 1);
0023     end
0024 end
0025 
0026 elec_zmax = max(pos(:,3));
0027 elec_zmin = min(pos(:,3));
0028 
0029 levels = inf*ones(num_levs,3);
0030 levels(:,3) = [elec_zmax; elec_zmax-(elec_zmax - elec_zmin)/2; elec_zmin];
0031 levels(:,4) = ones(num_levs,1);
0032 levels(:,5) = (1:num_levs)';
0033 
0034 show_slices( img, levels );
0035 
0036 isize = calc_colours('npoints');
0037 toplayer = pos(:,3) < levels(2,3); % origin is top-left corner of image
0038 xofs = .5 + isize*(.5);
0039 xscale = (100/104)*isize/2;
0040 yofs = .5 + isize*(.5 + (num_levs-1)*toplayer);
0041 yscale = -(100/104)*isize/2;
0042 vx = pos(:,1) * xscale + xofs;
0043 vy = pos(:,2) * yscale + yofs;
0044 ecolour = [0,.3,0];
0045 hh= line(vx, vy);
0046 set(hh, 'LineStyle','none','Marker','.', ...
0047     'MarkerSize',10,'MarkerEdgeColor',ecolour);
0048 
0049 pp = aa_fwd_parameters( mdl );
0050 if nargin == 1;
0051     move = [];
0052 end
0053 if length(img.elem_data) > pp.n_elem
0054     move = reshape( ...
0055         img.elem_data( pp.n_elem+(1:pp.n_elec*pp.n_dims) ), ...
0056         pp.n_elec, pp.n_dims);
0057 end
0058 
0059 if ~isempty( move )
0060     nodes = img.fwd_model.nodes;
0061 
0062     % zero mean movement for each electrode row; this is not quite legit
0063     idx = 1:16;
0064     move(idx,:) = move(idx,:)- ones(16,1)*mean(move(idx,:));
0065     if length(img.fwd_model.electrode) == 32
0066         idx = 17:32;
0067         move(idx,:) = move(idx,:)- ones(16,1)*mean(move(idx,:));
0068     end
0069     hold on;
0070     if nargin < 3
0071         move_scale = 20*isize;
0072     end
0073     hh = working_quiver( vx, vy, move_scale*move(:,1), ...
0074         - move_scale*move(:,2), 0 );
0075     set(hh,'Color', [0,.3,0], 'LineWidth', 2, 'Clipping', 'off');
0076     hold off;
0077 end
0078 
0079 function hh= working_quiver( varargin )
0080 % WORKING_QUIVER   Matlab has made a completely imcompatible
0081 % quiver function which you can't call properly with different
0082 % versions of matlab.
0083 
0084 v = version;
0085 octave = exist('OCTAVE_VERSION') | str2num(v(1)) < 7;
0086 if octave
0087     hh = quiver( varargin{:} );
0088 else
0089     hh = quiver('v6', varargin{:} );
0090 end

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005