; Filter volume to limit resolution.
 ;
 ; SOURCE:  spider/docs/techs/recon1/Procs/filter-refvol.spi
 ;          New                                       ArDean Leith  Nov 2000
 ;          For gold standard reconstruction          ArDean Leith  May 2014
 ;
 ; PURPOSE: Filter original reference volume to limit resolution.
 ;
 ; CALLED FROM: 
 ;
 ; Register variables & files are set in: recon-settings.pam
 ;
 ; INPUT REGISTERS USED:
 ;   [pixsiz]              Pixel size (A)
 ;
 ; '***' denotes group number, '@' denotes subset 
 ; INPUT FILES:
 ;   [params]              ../params                EM parameters file                  (one)  
 ;   [ref_vol_unfilt]      ../ref_vol_unfilt        Initial unfiltered reference volume (one)   
 ;
 ; OUTPUT FILES:
 ;   [ref_vol]             ../ref_vol_filt          Initial filtered reference volume   (one)   
 ;
 ; INLINE FILES USED: none
 ;
 ; ---- Edit these parameters for your project ---------------------------------------------

 [filterType] = 7      ; filter type (7==Butterworth, 5==Fermi, 3==Gaussian, 1==Tophat)
 [filtParam1] = 40.0   ; pass band for Butterworth, else filter radius (Angstroms)
 [filtParam2] = 30.0   ; stop band for Butterworth, temperature for Fermi, else unused (Angstroms)
 [numProcs]   = 0      ; number of CPUs to use (0==ALL)

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

 ; Input initial parameters & file names
 @recon-settings([pixsiz],[ang-step],[r2],[alignsh],[prj-radius],[winsiz],[incore-yn],[bp-type],[qsub],[masterCPUs],[groupCPUs])
 
; FI H [nx]                  ; Query row length value (images/volumes must be square)
;   [ref_vol_unfilt]         ; Initial unfiltered reference volume        (input)
;   NX                       ; X dimension wanted (cubic)

;; get pixel-size
;UD 5, [pixsiz]
;  [parameter_doc]
;UD E

 MD
   SET MP
   [numProcs]

 SYS
   echo " Filter type: {*[filterType]}, Parameter1: {%f6.2%[filtParam1]}, Parameter2: {%f6.2%[filtParam2]}" ; echo

; [filt-pix]    = [filt-angstr] / [pixsiz]  ; Pass-band
; [filt-spfr]   = [filt-pix] / [nx]         ; Pass-band        
; ; (I think the math is wrong here.)
; [stop-band]   = [filt-spfr] + 0.15        ; Stop band frequency

 [filtParam1] = [pixsiz]/[filtParam1]
 [filtParam2] = [pixsiz]/[filtParam2]

 ; filter volume
 FQ NP
   [ref_vol_unfilt]
   [ref_vol]
   [filterType]
   [filtParam1],[filtParam2]

 SYS
   echo "Done"

EN 

; Modified 2017-07-28