avw_stats - calculate region of interest stats for avw data [stat] = avw_stats(stat) stat is a struct with the following fields: stat.roi - a region of interest from avw.img, see avw_roi. stat.function - cell array of strings, which can be any matlab descriptive stats function. The defaults are: {'mean','std','min','max','median','sum'} For example, stat.roi.value = avw.img(1:10,1:10,1:10); stat.function = {'mean'}; stat.value - output array of stats values, with length(stat.function). see also avw_roi
0001 function [stat] = avw_stats(stat) 0002 0003 % avw_stats - calculate region of interest stats for avw data 0004 % 0005 % [stat] = avw_stats(stat) 0006 % 0007 % stat is a struct with the following fields: 0008 % 0009 % stat.roi - a region of interest from avw.img, see avw_roi. 0010 % 0011 % stat.function - cell array of strings, which can be any matlab 0012 % descriptive stats function. The defaults are: 0013 % {'mean','std','min','max','median','sum'} 0014 % 0015 % For example, 0016 % 0017 % stat.roi.value = avw.img(1:10,1:10,1:10); 0018 % stat.function = {'mean'}; 0019 % 0020 % stat.value - output array of stats values, with length(stat.function). 0021 % 0022 % see also avw_roi 0023 % 0024 0025 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $ 0026 0027 % Licence: GNU GPL, no express or implied warranties 0028 % History: 08/2003, Darren.Weber_at_radiology.ucsf.edu 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 0033 version = '[$Revision: 1.1 $]'; 0034 fprintf('\nAVW_STATS [v%s]\n',version(12:16)); tic; 0035 0036 if ~exist('stat','var'), 0037 msg = sprintf('...no input stat struct.\n'); 0038 error(msg); 0039 end 0040 if ~isfield(stat,'function'), 0041 fprintf('...no input stat.function, using defaults.\n'); 0042 stat.function = {'mean','std','min','max','median','sum'}; 0043 elseif isempty(stat.function), 0044 fprintf('...empty input stat.function, using defaults.\n'); 0045 stat.function = {'mean','std','min','max','median','sum'}; 0046 end 0047 0048 0049 stat.value = zeros(1,length(stat.function)); 0050 0051 for i = 1:length(stat.function), 0052 0053 tmp = feval(stat.function{i},stat.roi.value); 0054 0055 while length(tmp) > 1, 0056 tmp = feval(stat.function{i},tmp); 0057 end 0058 stat.value(i) = tmp; 0059 0060 end % stat roi 0061 0062 stat 0063 0064 return