([sp_pixsiz],[r2],[alignsh],[prj-radius],[iter1],[iter-end],[sphdecon],[smallang-yn],[qsub],[incore-yn],[gold-std],[bp-type]) ; ; Sets refinement parameters and files
 ;
 ; SOURCE:  spider/docs/techs/recon1/Procs/refine_settings.spi
 ;          New                                    ArDean Leith Jul 2002
 ;          [] variables                           ArDean Leith Dec 2005
 ;          Rewritten, more stacks                 ArDean Leith Dec 2006
 ;          Variable assignment                    ArDean Leith Jan 2010
 ;          Even-odd replaced                      ArDean Leith Jan 2011
 ;          Dala removal                           ArDean Leith Jan 2012
 ;          [pixsiz] returned, fsc, ofsc...        ArDean Leith Aug 2012
 ;          Skip 3.3,3...                          ArDean Leith Sep 2012
 ;          For CTF corrected images               ArDean Leith Oct 2013
 ;          For gold standard reconstruction       ArDean Leith May 2014
 ;          Added spherical deconvolution          ArDean Leith Jan 2016
 ;          Inlined params, changed dirs           ArDean Leith Mar 2016
 ;
 ; INPUT REGISTERS:    None
 ;
 ; OUTPUT REGISTERS:
 ;   [sp_pixsiz]       Pixel size                    (A) 
 ;   [r2]              Object alignment radius       (pixels)
 ;   [alignsh]         Alignment shift +- allowed    (pixels) 
 ;   [prj-radius]      Object projection radius      (pixels)
 ;   [iter1]           Starting iteration
 ;   [iter-end]        Ending   iteration
 ;   [sphdecon]        Spherical deconvolution angle (degrees)
 ;   [smallang-yn]     Small angle refinement flag   (1 == True)
 ;   [qsub]            Specifies que type            (1 == use PBS)
 ;   [incore-yn]       Incore files                  (1 == true)
 ;   [gold-std]        Use 'gold-standard' work-flow (1 == True)
 ;   [bp-type]         Backprojection method         (2 == 'BP 3F')
 ;
 ; 
 ; ------------- Adjust these parameters for your project --------------- EDIT -----

 [qsub]        = 1     ; Specifies que (1 == use PBS, 2 == PBS with memory estimate, 0 == use PubSub, <0 == none)

 [diam]        = 420   ; Diameter of the object (A), used to find radius for alignment.

 [sp_pixsiz]   = 1.68  ; Pixel size  from 'params.spi' file (A)  

 [sp_winsiz]   = 280   ; Window size from 'params.spi' file (pixels)   

 [win-frac]    = 0.95  ; Fraction of window diameter used in projection (0.95 == 95%)

 [incore-yn]   = 1     ; Load input images into incore stack (>0 == yes we have enough memory)

 [alignsh]     = 8     ; Alignment shift (pixels) searched is +- this value

 [iter1]       = 1     ; Starting alignment step (iteration)
 [iter-end]    = 12    ; Ending alignment step   (iteration)
  
 [bp-type]     = 2     ; Backprojection method (1=='BP CG', 2=='BP 3F', 3=='BP RP', 4=='BP 3N')

 [sphdecon]    = 0     ; Spherical deconvolution angle in degreees (0 == Do not deconvolve)

 [gold-std]    = 1     ; Use 'gold-standard resolution' work-flow (1 == use gold, 0 == use legacy)

 ; Following two string variables are used during usual refinement (one value / iteration) (Set for up to: 20 iterations)
!GLO [ang-steps]  = '15,10,3.3,3,2,  2,2,1.5,1.5,1.5, 1.5,1.5,1.5,1.5,1.5, 1.5,1.5,1.5,1.5,1.5'      ; Angular separation (degrees)    
 GLO [ang-steps]  = '15,3.3,3, 2,2,  2,1.5,1.5,1.5,1.5,  1.5,1.5,1.5,1.5,1.5,   1.5,1.5,1.5,1.5,1.5' ; Angular separation (degrees)  

!GLO [ang-limits] = '0,0,0,  0,15,  8,6,5,5,5, 5,5,5,5,5, 5,5,5,5,5'      ; Angular separation limits (degrees)
 GLO [ang-limits] = '0,0,0,  15,8,  6,5,5,5,5, 5,5,5,5,5, 5,5,5,5,5,5'    ; Angular separation limits (degrees)

 ; Following string variable is used to activate OPTIONAL amplitude enhancement (Set for up to: 20 iterations)
 GLO [amp-enhance-flags] = '0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0'  ; Amplitude enhancement selector 

 [smallang-yn] = 0    ; Use small angle refinement instead of regular (1 == Yes)

 ; Following two global register variables are only used during 'small angle refinement'
 GLO [ang-step-sm] =  5                    ; Angular degree step      
 GLO [theta-sm]    =  2.0                  ; Theta range  

 ; ----------------- Original input files ---  May have to EDIT these names, These files must exist ------

 GLO [in_dir]              = '../win_1'                             ; Dir. for starting selection files
 GLO [out_dir]             = '../final_1/'                          ; Dir. for significant output files

 GLO [sel_group]           = '[in_dir]/sel_group'                   ; Group selection doc file         (one)

 GLO [sel_parts]           = '[in_dir]/sel_part_{***[grp]}'         ; Particle selection doc files     (one/group)

 GLO [vol_orig]            = '[in_dir]/reference_volume_fqnp'       ; Initial reference volume         (one)   

 ; This variable: [unaligned_images] must be an absolute path to images or a link to an absolute path! 
 GLO [unaligned_images]    = '[in_dir]/data_{***[grp]}'             ; Original unaligned images stack  (one/group)
                
 ; OPTIONAL files needed if using amplitude enhancement
 GLO [scattering_doc]      = '[in_dir]/scattering'                  ; OPTIONAL enhancement doc file    (one)
 GLO [mask]                = '[in_dir]/mask'                        ; OPTIONAL mask for enhancement    (one)

 ; OPTIONAL local dir for speeding up parallel use 
 GLO [local_work_dir]      = '/scratch'                             ; OPTIONAL local scratch dir for parallel use (one)

 ; OPTIONAL doc file needed if using symmetry                         
 GLO [symmetry_doc]        = '*'                                    ; OPTIONAL symmetry doc file for 'back projection' (one)

 ; OPTIONAL initial alignment parameter doc file if starting from reconstruction 
!GLO [group_align_orig]    = '[in_dir]/align_{**[iter]}_{***[grp]}' ; OPTIONAL Initial alignment parameter file (one/group) 
 GLO [group_align_orig]    = '*'                                    ; OPTIONAL Initial alignment parameter file (one/group) 

 ; -------------- Output files -- Usually no need to edit for default refinement ---------------------

 GLO [work_dir]            = 'work/'                                      ; Work dir                           (one)

 GLO [sel_parts_s]         = '[sel_parts]_s{*[s]}'                        ; Particle subset selection doc file (two/group)

 GLO [vol]                 = '[out_dir]/vol_{**[iter]}'                   ; Current volume   
 GLO [vol_s]               = '[vol]_s{*[s]}'                              ; Current subset volume              (two/iter)  

 GLO [next_vol]            = '[out_dir]/vol_{**[next-iter]}'              ; Next volume                        (one/iter)
 GLO [next_vol_s]          = '[next_vol]_s{*[s]}'                         ; Next subset volume                 (two/iter)

 GLO [group_vol_stem]      = '[work_dir]/vol_{**[iter]}_{***[grp]}_***'   ; Current group volume               (one/group/iter)           
 GLO [group_vol_s]         = '[work_dir]/vol_{**[iter]}_{***[grp]}_s{*[s]'; Current group subset volumes       (two/group/iter) 

 GLO [next_group_vol]      = '[work_dir]/vol_{**[next-iter]}_{***[grp]}'  ; Next group volume                  (one/group/iter)
   
 GLO [next_group_vol_stem] = '[work_dir]/vol_{**[next-iter]}_***_s{*[s]}' ; Next subset group volume stem       
 GLO [next_group_vol_s]    = '[next_group_vol]_s{*[s]}'                   ; Next subset group volume           (two/group/iter) 

 GLO [group_align]         = '[out_dir]/align_{**[iter]}_{***[grp]}'      ; Group alignment doc file   
 GLO [group_align_s]       = '[group_align]_s{*[s]}'                      ; Group subset alignment doc files   (two/group/iter)
 GLO [next_group_align]    = '[out_dir]/align_{**[next-iter]}_{***[grp]}' ; Next group alignment doc file  
 GLO [next_group_align_s]  = '[next_group_align]_s{*[s]}'                 ; Next group subset alignment doc file (one/group/iter)

 GLO [iter_refangs]        = '[work_dir]/ref_angs_{**[iter]}'             ; Reference angle file               (one/iter)
 GLO [iter_refangs_grp]    = '[work_dir]/ref_angs_{**[iter]}_{***[grp]}'  ; Reference projection angles doc file  (one/group/iter) (deleted)

 GLO [ref_projs_s]         = '[work_dir]/ref_projs_{**[iter]}_s{*[s]}'    ; Subset reference projections       (one/iter)
 GLO [ref_projs_s_grp]     = '[ref_projs_s]_{***[grp]}@'                  ; Subset group reference projections (two/group/iter) (deleted)

 GLO [fsc_mask]            = '[out_dir]/fsc_mask'                         ; Mask for FSC                       (one) 
 GLO [next_u_fsc]          = '[out_dir]/fscdoc_u_{**[next-iter]}'         ; Unmasked FSC curve doc file        (one/iter)
 GLO [next_m_fsc]          = '[out_dir]/fscdoc_m_{**[next-iter]}'         ; Masked   FSC curve doc file        (one/iter)
 GLO [m_fsc]               = '[out_dir]/fscdoc_m_{**[iter]}'              ; Masked   FSC curve doc file        (one/iter)
 GLO [fsc_plots]           = 'fsc_iter.gpl'                               ; Gnuplot script for FSC plotting    (one) 

 GLO [iter_resol]          = '[out_dir]/resolutions'                      ; Overall resolution doc file        (one)
       
 GLO [ang_voea]            = '[out_dir]/angvoea'                          ; OPTIONAL, Small angle refinement ref. angles        (one/group/iter)
 GLO [ang_vora]            = '[out_dir]/angvora_{**[iter]}_{***[grp]}'    ; OPTIONAL, Small angle refinement ref. angles        (one/group/iter)
 GLO [temp_ref_projs]      = '_5@'                                        ; OPTIONAL, Small angle refinement local scratch file (deleted)
 
 GLO [enhance_doc]         = '[work_dir]/enhance_doc_{**[next-iter]}'     ; OPTIONAL, Enhancement doc file output      (one/iter)

 GLO [ref_rings]           = '[work_dir]/SCR_{**[iter]}_{***[grp]}'       ; OPTIONAL, Reference rings files output     (one/group/iter)
 GLO [wait_file]           = 'jnk_waited_***'                             ; OPTIONAL, Created when local copy finished (one/group)

 GLO [finished_file]       = 'jnk_sync_{****[rn]}_'                       ; OPTIONAL, Created when parallel segment finished (one/group)

 GLO [temp_in_images]      = '_8@'                                        ; OPTIONAL, Used by alignment & back projection internally
 GLO [temp_out_images]     = '[work_dir]/dala_{***[grp]}@'                ; OPTIONAL, Used if [incore-yn] == 0  or small angle ref. (deleted)

 ; ----------------- END BATCH HEADER ---------------------------------

 ; ---- Should not need to adjust following parameters --------------------------

 [r2]  = INT([diam]/(2.0*[sp_pixsiz])) ; Alignment radius (pixels) used in alignment search

 ; Ensure that sum of alignment radius + translation is within window dimensions 
 [ring-sh] = [r2] + [alignsh]          ; Last ring + translation step
 [maxrad]  = INT([sp_winsiz]/2) - 1    ; Max radius of object in window

 IF ( [ring-sh] >= [maxrad] ) THEN
   ; Must reduce radius of outer ring, not translation step
   [r2] = [maxrad] - [alignsh] - 2     ; Reduces rotational search radius 
 ENDIF

 [prj-radius] = INT(([win-frac]*[sp_winsiz])/2.0 )  ; Convert fraction to pixel radius

 RE
 ;