; Extract slices from volumes
;
; SOURCE: slices.spi 
;
; PURPOSE: Extract central slices from volumes. 
;          Used to assess the quality of the volumes.
;
; MASTER COPY: /net/bali/usr1/spider/docs/techs/recon/newprogs/
;
; I/O PARAMETERS AND FILES ARE SET HERE:
;
;  -------------------- Input files -----------------------------------

FR G
[defgrps]sel_group           ; Defocus groups selection file

FR G
[vol]df{***[grp]}/vol001_odd   ; Volume (one for each defocus group)

; -------------------------- Output files ---------------------------

FR G
[slicedir]slices               ; Directory for output files 

FR G
[slice]slice{***[grp]}         ; Central slices from volumes (one/defocus group)

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

VM                         ; Make directory for slices         (output)
mkdir -p [slicedir]

[key]=1
UD IC [key],[grp]          ; Get first group number 
[defgrps]                  ; Group selection file              (input)

FI [diam]                  ; Get diameter of the volume
[vol]                      ; First volume                      (input)
(12)                       ; Nsam location in file header

[mid] = INT([diam]/2) + 1  ; Central slice

UD N [numgrps]             ; Find number of defocus groups
[defgrps]                  ;                                  (input)

DO LB1 [numgrp]=1,[numgrps]  ; Loop over all defocus groups

   UD IC [numgrp],[grp]    ; Get current group number 
   [defgrps]               ; Group selection file              (input)

   PS                      ; Pick slice
   [vol]                   ; Input volume                     (input)
   [slicedir]/[slice]      ; Output slice                     (output)
   ([mid])                 ; Slice number
LB1

VM                                      
echo ' 'Created central slices for: {***[numgrps]}  volumes 
VM                                      
echo ' '

EN D
;