susan.data.TiltRangeSelector¶
- class susan.data.TiltRangeSelector(tomograms, tilt_deg_min, tilt_deg_max, angle_source='eZYZ_Y')[source]¶
Bases:
objectBuild per-tomogram projection masks for a signed tilt range and emit reduced
Tomograms/Particleson the surviving projections.The selector is built once from a source
Tomogramsand a signed tilt range[tilt_deg_min, tilt_deg_max). For each tomogram it computes the indices of projections whose canonicalised signed tilt falls within that range and that are currently active (proj_wgt > 0). The same selector can then be applied to multiple inputs that share the projection layout — typically a b1 and a b2Tomogramsproduced viabin()— so the index arithmetic only happens once.The reduced output uses a single rectangular per-projection axis of length
new_n_projs = max_t(kept_count[t]); tomograms keeping fewer projections pad the trailing slots with zeros (proj_wgt = 0). Each rewritten stack MRC contains only that tomogram’s kept slices, sostack_size[t, 2] = kept_count[t].Tilt convention
Rmat_eZYZ(the canonical decomposition used throughout SUSAN) places β in[0, π], so a stage tilt of, e.g., −60° is stored as roughly(±π, 60°, ±π). The selector readsproj_eZYZ, decomposes the rotation matrix, and switches to the equivalent representation(α∓π, −β, γ∓π)whenever|α| > π/2. This yields a signed tilt β ∈ [−90°, 90°] with the in-plane component near zero, which is what one usually thinks of as “the tilt angle”. The canonicalised angles are used only for the filter test; the emittednew.proj_eZYZkeeps SUSAN’s original convention.Note
For lightweight filtering that does not need on-disk reduction,
susan.data.Particles.Geom.enable_by_tilt_range()zeros the relevantprj_wslots without touching the projection axis or the MRC stacks.Attributes
- tilt_deg_min: float¶
Signed lower bound of the kept range (inclusive), in degrees.
- tilt_deg_max: float¶
Signed upper bound of the kept range (exclusive), in degrees.
- tag: str¶
Filename tag derived from the bounds, e.g.
'tlt_m60p60'for[-60, 60)and'tlt_m45d5p45d5'for[-45.5, 45.5).m/pmark sign;dreplaces the decimal point.
Properties
- property kept_indices: list[ndarray]¶
List of length
n_tomos; each entry holds the original projection indices kept for that tomogram, asint32arrays.
- property kept_count: ndarray¶
uint32array of lengthn_tomoswith the per-tomogram kept-projection count.
Methods
- to_tomograms(tomograms, write_stacks=True, in_subfolder=True, filename=None) Tomograms[source]¶
Emit a reduced
Tomogramson the kept projections.The selector’s kept-index list is applied to
tomograms— which may differ from the source used to build the selector, as long as the projection layout matches (samen_tomos, sametomo_idordering, andnum_proj[t]at least as large as the source’s). This lets the same selector reduce a b1 and a b2Tomogramsconsistently.- Parameters:
tomograms (Tomograms or str) – Tomograms to reduce, or a path to a
.tomostxtfile.write_stacks (bool, optional) – If True (default), each input stack MRC is read and a new MRC containing only the kept projections is written. If False, the new
stack_fileentries keep the input paths andstack_size[:, 2]is left equal to the kept count (the caller is responsible for slicing at read time).in_subfolder (bool, optional) – If True (default), each rewritten stack is placed in a
<tag>/sibling directory next to the input stack; if False, written alongside with the tag inserted into the stem. Matches the behaviour ofTomograms.bin().filename (str, optional) – If given, also save the reduced
Tomogramsto this.tomostxtfile.
- Returns:
New
Tomogramswith per-projection arrays of lengthnew_n_projs.- Return type:
- to_particles(particles, filename=None) Particles[source]¶
Emit a reduced
Particleson the kept projections.Slices
prj_eu,prj_t,prj_cc,prj_wand the per- particle defocus arrays along the per-projection axis, using each particle’stomo_idto look up the matching kept-index list. Non-projection fields (positions, alignments, identifiers, half-sets) are copied verbatim.Defocus values are not recomputed. If you want them rederived from the reduced tomograms, call
Particles.update_defocus(new_tomos)on the returned object.