; Rotate and shift images for Alignment
; 
; SOURCE: alignsh.spi  
;                         Added alignment stack op Nov 2006 ArDean Leith
;
; PURPOSE: Rotate and shift images according to parameters  
;          determined earlier by 'AP SH'. 
;          (Not needed if already done in: apshgrp.spi)
;
; MASTER COPY: /net/bali/usr1/spider/docs/techs/recon/newprogs/
;
; I/O PARAMETERS AND FILES ARE SET HERE:
;
;  --------------- Input files ----------------------------------------

FR G                                     
[defgrps]../Power_Spectra/order_defgrps ; Defocus groups selection file

FR G
[align_parameters]align_01_***          ; Alignment parameter files

FR G
[img]jnk/jnk_{******[part]}             ; Unaligned image stack file

; --------------- Output file  ----------------------------------

FR G
[aligned_images]jnk/jnkali_dala01_{******[part]}     ; Rotated, shifted (aligned) images

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

UD N,[numgrps]                     ; Get number of defocus groups 
[defgrps]

[grp]=1

DO LB1 [part]=1,1917                ; Loop over all particles

   ; Parameter order in doc file: PHI,THETA,PSI, REF#,IMG#, ROT,SX,SY
   UD IC [part], x11,x12,x13, x14,x14, x15,x16,x17
   [align_parameters][grp]         ; Alignment angles doc. file         

   RT SQ                           ; Rotate & shift the images
   [img]                           ; Input image stack
   [aligned_images]                ; Output image stack
   (x15)                           ; angle, scale
   (x16,x17)                       ; x, & y shift
LB1

; Finished with incore group selection doc. file
UD ICE
[defgrps]                          ; Defocus group selection file

EN

;