;
; ; SOURCE: spider/docs/techs/recon1/Procs/align-loop.spi ; New Nov 2004 ArDean Leith ; Rewritten Feb 2005 ArDean Leith ; Added alignment option & stack op Nov 2006 ArDean Leith ; SET MP location Feb 2008 ArDean Leith ; Adapted from: pub-refine-start Jan 2016 ArDean Leith ; ; PURPOSE: Runs alignment for specified group ; ; ------------------------ Parameter ------------------------------------------ [numCPUs] = 10 ; Number of processors to use (0 == All) ; Can be overridden from the command line with [numProcs] ; INPUT REGISTERS (Set on command line or globally): ; [grp] Current group number ; [alignsh] Alignment shift distance ; [r2] Alignment outer radius ; [incore-yn] Incore images used ; ; INPUT FILES: ([init_dir] denotes input directory, '***' denotes group, '%' denotes subset) ; [init_sel_part] [init_dir]/sel_part_*** Group particle selection files (one/group) ; [init_unaligned] [init_dir]/data_*** Unaligned image stacks (one/group) ; ; OUTPUT FILES: ([init_dir] denotes output directory, '$$$$' denotes sync number, and '***' denotes group) ; [out_align_doc] [init_dir]/align_01_*** Alignment parameter doc files (one/group) ; [out_aligned] [init_dir]/dala_***@ Rotationally aligned particle images (one/group) ; [finished_file] jnk_sync_$$$$_*** Created when this task is finished (one) ; ; -------------------- END BATCH HEADER ---------------------------------------- MD TR OFF ; Loop info turned off MD VB OFF ; File info turned off [iter] = 0 [next-iter] = 1 IF ( [grp] > 0 ) THEN ; Get reconstruction parameters & file names @recon-settings([pixsiz],[ang-step],[r2],[alignsh],[prj-radius],[winsiz],[incore-yn],[bp-type],[qsub],[masterCPUs],[groupCPUs]) ELSE ; Reconstruction file names already available RR [grp] ; Input group from caller for inline use ? ENTER GROUP ? RR [groupCPUs] ; Input number of CPUs ? ENTER NUMBER OF CPUS ? [qsub] = -1 ; For single group ENDIF IF ( [numProcs] > 0 ) THEN MD SET MP ; Set OMP processors [numProcs] ELSE MD SET MP ; Set OMP processors [groupCPUs] ENDIF ; IQ DIR [has-scratch] ; See if there is a local scratch dir. ; [temp_local_dir] ; Dir name ; ; IF ( [has-scratch] > 0 ) THEN ; ; Copy files to local compute node disk ; @pub-ref-loop-clone([iter],[grp]) ; ; ELSE ; ; Redefine [temp_local_dir] to work directory ; GLO [temp_local_dir] = '[temp_work_dir]' ; ENDIF ; ; (NOT USED) SYS echo -n " Starting: align-loop for group: {%I3%[grp]} --- " ; date '+ %x %X' UD N [num-refs] ; Get number of reference images used [iter_refangs] ; Reference images angles file (input) MY FL ; Flush results file IF ( [incore-yn] > 0 ) THEN ; Load input images into incore image stack for speedup ; Note: If INLN_WRTLIN ARRAY OVERFLOWS, set: [incore-yn] to: zero GLO [temp_in_images] = '_8@' FI H [maxim] ; Find total number of images (not [numparts]) [init_unaligned][grp]@ ; Input file needed (input) MAXIM ; Max. image number, image size CP ; Copy unaligned images to inline stack [init_unaligned][grp]@ ; Input file needed (input) [temp_in_images] ; Incore unaligned images stack (output) [maxim] ; Number of images in stack _8@ GLO [temp_out_imgs] = '_8@' ; Incore, inplace ELSE ; Use existing image stack for input & a temporary stack for output GLO [temp_in_images] = [init_unaligned][grp]@ GLO [temp_out_imgs] = [out_aligned][grp]@ ENDIF !SYS ; Create copy wait time flag file (unused) ! touch [wait_file].$DATEXT DE ; Delete existing files [out_align_doc] ; Alignment parameter doc file (deleted) ; Find reference projection matching current aligned image [r1] = 5.0 ; First radius for 'AP' (Can alter this) [rinc] = 1 ! Use: 2 for large radii & faster AP SHC ; (Can change alignment operation) [ref_projs]@****** ; Template for ref. projections (input) 1-[num-refs] ; Ref. projection file numbers [alignsh],[alignsh],1 ; Shift search range x & y , Step size [r1],[r2],[rinc] ; First, last radial ring, & Skip [iter_refangs] ; Ref. angles file (input) [temp_in_images]****** ; Template for unaligned images (input) [init_sel_part][grp] ; Particle selection files (input) * ; Alignment parameter doc file (input) 0, 0 ; Angular search restriction Y, N, N ; Check mir, align first, denoise [out_align_doc] ; Alignment parameter doc file (output) SYS echo " Found alignment parameters for iteration: {%I0%[iter]} Group: {%I3%[grp]}" ; Apply new rotational alignments to original particle images RT SF ; Rotate & shift operation [init_unaligned][grp]@****** ; Unaligned stacked image files (input) [init_sel_part][grp] ; Particle selection file (input) 6,0,7,8 ; Reg. #s for angle, scale, & shift [out_align_doc] ; Alignment parameter doc file (input) [temp_out_imgs]****** ; Current aligned images (output) ; Save aligned images when doing reconstruction but not during refinement IF ( [iter] == 0 ) THEN CP ; Copy aligned images to file stack [temp_out_imgs] ; Aligned images (input) [out_aligned][grp]@ ; Aligned images (output) DE ; Delete stack [temp_out_imgs] ; No longer needed (deleted) ENDIF SYS echo " Finished rotational alignment iteration: {%I0%[iter]} Group: {%I3%[grp]}" IF ( [qsub] >= 0 ) THEN ; Signal controlling SPIDER run that task is finished and halt SD 1, [task] ; Set sync file output [finished_file] ; Sync file (output) SD E ; Close sync file [finished_file] ; Sync file (closed) EN ; This SPIDER ends now ENDIF RE ; Return to caller ; Modified 2017-08-04 ; 2016-05-25 (trs) -- made #CPUs user-defined ;