show_fem_move

PURPOSE ^

SHOW_FEM_MOVE Plot EIT finite element model (FEM) and movement

SYNOPSIS ^

function show_fem_move( img, move, scale, options )

DESCRIPTION ^

 SHOW_FEM_MOVE   Plot EIT finite element model (FEM) and movement 
    vectors.
 Args: img     - eidors_obj of type 'image'
       move    - FEM node coordinate matrix of movement vectors (optional)
       scale   - factor to scale movement arrows (optional)
       options - options array passed on to show_fem()

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function show_fem_move( img, move, scale, options )
0002 % SHOW_FEM_MOVE   Plot EIT finite element model (FEM) and movement
0003 %    vectors.
0004 % Args: img     - eidors_obj of type 'image'
0005 %       move    - FEM node coordinate matrix of movement vectors (optional)
0006 %       scale   - factor to scale movement arrows (optional)
0007 %       options - options array passed on to show_fem()
0008 
0009 % $Id: show_fem_move.html 2819 2011-09-07 16:43:11Z aadler $
0010 
0011 % Check for single argument call
0012 if nargin == 1
0013     move = [];
0014     scale = 20;
0015     options = [0,0,[]];
0016 elseif nargin == 2
0017     scale = 20;
0018     options = [0,0,[]];
0019 elseif nargin == 3
0020     options = [0,0,[]];
0021 end
0022 
0023 % Extract forward model parameters
0024 fwdp = aa_fwd_parameters( img.fwd_model );
0025 
0026 % Verify if img is partitioned by conductivity and move submatrices
0027 if length(img.elem_data) > fwdp.n_elem
0028     move = reshape( ...
0029         img.elem_data( fwdp.n_elem+(1:fwdp.n_elec*fwdp.n_dims) ), ...
0030         fwdp.n_elec, fwdp.n_dims);
0031     img.elem_data = img.elem_data(1:fwdp.n_elem);    
0032 end
0033 
0034 % Plot FEM with conductivity elements with or without colourbars
0035 show_fem(img, options); % Show colourbar
0036 
0037 % Plot movement vectors on electrodes
0038 if ~isempty(move)
0039     % Group all electrode node indicies into a single vector
0040     e_nodes = cell2mat({img.fwd_model.electrode(:).nodes});
0041     
0042     % Keep only electrode node movement coordinates
0043     if size(move,1) == fwdp.n_node;
0044         move = move(e_nodes,:);
0045     end
0046     move = move- ones(size(move,1),1)*mean(move);
0047     
0048     % Render movement arrows for each electrode
0049     hold on;
0050     if nargin < 3
0051         scale = 20;
0052     end
0053     nodes = img.fwd_model.nodes;
0054     hh = working_quiver(nodes(e_nodes,1), nodes(e_nodes,2), ...
0055         scale*move(:,1), scale*move(:,2), 0 );
0056     set(hh,'Color', [0,.3,0], 'LineWidth', 2, 'Clipping', 'off');
0057     hold off;
0058 end
0059 % Format output figure
0060 axis('off'); 
0061 axis('image'); 
0062 axis(1.3*[-1,1,-1,1]);
0063 
0064 function hh= working_quiver( varargin )
0065 % WORKING_QUIVER   Matlab has made a completely imcompatible
0066 % quiver function which you can't call properly with different
0067 % versions of matlab.
0068 
0069 v = version;
0070 octave = exist('OCTAVE_VERSION') | str2num(v(1)) < 7 | str2num(v(1:3)) >= 7.8;
0071 if octave
0072     hh = quiver( varargin{:} );
0073 else
0074     hh = quiver('v6', varargin{:} );
0075 end

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