% reProc
action = get(gcbo,'Tag');
comp=computer;
switch action

   case 'UseCurrentMarks'
      reProc.UseCM = get(gcbo,'Value');
   case 'BadRecFileBrowse'
      filterSpec = [ TSd{ii}.DataDir 'BR/*.bad'];
      [fileName,pathName] = uigetfile(filterSpec,'Bad record file name');
      pathName=strrep(pathName,'\','/');
      reProc.File = [ pathName fileName ];
   case 'BadRecFileName'
      reProc.File = get(gcbo,'String');
   case 'ReProcess MMT'
      reProc.MMT = get(gcbo,'Value');
   case 'ReProcess MTR'
      reProc.MTR = get(gcbo,'Value');
   case 'RunReProcess'

      %%%%job = mod(reProc.MTR+2*reProc.MMT,3) ; %%%%%%
      %%% I am changing job to comply with new reProc options %%%%
      %%% but only old options are available from MATLAB for now %%
      %%%                                    Lana, Aug 5, 2005 %%%%
      job = [ '-j0' num2str(reProc.MTR) num2str(reProc.MMT)];
      ii = reProc.iFig;
      if(reProc.UseCM)
        wrBadRec(reProc.File,TSw{ii}.T12,TSd{ii}.dt); 
      end
      D = num2str(TSd{ii}.arrayID);
      Y = ['-o' num2str(TSd{ii}.SubDir)]; %% Lana, Aug 5
      S='-s';
      tmp=TSd{ii}.SITES;
      S=['-s' char(tmp{1})];
      for l=2:length(tmp)
       S = [S ',' char(tmp{l})];
      end
      f = round(1./TSd{ii}.dt);
      if f~=40,f=1;end %%% only 1Hz and 40Hz from matlab fro re-processing
      f=['-b' num2str(f)]; 
      %%%%%%%%j = num2str(job);
      brFile = ['-B' reProc.File];
      suffix = ['-x' reProc.suffix];
%       might want to add browse/text edit objects to allow changing
%       this in reProc window
      STR = ['reProc ' D ' ' Y ' ' S ' ' brFile ' ' suffix ' ' job ' ' f '&'];
      fprintf ('%s\n',STR);
      delete(reProc.Fig)
      
      if comp(1:4)=='PCWI',
        STR=['bash -c -l "' PKDSAOhome SLASH 'bin' SLASH STR ];
        system(STR);
      else
        eval(['!' STR]);
      end
      fprintf('Do not try to re-process again untill message of\n');
      fprintf('reprocessing completion appears...wait...\n'); 
   case 'SetSuffix'
      reProc.suffix = get(gcbo,'String');
   case 'CancelReProcess'
      delete(reProc.Fig)
end
