// reset_ahYX: reset functions for the sequence ahYX.c

//             1. par2D is always executed.
//             2. Create BioPack globals

par2D

exists('investigator','parameter','global'):$e
if $e < 0.5 then
   create('investigator','string','global')
   investigator=''
endif 

exists('notebook','parameter'):$e
if $e < 0.5 then
   create('notebook','string','global')
   notebook=''
endif 

exists('page','parameter'):$e
if $e < 0.5 then
   create('page','string','global')
   page=''
endif 

"parCS - add parameters for Compressive Sensing options, EK, Oxford 17/02/2011 "

$curdir=''
exists('ni','parameter'):$e
if not ($e) then  
  return     "make no changes for 1D parameter sets "
else
  exists('nimax','parameter'):$e
  if not ($e) then
   create('nimax','integer')
   nimax=0
  endif
endif

exists('ni2','parameter'):$e
if($e) then
  exists('ni2max','parameter'):$e
  if not ($e) then
   create('ni2max','integer')
   ni2max=0
  endif
endif

exists('ni3','parameter'):$e
if($e) then
  exists('ni3max','parameter'):$e
  if not ($e) then
   create('ni3max','integer')
   ni3max=0
  endif
endif

exists('SPARSE','parameter'):$e 
if not ($e) then 
  create('SPARSE','flag') 
  SPARSE='n'  
endif

exists('skey','parameter'):$e 
if not ($e) then 
  create('skey','real') 
  skey=169  " seed parameter "
endif

exists('stype','parameter'):$e 
if not ($e) then 
  create('stype','flag') 
  stype='a'
endif

exists('CSlines','parameter'):$e 
if not ($e) then 
  create('CSlines','integer') 
  CSlines=4  " number of lines to print "
endif

exists('CSdensity','parameter'):$e 
if not ($e) then 
  create('CSdensity','real') 
  CSdensity=100.0  " sampling density "
endif

exists('CSwp','parameter'):$e 
if not ($e) then 
  create('CSwp','integer') 
  setgroup('CSwp','processing')
  CSwp=0  " region of interest "
endif

exists('CSsp','parameter'):$e 
if not ($e) then 
  create('CSsp','integer') 
  setgroup('CSsp','processing')
  CSsp=0  " region of interest "
endif

exists('CS_se','parameter'):$e 
if not ($e) then 
  create('CS_se','flag') 
  setgroup('CS_se','processing')
  CS_se='n'  " flag for sensitivity enhanced data "
endif

exists('CS_inf','parameter'):$e 
if not ($e) then 
  create('CS_inf','flag') 
  setgroup('CS_inf','processing')
  CS_inf='n'  " flag for inflated data "
endif

exists('BP_SPARSEproc','parameter'):$e 
if not ($e) then 
  create('BP_SPARSEproc','string') 
  setgroup('BP_SPARSEproc','processing')
  BP_SPARSEproc='CLEAN'  " flag for CLEAN processing "
endif

exists('CS_cln','parameter'):$e 
if not ($e) then 
  create('CS_cln','flag') 
  setgroup('CS_cln','processing')
  CS_cln='n'  " flag for CLEAN processing "
endif

exists('CS_dpars','parameter'):$e 
if not ($e) then 
  create('CS_dpars','flag') 
  setgroup('CS_dpars','processing')
  CS_dpars='n'  " flag for default processing functions "
  exists('ni2','parameter'):$e
  if($e) and (ni>1) then
    if(ni2>1) then
      CS_dpars='y'
    endif
  endif
endif

exists('CSdnoise','parameter'):$e 
if not ($e) then 
  create('CSdnoise','flag') 
  setgroup('CSdnoise','processing')
  CSdnoise='n'  " de-noising flag "
endif

exists('CSthr','parameter'):$e 
if not ($e) then          " processing threshold level "
  create('CSthr','real') 
  setgroup('CSthr','processing')
  setlimit('CSthr',100.0,1.0,0.1)
  CSthr=2.0  
  exists('ni2','parameter'):$e
  if($e) then
    if(ni>1) and (ni2>1) then 
      CSthr=4.0
    endif
  endif
endif

$sch=''
$sch = curexp+'/acqfil/sampling.sch' 
exists($sch,'file'):$e 
if ($e) then 
  rm($sch)
endif

// Add Parameters for NMR Pipe Script Control. 

$Spars='BPpipe_controls','n',\
       'BPpipe_editor','gedit',\
       'BPpipe_fidscript','vj_fid.com', \
       'BPpipe_XYscript', 'vj_xy_user.com',\
       'BPpipe_XZscript','vj_xz_user.com',\
       'BPpipe_3Dscript','vj_xyz_user.com',\
       'BPpipe_strips_script','vj_scroll_user.com',\
       'BPpipe_4Dscript','vj_xyza_user.com',\
       'BPpipe_pipeDir','pipe',\
       'BPpipe_solids','y',\
       'BPpipe_fidDir','acqfil/fid',\
       'BPpipe_par','curpar',\
       'BPpipeSOL','n' 
            
$nSpars=size('$Spars')
$i=1
while ($i<$nSpars) do
   exists($Spars[$i],'parameter'):$e       
   if not $e then
      create($Spars[$i],'string') 
      setprotect( $Spars[$i] ,'on',256) 
      {$Spars[$i]}=$Spars[$i+1]   
   endif
   setgroup($Spars[$i],'processing')
   $i=$i+2
endwhile
groupcopy('current','processed','all')
flush 

// Add Dimension 
 
exists('dimension','parameter'):$e
if not $e then
   create('dimension','string')
   setprotect('dimension','on',256)
   dimension=''
endif

// Add Parameters for Pipe Information
 
exists('BPpipeprocinfo','parameter'):$e   
if not $e then
   create('BPpipeprocinfo','string')
   setprotect('BPpipeprocinfo','on',256)
   BPpipeprocinfo=''
endif

exists('BPpipedrawinfo','parameter'):$e     
if not $e then
   create('BPpipedrawinfo','string')
   setprotect('BPpipedrawinfo','on',256)
   BPpipedrawinfo=''
endif

exists('BPpipetype','parameter'):$e
if not $e then
   create('BPpipetype','string')
   setprotect('BPpipetype','on',256)
   BPpipetype=''
endif

exists('BPpipetype','parameter','processed'):$e
if not $e then
   create('BPpipetype','string','processed')
   setprotect('BPpipetype','on',256,'processed')
   BPpipetype=''
endif

exists('BPpipeautoproc','parameter'):$e
if not $e then
   create('BPpipeautoproc','flag')
   setprotect('BPpipeautoproc','on',256)
   BPpipeautoproc = 'n'
endif

exists('BPpipeproc','parameter'):$e
if not $e then
   create('BPpipeproc','real')
   setprotect('BPpipeproc','on',256)
   BPpipeproc =1
endif

exists('BPpipedraw','parameter'):$e
if not $e then
   create('BPpipedraw','flag')
   BPpipedraw = 'n'
endif

exists('BPpipevjdisp','parameter'):$e
if not $e then
   create('BPpipevjdisp','flag')
   setprotect('BPpipevjdisp','on',256)
   BPpipevjdisp = 'n'
endif

exists('BPpipevjproc','parameter'):$e
if not $e then
   create('BPpipevjproc','flag')
   BPpipevjproc = 'n'
endif

exists('BPpipeexport','parameter'):$e
if not $e then
   create('BPpipeexport','flag')
   setprotect('BPpipeexport','on',256)
endif
BPpipeexport='n'

exists('BPpipeexportexp','parameter'):$e
if not $e then
   create('BPpipeexportexp','string')
   setprotect('BPpipeexportexp','on',256)
endif
BPpipeexportexp='5'

exists('BPpipenexp','parameter'):$e
if not $e then
   create('BPpipenexp','integer')
   BPpipenexp = 1
endif

exists('BPpipeexp','parameter'):$e
if not $e then
   create('BPpipeexp','string')
   setprotect('BPpipeexp','on',256)
   BPpipeexp = '','','','','','','','','','','',''
endif

exists('BPpipeexp1','parameter'):$e
if not $e then
   create('BPpipeexp1','real')
   setprotect('BPpipeexp1','on',256)
endif
BPpipeexp1=1
  
exists('BPpipeexp2','parameter'):$e
if not $e then
   create('BPpipeexp2','real')
   setprotect('BPpipeexp2','on',256)
endif
BPpipeexp2=2
  
exists('BPpipeexp3','parameter'):$e
if not $e then
   create('BPpipeexp3','real')
   setprotect('BPpipeexp3','on',256)
endif
BPpipeexp3=3
  
exists('BPpipeexp4','parameter'):$e
if not $e then
   create('BPpipeexp4','real')
   setprotect('BPpipeexp4','on',256)
endif
BPpipeexp4=4
  
exists('BPpipeexp5','parameter'):$e
if not $e then
   create('BPpipeexp5','real')
   setprotect('BPpipeexp5','on',256)
endif
BPpipeexp5=5
  
exists('BPpipeexp6','parameter'):$e
if not $e then
   create('BPpipeexp6','real')
   setprotect('BPpipeexp6','on',256)
endif
BPpipeexp6=6
  
exists('BPpipeexp7','parameter'):$e
if not $e then
   create('BPpipeexp7','real')
   setprotect('BPpipeexp7','on',256)
endif
BPpipeexp7=7
  
exists('BPpipeexp8','parameter'):$e
if not $e then
   create('BPpipeexp8','real')
   setprotect('BPpipeexp8','on',256)
endif
BPpipeexp8=8
  
exists('BPpipeexp9','parameter'):$e
if not $e then
   create('BPpipeexp9','real')
   setprotect('BPpipeexp9','on',256)
endif
BPpipeexp9=9
  
exists('BPpipeexp10','parameter'):$e
if not $e then
   create('BPpipeexp10','real')
   setprotect('BPpipeexp10','on',256)
endif
BPpipeexp10=10
  
exists('BPpipeexp11','parameter'):$e
if not $e then
   create('BPpipeexp11','real')
   setprotect('BPpipeexp11','on',256)
endif
BPpipeexp11=11
  
exists('BPpipeexp12','parameter'):$e
if not $e then
   create('BPpipeexp12','real')
   setprotect('BPpipeexp12','on',256)
endif
BPpipeexp12=12

exists('BPpiperegion','parameter'):$e
if not $e then
   create('BPpiperegion','flag')
   BPpiperegion='n'
endif

exists('BPpipepage','parameter'):$e
if not $e then
   create('BPpipepage','integer')
   setprotect('BPpipepage','on',256)
   BPpipepage=1
else
   setprotect('BPpipepage','on',256)
endif

// Create Reference Parameters for Pipe.

exists('h1reff1','parameter'):$e
if $e=0 then create('h1reff1','real') endif
exists('h1reff2','parameter'):$e
if $e=0 then create('h1reff2','real') endif
exists('h1reff3','parameter'):$e
if $e=0 then create('h1reff3','real') endif
exists('c13reff1','parameter'):$e
if $e=0 then create('c13reff1','real') endif
exists('c13reff2','parameter'):$e
if $e=0 then create('c13reff2','real') endif
exists('c13reff3','parameter'):$e
if $e=0 then create('c13reff3','real') endif
exists('n15reff1','parameter'):$e
if $e=0 then create('n15reff1','real') endif
exists('n15reff2','parameter'):$e
if $e=0 then create('n15reff2','real') endif
exists('n15reff3','parameter'):$e
if $e=0 then create('n15reff3','real') 
endif
exists('obscenterppm','parameter'):$e
if $e=0 then create('obscenterppm','real')
endif

write('line3','Macro %s is complete\n',$0)
