; Creates average and variance images
;
; SOURCE: Display.spi
;
; PURPOSE: Creates a large circular plot (a SPIDER image) containing smaller 
;          circles representing the 83 angular groups. The radii of the 83 small
;          circles are proportional to the number of particles in each group.
;
; This batch files creates displays for all defocus groups.

; I/O PARAMETERS AND FILES ARE SET HERE:

[type] =  1  ; 1 = put projection numbers in display
            ; 0 = don't put in numbers
            ; -1 = numbers only, no circles!

[back] = 1  ; 1 = white background, 0 = black background

;  ------------ Input files ---------------------------------------
FR G
[refangles]../Alignment/refangles    ; Doc file of the 83 angles

FR G                                     
[defgrps]sel_group                  ; Defocus groups selection file

FR G
[how_many]how_many                   ; Number of particles per projection

; --------------- Output files  -----------------------------------
FR G
[displaydir]display                  ; Directory for output files

FR G
[display]cndis                       ; Output plot images

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

VM
mkdir -p [displaydir]

UD N,[numgrps]                  ; Get number of groups 
[defgrps]                       ; Group selection doc file      (input)

DO LB1 [numgrp]=1,[numgrps]     ; Loop over all defocus group(s)
   UD IC [numgrp],[grp]         ; Get current defocus group number
   [defgrps]

   @display_p[[type],[back]]
   [refangles]                       ; Reference angles file
   df{***[grp]}/[how_many]           ; Doc file of particles per projection
   [displaydir]/[display]{***[grp]}  ; Output files
LB1

; Put sum of all defocus groups in output file000

[grp] = 0

@display_p[[type],[back]]
[refangles]           
[how_many]                        ; Overall no. of particles / projection
[displaydir]/[display]{***[grp]}  ; Output file

VM
echo " Created circular plots [displaydir]/[display]*** of projection angles"
VM
echo ' '
 
EN 
;