function [avg,med,stdev,minimum,maximum]=get_stats(volume);
% function [avg,med,stdev,minimum,maximum]=get_stats(volume);
%  volume : matrix or minc-file (no time frames supported);

% ---------------------------------
% Copyright (c) 2003 Serge Dumoulin
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License version 2
% as published by the Free Software Foundation.
% ---------------------------------


if ischar(volume), %assume mincvolume
   h=openimage(deblank(volume));
   frames=getimageinfo(h,'NumFrames');
   if frames > 0,
      disp(sprintf('Volumes with tmp dimension not yet supported.'));
      return;
   end;
   ns=getimageinfo(h,'NumSlices');
   volume=getimages(h,1:ns);
   closeimage(h);
end;

v2=sort(reshape(volume,prod(size(volume)),1));

med=median(v2);
avg=mean(v2);
stdev=std(v2);
minimum=min(v2);
maximum=max(v2);