% tool
% 
%   INPUT VALUES:
%  
%   RETURN VALUE:
%
% 
% (c) 2003-2008, University of Cambridge, Medical Research Council 
% Maintained by Tom Walters (tcw24@cam.ac.uk), written by Stefan Bleeck (stefan@bleeck.de)
% http://www.pdn.cam.ac.uk/cnbh/aim2006
% $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $
% $Revision: 585 $

function width=getmaxwidth(wo,maxpos,minpos,maxs,mins)
% usage: width=getmaxwidth(wo,frewomax,fremaxs,frewomin,fremins)
% returns the width of the maximum
% this is calculated by taking the left and the right minimum of the max

[leftminwo,val]=getminimumleftof(wo,maxpos,minpos,maxs,mins);
if isempty(leftminwo)
    % wenns keinen linkes minimum gibt, versuche, obs ein rechtes gibt
    [rightminwo,rightmin]=getminimumrightof(wo,maxpos,minpos,maxs,mins);
    if ~isempty(rightminwo)
        leftminwo=rightminwo;
    else
        leftminwo=0;
    end
end

[rightminwo,val]=getminimumrightof(wo,maxpos,minpos,maxs,mins);
if isempty(rightminwo)
    rightminwo=leftminwo;
end

width=abs((leftminwo+rightminwo)/2);

