; RE-SEPARATE SEL_PARTICLES FILES BY VIEW ; ; Useful for supervised-classification output ; ; REQUIRES ../Reconstruction/reversedoc_7col.spi ; ------------------------- Parameter ------------------------- [progress-interval] = 10 ; prints progress message every Nth view ; -------------------------- Inputs -------------------------- fr l [recon_dir]../Reconstruction ; reconstruction input/output directory fr l [defocus_list][recon_dir]/sel_group ; list of defocus groups fr l [df_select_doc][recon_dir]/class2-sel_particles_*** ; selection-file template, for each defocus group ; DF_SLICE FR L [group2particle_table][recon_dir]/stack2particle*** ; stack-to-particle lookup table template, for each defocus-group ; KEY:DF_SLICE / PARTICLE ; used fr l [projection_list]../Alignment/projlist ; list of projection views fr l [total_view_doc][recon_dir]/select/sel{***x80} ; total by-view particle list (all defocus groups combined) ; VIEW_SLICE GLOBPARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW ; -------------------------- Outputs -------------------------- fr l [reselect_view_doc][recon_dir]/select/prj{***x80}/class2-sel ; by-view selection file ; / VIEW_SLICE PARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW fr l [summary_doc][recon_dir]/summary-reselectbyview ; summary doc ; --------------------- END BATCH HEADER --------------------- fr l [temp_combined_select]tmpcombinedsel fr l [temp_combined_particles_incore]tmpcombined_incore fr l [temp_combined_particles_ondisk]tmpcombinedparts_ondisk fr l [temp_viewsel_unreversed]tmpreselect_unreversed de [summary_doc] SD / VIEW_NUM NUMPARTICLES [summary_doc] vm echo "Separating selection lists by view" vm echo "Combining defocus groups' selection lists"; date; echo ; combine groups' selection files (only to get #particles) doc combine [df_select_doc] [defocus_list] [temp_combined_select] ; get #particles in defocus-group selection ud n [num-dfsel] [temp_combined_select] de [temp_combined_select] ; initialize in-core doc sd ic new [temp_combined_particles_incore] (3,[num-dfsel]) ; #columns, #particles ; initialize particle-counter [counter-bygrp] = 0 ; get #groups ud n [num-groups] [defocus_list] ; loop through groups do lb7 [grp-num] = 1,[num-groups] ; get #particles in current group ud n [num-partsgrp] [df_select_doc][grp-num] ; loop through particles do lb5 x55 = 1,[num-partsgrp] ; read df-slice ud ic x55, [df-slice] [df_select_doc][grp-num] ; read particle# ud ic [df-slice], [particle-num] [group2particle_table][grp-num] [counter-bygrp] = [counter-bygrp] + 1 ; write to in-core doc sd ic [counter-bygrp], [grp-num],[particle-num],[df-slice] [temp_combined_particles_incore] lb5 ; end particle-loop ; close docs ud ice [df_select_doc][grp-num] ud ice [group2particle_table][grp-num] lb7 ; end group-loop sd ic copy [temp_combined_particles_incore] [temp_combined_particles_ondisk] sd ic e [temp_combined_particles_incore] vm m echo "Done combining defocus groups' selection lists"; date ; echo "Splitting by view" . ; GENERATE LISTS BY VIEW ; initialize view-particle counter [num-byview] = 0 ; get #views ud n [num-views] [projection_list] ; loop through views do lb8 x80=1,[num-views] if (int(x80/[progress-interval]).eq.x80/[progress-interval]) then vm echo "Working on view #{***x80} out of {***[num-views]}" endif ; get #particles in view ud n [parts-inview] [total_view_doc] ; if there are no particles in this view, then... if([parts-inview].eq.0) then vm echo "No particles in view #{***x80} -- Skipping..." [num-partsview] = 0 goto lb3 endif ; intersect with combined selection list doc and [total_view_doc] [temp_combined_particles_ondisk] ; WAS [temp_combined_select] [reselect_view_doc]_unrenum ; WAS _unrekey (2) ; column# to intersect: particle# ; get #particles in subset ud n [parts-insubset] [reselect_view_doc]_unrenum ; if there are no particles in this view, then... if([parts-insubset].eq.0) then vm echo "No particles in view #{***x80} -- Skipping..." [num-partsview] = 0 de [reselect_view_doc]_unrenum ; WAS _unrekey goto lb3 endif ; if there are particles in this view, then... ; renumber view-doc doc sort ; WAS doc ren [reselect_view_doc]_unrenum [temp_viewsel_unreversed] ; WAS [reselect_view_doc] (4) ; column# to sort: CCROT Y ; renumber keys? @../Reconstruction/reversedoc_7col [temp_viewsel_unreversed] [reselect_view_doc] SD / VIEW_SLICE PARTICLE DF_SLICE CC_ROT MIRROR GROUPNUM VIEW [reselect_view_doc] sd e [reselect_view_doc] ; clean up de [reselect_view_doc]_unrenum ; WAS _unrekey de [temp_viewsel_unreversed] ; get #particles ud n [num-partsview] [reselect_view_doc] lb3 ; skip here if no particles found ; increment counter [num-byview] = [num-byview] + [num-partsview] ; write to summary sd x80,x80,[num-partsview] [summary_doc] lb8 ; end view-loop ; clean up SD / PARTSAFTER PARTSBEFORE [summary_doc] [dummy] = -[num-views] sd [dummy], [num-byview],[num-dfsel] [summary_doc] sd e [summary_doc] de [temp_combined_particles_ondisk] vm m echo "Done"; echo ; echo "Combined particles in defocus-group files: {******[num-dfsel]}" ; echo "Combined particles in view-selection files: {******[num-byview]}" ; date . en d ; Modified 2009-12-15 ; 2009-08-26 (trs) -- checks for empty views ; 2009-06-22 (trs) -- sorts by CCROT