function fig = PLviewautoID(action, varargin)

if nargin<1,
  action='InitializePLviewautoID';
end;

feval(action,varargin{:});
return;

%%%
%%%   Sub-function - InitializePLviewautoID
%%%

function InitializePLviewautoID()

%First get information from calling window 
%if it exists
h=gcbf;
if ~isempty(h),
    oh=findobj(h,'tag','PopupMenu Disc');
    autoiddrives=get(oh,'string');
    valueautoiddrive=get(oh,'value');
    oh=findobj(h,'tag','PopupMenu Folder');
    autoidfolders=get(oh,'string');
    valueautoidfolder=get(oh,'value');
    oh=findobj(h,'tag','PopupMenu Cruise');
    cruises=get(oh,'string');
    valuecruise=get(oh,'value');
    oh=findobj(h,'tag','PopupMenu GetClassifier');
    classifiers=get(oh,'string');
    valueclassifier=get(oh,'value');
else
    autoiddrives=str2mat(getdrives('-nofloppy'));
    autoiddrives=str2mat('Select',autoiddrives);
    valueautoiddrive=1;
    valueautoidfolder=1;
    valuecruise=1;
    valueclassifier=1;
end

redgreenblue=[0.2157 .6353 .6353]*1.2;

h0 = figure('Units','normalized', ...
	'Color',[redgreenblue], ...
	'Colormap','default', ...
	'FileName','c:\plgui\mygui\PLviewautoID.m', ...
	'MenuBar','none', ...
	'Name','VPR   View AutoID', ...
	'NumberTitle','off', ...
	'PaperPosition',[18 180 576 432], ...
	'PaperUnits','points', ...
	'Position',[0.0059 0.3802 0.2598 0.5443], ...
	'Tag','VPR View AutoID', ...
	'ToolBar','none');
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'ListboxTop',0, ...
	'Position',[0.086 0.053 0.808 0.899], ...
	'Style','frame', ...
	'Tag','Frame1');

%SELECT DISPLAY ROWS X COLUMNS
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.293 0.837 0.173 0.041], ...
	'String','Display', ...
	'Style','text', ...
	'Tag','StaticText Display', ...
	'TooltipString','Select # Rows x Columns of ROIs to Display');
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.835 0.351 0.053], ...
	'String',str2mat('3x3','4x4','5x5','7x7','10x10'), ...
	'fontunits','normalized','fontsize',.4, ...
    'value',3, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu Display', ...
	'TooltipString','Select # Rows x Columns of ROIs to Display') ;

%SELECT AUTOID DRIVE LETTER
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.188 0.777 0.293 0.041], ...
	'String','AutoID Drive', ...
	'Style','text', ...
	'Tag','StaticText AutoID Drive', ...
	'TooltipString','Select AutoID Drive Letter');
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Callback','PLviewautoID GetAutoIDFolders', ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.772 0.351 0.053], ...
	'String',autoiddrives, ...
    'value',valueautoiddrive, ...
	'fontunits','normalized','fontsize',.4, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu AutoID Drive', ...
	'TooltipString','Select AutoID Drive Letter') ;

%SELECT AUTOID BASE FOLDER
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.154 0.712 0.323 0.041], ...
	'String','AutoID Folder', ...
	'Style','text', ...
	'Tag','StaticText AutoID Folder', ...
	'TooltipString','Select AutoID Base Folder');
if ~isempty(h),
  h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.504 0.712 0.351 0.053], ...
    'Callback','PLviewautoID GetCruises', ...
	'String',autoidfolders, ...
    'value',valueautoidfolder, ...
	'fontunits','normalized','fontsize',.4, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu AutoID Folder', ...
	'TooltipString','Select AutoID Base Folder') ;
end


%SELECT ROI DRIVE LETTER

roidrives=str2mat(getdrives('-nofloppy'));
roidrives=str2mat('Select',roidrives);
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.244 0.655 0.229 0.041], ...
	'String','ROI Drive', ...
	'Style','text', ...
	'Tag','StaticText ROI Drive', ...
	'TooltipString','Select Drive Letter where ROIs are located');
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'Callback','PLviewautoID GetRoiFolders', ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.647 0.351 0.053], ...
	'String',roidrives, ...
    'value',1, ...
	'fontunits','normalized','fontsize',.4, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu ROI Drive', ...
	'TooltipString','Select Drive Letter where ROIs are located') ;

%SELECT ROI BASE FOLDER
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.214 0.59 0.259 0.041], ...
	'String','ROI Folder', ...
	'Style','text', ...
	'Tag','StaticText ROI Folder', ...
	'TooltipString','Select ROI Base Folder');

%SELECT Cruise
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.297 0.525 0.169 0.041], ...
	'String','Cruise', ...
	'Style','text', ...
	'Tag','StaticText Cruise', ...
	'TooltipString','Select Cruise');
if ~isempty(h),
  h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.523 0.351 0.053], ...
    'Callback','PLviewautoID GetClassifier', ...
	'String',cruises, ...
    'value',valuecruise, ...
	'fontunits','normalized','fontsize',.4, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu Cruise', ...
	'TooltipString','Select Cruise') ;
end

%SELECT Classifier
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.241 0.46 0.233 0.041], ...
	'String','Classifier', ...
	'Style','text', ...
	'Tag','StaticText Classifier', ...
	'TooltipString','Select Classifier');
if ~isempty(h),
  h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[1 1 1], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.46 0.351 0.053], ...
    'Callback','PLviewautoID GetTaxon', ...
	'String',classifiers, ...
    'value',valueclassifier, ...
	'fontunits','normalized','fontsize',.4, ...
	'FontWeight','normal', ...
	'Style','popupmenu', ...
	'Tag','PopupMenu Classifier', ...
	'TooltipString','Select Classifier') ;
end

%SELECT Taxon
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.327 0.398 0.124 0.041], ...
	'String','Taxon', ...
	'Style','text', ...
	'Tag','StaticText Taxon', ...
	'TooltipString','Select Taxon to View');

%SELECT Yearday
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.263 0.333 0.199 0.041], ...
	'String','Yearday', ...
	'Style','text', ...
	'Tag','StaticText Yearday', ...
	'TooltipString','Select Yearday');

%SELECT Hour
h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[redgreenblue]*1.1, ...
	'fontunits','normalized','fontsize',.7, ...
	'FontWeight','normal', ...
	'ListboxTop',0, ...
	'Position',[0.35 0.269 0.113 0.041], ...
	'String','Hour', ...
	'Style','text', ...
	'Tag','StaticText Hour', ...
	'TooltipString','Select Hour');


if nargout > 0, fig = h0; end


function GetAutoIDFolders(fig)

if nargin<1,
   h=gcbf;
else
   h=fig;
end;

if ~isempty(h)
  %delete existing popups
  h1=findobj(h,'Tag','PopupMenu AutoID Folder'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Cruise'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Classifier'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Taxon'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Yearday'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  %find folders
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  folders=dir(disc);
  folderarray=str2mat(folders.name);
  folderarray=lower(folderarray([folders.isdir]',:));
  sz=size(folderarray,1);
  if sz>2,    
     folderarray=sortrows(folderarray(3:sz,:));
     folderarray=str2mat('Select',folderarray);
     h1 = uicontrol('Parent',h, ...  
          'Units','normalized', ...
          'BackgroundColor',[1 1 1], ...
          'ListboxTop',0, ...
          'Position',[0.5 0.712 0.351 0.053], ...
          'Callback','PLviewautoID GetCruises', ...
          'String',folderarray, ...
	      'fontunits','normalized','fontsize',.4, ...
	      'FontWeight','normal', ...
          'max',sz+1, ...
          'min',1, ...
          'Style','popupmenu', ...
          'Tag','PopupMenu AutoID Folder', ...
          'TooltipString','Select Folder', ...
          'Value',1);
  end
end

function GetRoiFolders(fig)

if nargin<1,
   h=gcbf;
else
   h=fig;
end;

if ~isempty(h)
  %delete existing popups
  h1=findobj(h,'Tag','PopupMenu RoiFolder'); delete(h1);
  %find folders
  h1=findobj(h,'Tag','PopupMenu ROI Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  folders=dir(disc);
  folderarray=str2mat(folders.name);
  folderarray=lower(folderarray([folders.isdir]',:));
  sz=size(folderarray,1);
  if sz>2,
     folderarray=sortrows(folderarray(3:sz,:));
     folderarray=str2mat('Select',folderarray);
     h1 = uicontrol('Parent',h, ...
          'Units','normalized', ...
          'BackgroundColor',[1 1 1], ...
          'ListboxTop',0, ...
          'Position',[0.5 0.585 0.351 0.053], ...
          'String',folderarray, ...
	      'fontunits','normalized','fontsize',.4, ...
	      'FontWeight','normal', ...
          'max',sz+1, ...
          'min',1, ...
          'Style','popupmenu', ...
          'Tag','PopupMenu ROI Folder', ...
          'TooltipString','Select Folder', ...
          'Value',1);
  end
end

function GetCruises(fig)

if nargin<1,
   h=gcbf;
else
   h=fig;
end;

if ~isempty(h)
  %delete existing popups
  h1=findobj(h,'Tag','PopupMenu Cruise'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Classifier'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Taxon'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Yearday'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  %find cruises
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu AutoID Folder');
  dummystring=get(h1,'String');v=get(h1,'value');
  folder=deblank(dummystring(v,:));
  basepath=[disc folder];
  cruises=dir(basepath);
  cruisearray=str2mat(cruises.name);
  sz=size(cruisearray,1);
  if sz>2,    
     cruisearray=sortrows(cruisearray(3:sz,:));
     cruisearray=str2mat('Select',cruisearray);
     h1 = uicontrol('Parent',h, ...  
          'Units','normalized', ...
          'BackgroundColor',[1 1 1], ...
          'Callback','PLviewautoID GetClassifier', ...
          'ListboxTop',0, ...
          'Position',[0.5 0.523 0.351 0.053], ...
          'String',cruisearray, ...
	      'fontunits','normalized','fontsize',.4, ...
	      'FontWeight','normal', ...
          'max',sz+1, ...
          'min',1, ...
          'Style','popupmenu', ...
          'Tag','PopupMenu Cruise', ...
          'TooltipString','Select Cruise', ...
          'Value',1);
  end
end


function GetClassifier
h=gcbf; 
if ~isempty(h)
  %delete existing GetClassifier popup
  h1=findobj(h,'Tag','PopupMenu Classifier'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Taxon'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Yearday'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu AutoID Folder');
  dummystring=get(h1,'String');v=get(h1,'value');
  folder=deblank(dummystring(v,:));
  basepath=[disc folder];
  h1=findobj(h,'Tag','PopupMenu Cruise');
  dummystring=get(h1,'String');v=get(h1,'value');
  cruise=deblank(dummystring(v,:));
  classifiers=dir([basepath, filesep, cruise, filesep,'clpar\*nn.mat']);
  datarray=str2mat(classifiers.name);
  sd=size(datarray,1);
  if sd>0,    
     datarray=datarray(1:sd,:);
     datarray=sortrows(datarray);
     for j=1:sd,
         k=findstr('nn.mat',datarray(j,:));
         datarray(j,k:end)=' ';
     end
     datarray=str2mat('Select',datarray);
     h1 = uicontrol('Parent',h, ...  
          'Units','normalized', ...
          'BackgroundColor',[1 1 1], ...
          'Callback','PLviewautoID GetTaxon', ...
          'ListboxTop',0, ...
          'Position',[0.5 0.46 0.351 0.053], ...
          'String',datarray, ...
	      'fontunits','normalized','fontsize',.4, ...
	      'FontWeight','normal', ...
          'max',sd, ...
          'min',1, ...
          'Style','popupmenu', ...
          'Tag','PopupMenu Classifier', ...
          'TooltipString','Select classifier', ...
          'Value',1);
  end
end


function GetTaxon
h=gcbf; 
if ~isempty(h)
  %delete existing GetClassifier popup
  h1=findobj(h,'Tag','PopupMenu Taxon'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Yearday'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  %do the following because it may take a while to get the taxa info
  h1_working = uicontrol('Parent',h, ...
      'Units','normalized', ...
      'BackgroundColor',[0.2157 .6353 .6353]*1.2*1.1, ...
      'ForegroundColor',[1 1 0], ...
      'fontunits','normalized','fontsize',.7, ...
      'FontWeight','bold', ...
      'Position',[0.5 0.396 0.3 0.041], ...
      'String','Working...', ...
      'Style','text', ...
      'Tag','StaticText Working', ...
      'TooltipString','Getting list of Taxa');
  drawnow;
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu AutoID Folder');
  dummystring=get(h1,'String');v=get(h1,'value');
  folder=deblank(dummystring(v,:));
  basepath=[disc folder];
  h1=findobj(h,'Tag','PopupMenu Cruise');
  dummystring=get(h1,'String');v=get(h1,'value');
  cruise=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Classifier');
  dummystring=get(h1,'String');v=get(h1,'value');
  classifier=deblank(dummystring(v,:));
  taxa1=dir([basepath, filesep, cruise, filesep,'autoid']);
  datarray=str2mat(taxa1.name);%some taxa here may be from other classifiers
  sd=size(datarray,1);
  if sd>2,
      taxa2=[];
      for j = 3:sd,%check for taxa having the right classifier aid files
          dum=dir([basepath '\' cruise '\autoid\' deblank(datarray(j,:)) '\aid\' classifier 'aid.*']);
          if ~isempty(dum),%at least one aid file was found in this taxon for the specified classifier
              if j==3,
                  taxa2=deblank(datarray(j,:));%taxa2 has good taxa
              else
                  taxa2=strvcat(taxa2,deblank(datarray(j,:)));%taxa2 has good taxa
              end
          end
      end
  end;
  datarray=taxa2;
  datarray=sortrows(datarray);
  datarray=str2mat('Select',datarray);
  sd=size(datarray,1);
  set(h1_working,'visible','off');
  h1 = uicontrol('Parent',h, ...  
      'Units','normalized', ...
      'BackgroundColor',[1 1 1], ...
      'Callback','PLviewautoID GetYearday', ...
      'ListboxTop',0, ...
      'Position',[0.5 0.396 0.351 0.053], ...
      'String',datarray, ...
      'fontunits','normalized','fontsize',.4, ...
      'FontWeight','normal', ...
      'max',sd, ...
      'min',1, ...
      'Style','popupmenu', ...
      'Tag','PopupMenu Taxon', ...
      'TooltipString','Select Taxon', ...
      'Value',1);
end

function GetYearday
h=gcbf; 
if ~isempty(h)
  %delete existing Yearday and Hour popups
  h1=findobj(h,'Tag','PopupMenu Yearday'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu AutoID Folder');
  dummystring=get(h1,'String');v=get(h1,'value');
  folder=deblank(dummystring(v,:));
  basepath=[disc folder];
  h1=findobj(h,'Tag','PopupMenu Cruise');
  dummystring=get(h1,'String');v=get(h1,'value');
  cruise=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Classifier');
  dummystring=get(h1,'String');v=get(h1,'value');
  classifier=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Taxon');
  dummystring=get(h1,'String');v=get(h1,'value');
  taxon=deblank(dummystring(v,:));
  aa=dir([basepath,'\',cruise,'\autoid\',taxon,'\aid\',classifier,'aid.*']);
  bb=str2mat(aa.name);
  sbb=size(bb,2);
  cc=sort(str2num(bb(:,sbb-6:sbb-4)));
  dd=cc(2:length(cc));
  yeardays=num2str([cc(1);dd(find(diff(cc)>0))]);
  yeardays((yeardays(:,1)==' '),1)='0';
  if (size(yeardays,2)==2),%this pads yeardays w/ leading zero if only 2 digits
      yeardays=[num2str(zeros(size(yeardays,1),1)),yeardays];
  end
  datarray=yeardays;
  datarray=str2mat('Select',datarray);
  sd=size(datarray,1);
  h1 = uicontrol('Parent',h, ...  
      'Units','normalized', ...
      'BackgroundColor',[1 1 1], ...
      'Callback','PLviewautoID GetHour', ...
      'ListboxTop',0, ...
      'Position',[0.5 0.329 0.351 0.053], ...
      'String',datarray, ...
      'fontunits','normalized','fontsize',.4, ...
      'FontWeight','normal', ...
      'max',sd, ...
      'min',1, ...
      'Style','popupmenu', ...
      'Tag','PopupMenu Yearday', ...
      'TooltipString','Select Yearday', ...
      'Value',1);
end


function GetHour
h=gcbf; 
if ~isempty(h)
  %delete existing Hour popup and start pushbutton
  h1=findobj(h,'Tag','PopupMenu Hour'); delete(h1);
  h1=findobj(h,'Tag','PushButton StartViewAutoID'); delete(h1);
  h1=findobj(h,'Tag','PopupMenu AutoID Drive');
  dummystring=get(h1,'String');v=get(h1,'value');
  disc=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu AutoID Folder');
  dummystring=get(h1,'String');v=get(h1,'value');
  folder=deblank(dummystring(v,:));
  basepath=[disc folder];
  h1=findobj(h,'Tag','PopupMenu Cruise');
  dummystring=get(h1,'String');v=get(h1,'value');
  cruise=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Classifier');
  dummystring=get(h1,'String');v=get(h1,'value');
  classifier=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Taxon');
  dummystring=get(h1,'String');v=get(h1,'value');
  taxon=deblank(dummystring(v,:));
  h1=findobj(h,'Tag','PopupMenu Yearday');
  dummystring=get(h1,'String');v=get(h1,'value');
  yearday=deblank(dummystring(v,:));
  aa=dir([basepath,'\',cruise,'\autoid\',taxon,'\aid\',classifier,'aid.d' yearday '.*']);
  bb=str2mat(aa.name);
  bb=bb([aa.bytes]'~=0,:);%only lists non-empty aid files
  sbb=size(bb,2);
  cc=sort(str2num(bb(:,sbb-1:sbb)));
  hours=num2str(cc);
  datarray=hours;
  datarray=str2mat('Select',datarray);
  sd=size(datarray,1);
  h1 = uicontrol('Parent',h, ...  
      'Units','normalized', ...
      'BackgroundColor',[1 1 1], ...
      'Callback','PLviewautoID StartViewAutoID', ...
      'ListboxTop',0, ...
      'Position',[0.5 0.266 0.351 0.053], ...
      'String',datarray, ...
      'fontunits','normalized','fontsize',.4, ...
      'FontWeight','normal', ...
      'max',sd, ...
      'min',1, ...
      'Style','popupmenu', ...
      'Tag','PopupMenu Hour', ...
      'TooltipString','Select Hour', ...
      'Value',1);
end


function StartViewAutoID
h=gcbf; 
redgreenblue=get(h,'color');
if ~isempty(h)
    h1 = uicontrol('Parent',h, ...  
        'Units','normalized', ...
        'BackgroundColor',[redgreenblue]*1.1, ...
        'Callback','ViewAutoID', ...
        'Position',[0.293 0.129 0.429 0.058], ...
        'String','View AutoID ROIs', ...
        'fontunits','normalized','fontsize',.528, ...
        'FontWeight','normal', ...
        'Style','pushbutton', ...
        'Tag','PushButton StartViewAutoID', ...
        'TooltipString','Push to view and/or manually re-sort AutoID ROIs');
end


