susan.project.STA¶
- class susan.project.STA.STA(prj_name, box_size=None)[source]¶
Bases:
objectSubtomogram averaging project manager.
Manages an STA project stored on disk. If box_size is provided the project directory prj_name is created (or reused) and a metadata file is written. If box_size is omitted the constructor reads the existing project.
The main entry point for automated workflows is
execute_iteration(). Lower-level helpers (exec_estimation(),exec_particle_selection(),exec_averaging(),exec_postprocessing()) can also be called individually for custom pipelines.Project files
- prj_name: str¶
Project directory path. Set by the constructor.
- box_size: int¶
Subvolume box size in pixels. Set by the constructor.
- tomogram_file: str¶
Path to the
.tomostxtfile used throughout the project.
- initial_reference: str¶
Path to the initial
.refstxtfile (iteration 0 reference).
- initial_particles: str¶
Path to the initial
.ptclsrawfile (iteration 0 particles).
GPU & processing
- list_gpus_ids: list of int¶
GPU device IDs forwarded to
aligner,averager, andctf_refinerat execution time. Default:[0].
Iteration control
- iteration_type: int or str¶
Type of processing step executed by
execute_iteration():Value
Step
3/'3D'3-D angular + offset search
2/'2D'2-D in-plane alignment
'ctf'CTF refinement
Default:
3.
- cc_threshold: float¶
Fraction of top-scoring particles kept for reconstruction (by cross-correlation score within each half-set). Must be in
(0, 1]. Default:0.8.
- fsc_threshold: float¶
FSC threshold used for resolution estimation in
exec_postprocessing(). Default:0.143.
Modules
- aligner: :class:`~susan.modules.Aligner`¶
Aligner instance used for 3-D/2-D alignment steps.
- averager: :class:`~susan.modules.Averager`¶
Averager instance used for map reconstruction.
- ctf_refiner: :class:`~susan.modules.CtfRefiner`¶
CtfRefiner instance used for CTF refinement steps.
Advanced
- mpi: :class:`~susan.utils.datatypes.mpi_params`¶
MPI launcher forwarded to child modules when
mpi.arg > 1. Default:mpi_params('srun -n %d ', 1).
- verbosity: int¶
Verbosity level forwarded to child modules. Default:
1.
- max_2d_delta_angstroms: float¶
Maximum 2-D shift magnitude (Å) allowed per iteration.
0disables the limit. Default:0.
- max_tilt_reconstruction: None, float, or array-like of length 2¶
Tilt-angle limit applied during reconstruction. Three forms:
Noneor a negative scalar — disabled (default:-1).Scalar (
intorfloat) — passestilt_deg_maxtoenable_by_tilt(); projections whose absolute tilt exceeds this value are zeroed.Two-element sequence
[min, max]— passes both signed bounds toenable_by_tilt_range(), allowing asymmetric tilt ranges.
- type_2d_shift_fitting: str¶
Warning
Experimental. This feature may change or be removed in a future release.
Post-alignment 2-D shift regularisation:
'none','affine','gaussian', or'tps'. Default:'none'.'tps'fits a regularised thin-plate spline to the per-tilt 2-D shift field: a globally smooth warp sitting between'affine'(globally rigid) and'gaussian'(purely local), with stiffness controlled bytps_lambda.
- tps_lambda: float¶
Warning
Experimental. This feature may change or be removed in a future release.
Stiffness of the
'tps'shift warp (dimensionless; coordinates are normalised per tomogram so the value is comparable across datasets).0interpolates every shift (overfits noise), large values converge to the pure affine fit. Default:1.0.
- fitting_from_origin: bool¶
Warning
Experimental. This feature may change or be removed in a future release.
Controls what the
'affine'/'gaussian'/'tps'shift regularisers fit. IfTrue(default) they fit the absolute currentprj_t(measured from origin). IfFalsethey fit only the incrementalprj_t(the delta versus the previous iteration) and add the smoothed delta back onto the previous shifts. Incremental deltas are smaller and noisier, sotps_lambdatypically needs to be larger in this mode. Default:True.
- smooth_ctf: bool¶
Warning
Experimental. This feature may change or be removed in a future release.
If
True, apply spatial smoothing to the per-particle CTF defocus deltas (difference from previous iteration) after CTF refinement. The smoother is selected bytype_ctf_smoothing. Default:False.
- type_ctf_smoothing: str¶
Warning
Experimental. This feature may change or be removed in a future release.
Smoother used when
smooth_ctfis enabled:'gaussian'(local kNN average, same kernel astype_2d_shift_fitting = 'gaussian') or'tps'(regularised thin-plate spline warp). Default:'gaussian'.
- ctf_tps_lambda: float¶
Warning
Experimental. This feature may change or be removed in a future release.
Stiffness of the
'tps'defocus warp, analogous totps_lambdabut applied independently to the CTF deltas. Default:1.0.
- reweight_classification: bool or float¶
Warning
Experimental. This feature may change or be removed in a future release.
Multi-reference classification weight strategy.
Falsekeeps raw CC scores;Truenormalises them to sum to 1; a float p raises them to the power p before normalising. Default:False.
Note
Retained for backward compatibility. New projects should use
SubtomoAvg(orSubtomoAvgSched/SubtomoAvgN2N), which supersede this interface.Main Method
- execute_iteration(ite) float | ndarray[source]¶
Run a complete STA iteration.
Executes
setup_iteration(),exec_estimation(),exec_particle_selection(),exec_averaging(), andexec_postprocessing()in sequence.- Parameters:
ite (int) – Iteration number (must be ≥ 1). If the iteration directory already exists its results are overwritten.
- Returns:
Estimated resolution in Fourier pixels (see
exec_postprocessing()).- Return type:
float or numpy.ndarray
Notes
Iteration
0is the project seed and cannot be processed. In that case a warning is issued, the iteration is skipped, and the configured starting lowpass is returned instead — the lowpass ofalignerfor a 3-D/2-D iteration orctf_refinerfor a CTF iteration. For a multi-reference project anumpy.ndarrayof lengthn_refsfilled with that value is returned; otherwise a scalar.
Step-by-step Execution
- setup_iteration(ite) tuple[_iteration_files, _iteration_files][source]¶
Prepare the directory and file-path objects for iteration ite.
Creates the iteration directory if needed and validates that the previous iteration’s output files exist.
- Parameters:
ite (int) – Iteration number (must be ≥ 1).
- Returns:
(cur, prv)— file-path objects for the current and previous iterations respectively.- Return type:
tuple
- Raises:
NameError – If the previous iteration’s particle or reference files are missing.
- exec_estimation(cur, prv)[source]¶
Run the alignment or CTF refinement step.
Dispatches to
align()(oralign_mpi()) for 3-D/2-D iteration types, or torefine()for CTF iterations. The type is determined byiteration_type.- Parameters:
cur (_iteration_files) – File paths for the current iteration (output).
prv (_iteration_files) – File paths for the previous iteration (input).
- exec_particle_selection(cur, prv)[source]¶
Select particles and prepare the input for reconstruction.
Performs multi-reference classification (if
n_refs > 1), applies optional 2-D shift corrections (max_2d_delta_angstroms,type_2d_shift_fitting) for 2-D alignment and CTF iterations, filters particles by CC score (cc_threshold), and optionally limits the tilt range (max_tilt_reconstruction). The selected particles are saved tocur.ptcl_temp.- Parameters:
cur (_iteration_files) – File paths for the current iteration.
prv (_iteration_files) – File paths for the previous iteration.
- exec_averaging(cur, prv)[source]¶
Reconstruct the reference maps and update the
.refstxtfile.Calls
reconstruct()(or MPI variant), then updatescur.referencewith the new map paths.- Parameters:
cur (_iteration_files) – File paths for the current iteration.
prv (_iteration_files) – File paths for the previous iteration (provides the mask paths).
- exec_postprocessing(cur) float | ndarray[source]¶
Compute FSC-based resolution estimates for all references.
- Parameters:
cur (_iteration_files) – File paths for the current iteration.
- Returns:
Estimated resolution in Fourier pixels at the
fsc_thresholdlevel. A scalar for single-reference projects; a 1-D array for multi-reference projects.- Return type:
float or numpy.ndarray
Data Access
- get_map(ite, ref=1) ndarray[source]¶
Load and return the reference map for iteration ite.
- Parameters:
ite (int) – Iteration number.
ref (int) – 1-based reference index. Default:
1.
- Returns:
3-D map array.
- Return type:
numpy.ndarray
- get_ptcls(ite) Particles[source]¶
Load and return the particles for iteration ite.
- Parameters:
ite (int) – Iteration number.
- Returns:
Particle container with aligned positions and scores.
- Return type:
- get_cc(ite, ref=1) ndarray[source]¶
Return the per-particle cross-correlation scores for iteration ite.
- Parameters:
ite (int) – Iteration number.
ref (int) – 1-based reference index. Default:
1.
- Returns:
CC scores for all particles assigned to reference ref.
- Return type:
numpy.ndarray, shape (N,)
- get_fsc(ite, ref=1) ndarray[source]¶
Compute and return the FSC curve for iteration ite.
- Parameters:
ite (int) – Iteration number.
ref (int) – 1-based reference index. Default:
1.
- Returns:
1-D FSC array indexed by Fourier shell.
- Return type:
numpy.ndarray
- get_name_ptcls(ite) str[source]¶
Return the path to the
.ptclsrawfile for iteration ite.- Parameters:
ite (int) – Iteration number.
0returnsinitial_particles.- Returns:
Path to the
.ptclsrawfile.- Return type:
str
- get_name_refstxt(ite) str[source]¶
Return the path to the
.refstxtfile for iteration ite.- Parameters:
ite (int) – Iteration number.
0returnsinitial_reference.- Returns:
Path to the
.refstxtfile.- Return type:
str
- get_names_map(ite, ref=1) str[source]¶
Return the path to the full reference map for iteration ite.
- Parameters:
ite (int) – Iteration number.
0returns the path from the initial.refstxt.ref (int) – 1-based reference (class) index. Default:
1.
- Returns:
Path to the MRC map file.
- Return type:
str
- get_names_mask(ite, ref=1) str[source]¶
Return the path to the soft mask for iteration ite.
- Parameters:
ite (int) – Iteration number.
0reads from the initial.refstxt.ref (int) – 1-based reference index. Default:
1.
- Returns:
Path to the mask MRC file.
- Return type:
str
- get_names_halfmaps(ite, ref=1) tuple[str, str][source]¶
Return the paths to the two half-maps for iteration ite.
- Parameters:
ite (int) – Iteration number.
0reads from the initial.refstxt.ref (int) – 1-based reference index. Default:
1.
- Returns:
(half1_path, half2_path).- Return type:
tuple of str
- get_iteration_dir(ite) str[source]¶
Return the directory path for iteration ite.
- Parameters:
ite (int) – Iteration number (1-based).
- Returns:
Path of the form
<prj_name>/ite_NNNN/.- Return type:
str
- get_iteration_files(ite) _iteration_files[source]¶
Return the standard file paths for iteration ite.
For
ite < 1the initial files (initial_particlesandinitial_reference) are returned.- Parameters:
ite (int) – Iteration number. Use
0for the initial state.- Returns:
Object with attributes
ptcl_rslt,ptcl_temp,reference, andite_dir.- Return type:
_iteration_files