function [xo, yo] = fsi_select;

% Brian Schlining
% 31 Jul 2000

figH = findobj('Tag', 'fsi_slicexy');

lH = findobj('Tag', 'nav');
X = get(lH, 'XData');
Y = get(lH, 'YData');

[rx cx] = size(X);
[ry cy] = size(Y);
if (rx > 1 & cx > 1)
   error('  GETPTS: Input X can not be a matrix')
end
if (ry > 1 & cy > 1)
   error('  GETPTS: Input Y can not be a matrix') 
end
if (ry ~= rx) | (cy ~= cx)
   error('  GETPTS: Input X and Y must be the same size')
end
if rx > 1
   xy = [X Y];
else
   xy = [X;Y]';
end

button = 0;
OK     = 1;
NextPlotFig = get(gcf,'NextPlot');
NextPlotAxe = get(gca,'NextPlot');
set(gcf,'NextPlot','add');
set(gca,'NextPlot','add');
n = 0;
flag = 0;
h = 0;

while OK 
   
   [x,y,button] = ginput(1);
   if isempty(button)
      button = -1;
   end
   
   figH = findobj('Tag', 'fsi_slicexy');
   if isempty(figH)
      xo = NaN;
      yo = NaN;
      OK = 0;
   end
   
   switch button
      
   case 1
      if h ~= 0
         delete(h);
      end
      h      = plot(x, y,'go');
      tmppts = [x y]; %store the points in case the're it
      flag = 1;
   case 3
      if flag
         set(h,'Marker','x','Color',[1 0 0],'MarkerSize',8);
         OK = 0;
         h = 0;
      end
   otherwise
      OK = 0;
   end
end

xo = tmppts(1);
yo = tmppts(2);

set(gcf,'NextPlot',NextPlotFig);
set(gca,'NextPlot',NextPlotAxe);


