([maxspfreq],[radius],[alignsh],[prj-radius],[iter1],[iter-end],[lambda],[small-ang],[winsize],[converg]) ; ; Sets refinement parameters and files
;
; SOURCE: refine_settings.pam                    ArDean Leith    Jul 2002
;                                    []          ArDean Leith    Dec 2005
;                        Rewritten  More stacks  ArDean Leith    Dec 2006
;
; MASTER COPY: /net/bali/usr1/spider/dev/refine/
;
; INPUT REGISTERS:
;
; OUTPUT REGISTERS (SET  BELOW):
;   [maxspfreq]          Maximum spatial freq (1/A) 
;   [radius]             Radius of structure (pixels)
;   [alignsh]            Alignment shift +- allowed (pixels) 
;   [prj-radius]         Projection radius (pixels)
;   [iter1]              Starting iteration
;   [iter-end]           Ending   iteration
;   [lambda]             Lambda (Angstroms)
;   [small-ang]          Small angle refinement flag (1 is true)
;   [winsize]            Image or window size = volume size
;   [converg]            Convergence criterion fraction
;
; ============== DO NOT COPY FROM WEB BROWSER ==============
; ---------Try to set Refinement parameters from parameter file ----------
;
 
FR G   
[params]input/params                                    ; Parameter doc file

UD 5,[pixsize]     ; Get pixelsize (Angstroms/pixel) (.17730) 
[params]           ; Parameter doc. file

UD 6,[kev]         ; Electron energy (kV)
[params]           ; Parameter doc. file

UD 14,[lambda]     ; Get Lambda (Angstroms) 
[params]           ; Parameter doc. file

UD 15,[maxspfreq]  ; Get maximum spatial frequency (1/Angstroms) 
[params]           ; Parameter doc. file

UD 17,[winsize]    ; Get windowsize (Pixels), used to find projection radius 
[params]           ; Parameter doc. file

UD E               ; End params doc. file usage

; ---- Adjust these parameters for your project --------------------- EDIT -----

[alignsh]  = 6    ; Alignment shift (pixels) searched is +- this value
[iter1]    = 1    ; Starting alignment step (iteration)
[iter-end] = 3    ; Ending alignment step   (iteration)

[diam]     = 349  ; Diameter of the structure (Angstroms) used in alignment search.
                  ;   (Default 276A is for ribosome. EDIT as needed.)
                  ;   This diameter is used to find radius for last alignment ring.
  
[win-frac] = 0.95 ; Fraction of window diameter used in projection (.95= use 95% window size)

[converg]  = 0.05 ; Convergence criterion fraction
                  ;   Converges when [converg] % of all images move < 1.5 * stepsize.

[small-ang] = 0   ; For SMALL angle refinement set this to 1

IF ([small-ang].EQ.1) THEN
   ; For SMALL angle refinement
   FR G           ; Angular degree step (CAN EDIT THIS)    
   [ang-steps](0.5) 
   FR G           ; Restriction on ang. search degrees (CAN EDIT THIS)    
   [ang-limits](2.0) 
ELSE
   FR G           ; Angular degree steps (CAN EDIT THIS)    
   [ang-steps]2.0,2.0,2.0,2.0,2.0,1.5,1.5,1.5,1.5,1.5,1.5 
   FR G           ; Restriction on ang. search degrees (CAN EDIT THIS)    
   [ang-limits]0.0,15.0,8.0,6.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0
ENDIF

FR G              ; Amplitude enhancement selector (CAN EDIT THIS)    
[amp-enhance-flags]0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 

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

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

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

IF ([ring-sh].GE.[maxrad]) THEN
   ; Must reduce alignment radius (last ring), not translation step
   [radius] = [maxrad] - [alignsh] - 1      ; Reduces alignment radius 
ENDIF

[prj-radius] = INT(([win-frac]*[winsize])/2.0 )  ; Convert fraction to radius in pixels 

; If maximum spatial frequency is not given, compute it from pixel size in params file
IF ([maxspfreq].LE.0)   [maxspfreq] = 1.0 / (2.0 * [pixsize])

; If Lambda is not given, compute it from electron energy in params file
IF ([lambda].LE.0)   [lambda] = 12.398 / SQR([kev] * (1022.0 + [kev]))

; ============== DO NOT COPY FROM WEB BROWSER ==============
; ----------------- Input files ---  May have to EDIT these names ------

FR G
[input_dir]input/                                       ; Main dir. for input files
FR G   
[params]input/params                                    ; Parameter doc file
FR G
[order_select]input/order_select                        ; Group selection doc file                    
FR G
[sorted_order_select]input/order_select_sort            ; Sorted group selection doc file
FR G
[start_vol]input/vol{**[iter]}                          ; Initial reconstructed volume   
FR G
[sel_particles]input/select_{***[grp]}                  ; Particle selection doc file
FR G
[start_group_align]input/align_{**[iter]}_{***[grp]}    ; Alignment parameter file 
FR G
[unaligned_images]input/data{***[grp]}                  ; Original unaligned images stack
FR G
[start_aligned_images]input/dala{**[iter]}_{***[grp]}   ; Initial aligned images prefix

; Following two files OPTIONAL (only needed if using amplitude enhancement)
FR G
[scattering_doc]input/scattering                        ; OPTIONAL enhancement document input
FR G
[mask]input/mask                                        ; OPTIONAL Mask for amplitude enhancement

; -------------- Output files -- No need to edit for default refinement ----------

FR G
[final_dir]final/                                       ; Main dir. for output files
FR G
[temp_local_dir]/tmp/                                   ; A local disk scratch dir
FR G
[temp_work_dir]work/                                    ; Temp work dir

FR G
[sel_particles_odd]input/selectodd_{***[grp]}           ; Particle selection doc file
FR G
[sel_particles_even]input/selecteven_{***[grp]}         ; Particle selection doc file

FR G
[current_vol]final/vol{**[iter]}                         ; Produced by 'AP SH' or previous iter.   
FR G
[next_vol]final/vol{**[next-iter]}                       ; Made for next iter.   
FR G
[next_val]final/val{**[next-iter]}                       ; Volumes

FR G
[group_align]final/align_{**[iter]}_{***[grp]}           ; Aignment parameter input file 
FR G
[next_group_align]final/align_{**[next-iter]}_{***[grp]} ; Alignment parameter output file 

FR G
[aligned_images_prefix]work/dala{**[iter]}_{***[grp]}    ; Current aligned images prefix
FR G
[aligned_images][aligned_images_prefix]@                 ; Current aligned images in stack
FR G
[next_aligned_images]work/dala{**[next-iter]}_{***[grp]}@ ; Next aligned images stack

; -------------------------

FR G
[group_vol]work/vol_{**[iter]}_{***[grp]}                ; Current group volume.   
FR G
[next_group_vol]work/vol_{**[next-iter]}_{***[grp]}      ; Next group volume.   
FR G
[next_group_vol_template]work/vol_{**[next-iter]}_***    ; Group volume template  

IF ([small-ang].EQ.0) THEN
   FR G
   [temp_ref_projs][temp_local_dir]/refproj{**[iter]}_{***[grp]} ; For Temporary local output file (deleted)
ELSE
   FR G                                         
   [img_ang_vora]final/angvora_{**[iter]}_{***[grp]}     ; For SMALL angles use only  

   FR G
   [temp_ref_projs]_5@                                   ; For SMALL angles Temporary local output file (deleted)
ENDIF

FR G
[next_dres]final/dres{**[next-iter]}                     ; Next dres output doc. file

FR G
[temp_ctf_file]input/ctf{***[grp]}                      ; CTF correction files
FR G
[temp_ctf_file_template]input/ctf***                    ; CTF correction file template

FR G
[iter_vft]final/vft{**[iter]}                           ; Temp. vft file template

FR G
[group_bpr]final/bpr{**[iter]}_{***[grp]}               ; Group volume file
FR G
[group_bpr_template]final/bpr{**[next-iter]}_***        ; Group volume template
FR G
[next_group_bpr]final/bpr{**[next-iter]}_{***[grp]}     ; Group volume file

FR G
[iter_ang_voea]work/angvoea_{**[iter]}                  ; Iter. angle voea file
FR G
[iter_select_voea]work/selvoea_{**[iter]}               ; Iter. angle voea selection file
   
FR G
[next_group_dres]final/dres{**[next-iter]}_{***[grp]}   ; Group dres output doc. file

FR G
[dbpr]final/dbpr{**[next-iter]}                         ; Output resolution doc files
FR G
[next_group_dbpr]final/dbpr{**[next-iter]}_{***[grp]}   ; Output group resolution doc files
FR G
[dbpr_resol]final/resolutions                           ; Output resolution doc file
FR G
[grp_resol]final/group_resolutions                      ; Output resolution doc file
       
FR G
[bpr]final/bpr{**[next-iter]}                           ; Refined output volume

FR G
[enhance_doc]work/enhance_doc_{**[next-iter]}           ; Enhancement document output

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

RE
;