Home > polypedal > cartperturb > topTrackStats.m

topTrackStats

PURPOSE ^

topTrackStats Generate statistics of top marker motion from track data

SYNOPSIS ^

function [] = topTrackStats( filestring )

DESCRIPTION ^

 topTrackStats Generate statistics of top marker motion from track data
   topTrackStats( filestring )
 INPUT:
 (required)
   filestring -- string -- argument to dir command specifying files,
     e.g. 'mov/*-top-track.mat' or 'mov/20080806-1511-r4-top-track.mat'

 Generates statistics describing top marker trajectories:
  * covariance matrix
  * trajectory discontinuities
 
 $Revision: 1.2 $
 By Sam Burden, Berkeley 2008

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [] = topTrackStats( filestring )
0002 % topTrackStats Generate statistics of top marker motion from track data
0003 %   topTrackStats( filestring )
0004 % INPUT:
0005 % (required)
0006 %   filestring -- string -- argument to dir command specifying files,
0007 %     e.g. 'mov/*-top-track.mat' or 'mov/20080806-1511-r4-top-track.mat'
0008 %
0009 % Generates statistics describing top marker trajectories:
0010 %  * covariance matrix
0011 %  * trajectory discontinuities
0012 %
0013 % $Revision: 1.2 $
0014 % By Sam Burden, Berkeley 2008
0015 
0016 % Parse arguments
0017 if nargin < 1
0018     error('Must specify a filestring, e.g. ''mat/*-top-track.mat'' or ''mat/20080806-1511-r4-top-track.avi''.');
0019     endnn
0020 end
0021 
0022 % Get list of files
0023 files = dir(filestring);
0024 
0025 % Get directory containing files
0026 d = strfind(filestring,'/');
0027 directory = filestring(1:d(end));
0028 
0029 % Loop over files
0030 for f = 1:length(files)
0031     
0032   % If file name contains directory, remove it
0033   d = strfind(files(f).name,'/');
0034   if ~isempty(d)
0035       files(f).name = files(f).name(d(end)+1:end);
0036   end
0037     
0038   % Get file name prefix
0039   prefix = strtok(files(f).name,'.');
0040 
0041   % If [prefix]-top-track.mat exists
0042   if exist([directory,prefix,'.mat'],'file')
0043         
0044     disp(['Creating top marker statistics for ',directory,prefix,'.mat . . .']);
0045 
0046     % Load top track data
0047     load([directory,prefix,'.mat'],'top');
0048 
0049     % Empirically compute covariance matrix from the good track data
0050 %     for i = [1 4 5 6 8 9]
0051 %       x{i} = top.trackF{i}.state;
0052 %       N = size(x{i},2);
0053 %       x{i} = x{i} - repmat(mean(x{i},2),1,N);
0054 %       K{i} = (1/(N-1))*(x{i} * x{i}');
0055 %     end
0056 %     Q = cat(3,K{:});
0057 %     Qm = mean(Q,3);
0058 %     Qstd = std(Q,1,3);
0059 
0060     e = [];
0061     for i = [1 4 5 6 8 9]
0062       x{i} = top.trackF{i}.state';
0063       E = diff(diff(x{i}));
0064       e(i,:) = sqrt(diag(E'*E))';
0065     end
0066     
0067 
0068     % Look at statistics of adjacent positions for the good track data
0069     dx = [];
0070     for i = [1 4 5 6 8 9]
0071       x{i} = top.trackF{i}.traj;
0072       dx = [dx; diff(x{i})];
0073     end
0074     dx(find(isnan(dx))) = [];
0075     
0076     figure;
0077     subplot(2,1,1);
0078     qqplot(real(dx));
0079     title('Good X coordinate QQPlot');
0080     subplot(2,1,2);
0081     qqplot(imag(dx));
0082     title('Good Y coordinate QQPlot');
0083     
0084     disp(['std_x = ',num2str(std(real(dx))),', std_y = ',num2str(std(imag(dx)))]);
0085         
0086         keyboard
0087     
0088     % Look at statistics of adjacent positions for all the track data
0089     dx = [];
0090     for i = 1:length(top.trackF)
0091       x{i} = top.trackF{i}.traj;
0092       dx = [dx; diff(x{i})];
0093     end
0094     dx(find(isnan(dx))) = [];
0095     
0096     figure;
0097     subplot(2,1,1);
0098     qqplot(real(dx));
0099     title('X coordinate QQPlot');
0100     subplot(2,1,2);
0101     qqplot(imag(dx));
0102     title('Y coordinate QQPlot');
0103     
0104     disp(['std_x = ',num2str(std(real(dx))),', std_y = ',num2str(std(imag(dx)))]);
0105         
0106         keyboard
0107         
0108     
0109   end
0110   
0111 end

Generated on Mon 02-Aug-2010 16:44:38 by m2html © 2003