autoemx.runners.process_particle_statistics module
Runner: recalculate the particle size statistics of a sample, filtering out some particles or frames.
The particles are read from the frames of the sample ledger (ledger.json), under the segmentations of its
active statistics result; the recalculated statistics are added as a new result (made the active one), recording the
particles (as (frame_id, index)) and frames left out. Frames and earlier results stay in the ledger, so recalculating
without exclusions restores the statistics of the measurement. Samples measured before the ledger stored particle
sizes are read from their particle sizes file (<sample_ID>_Par_sizes.csv).
The statistics are also saved with the suffix _processed (particle sizes, summary statistics and histogram).
Created on Mon Oct 13 2026 @author: Andrea
- autoemx.runners.process_particle_statistics.list_size_results(sample_ID: str, results_path: str, verbose: bool = True) List[str][source]
The statistics results of a sample (one per segmentation, recalculation…), to choose the one to recalculate (
result_idofprocess_particle_statistics): id, measurement, segmentation, particles, frames and particles left out. Printed ifverbose.
- autoemx.runners.process_particle_statistics.process_particle_statistics(sample_ID: str, results_path: str, particle_ids_to_filter: Iterable[int] | None = None, frame_ids_to_filter: Iterable[str] | None = None, include_eds_auto_particles: bool | None = None, particles_to_filter: Iterable[Tuple[str, int]] | None = None, result_id: int | None = None, output_file_suffix: str = '_processed', verbose: bool = True) DataFrame | None[source]
Recalculate the particle size statistics of a sample without some particles or frames.
- Parameters:
sample_ID (str) – Sample ID (name of the sample folder).
results_path (str) – Folder containing the sample folder (also searched in its subfolders).
particle_ids_to_filter (iterable of int, optional) – IDs of the particles to remove (‘Particle #’ column), for samples read from their particle sizes file.
frame_ids_to_filter (iterable of str, optional) – IDs of the frames whose particles are removed (‘Frame ID’ column). Only exact matches: the subframes of a frame (e.g. ‘A0_a1’ in ‘A0’) must be listed separately.
include_eds_auto_particles (bool, optional) – Whether to include what EDS measured (ledger only). Default: the setting of the active result.
particles_to_filter (iterable of (frame_id, index), optional) – Particles to remove, by frame and index in the frame (‘Frame ID’ and ‘Particle #’ columns), ledger only.
result_id (int, optional) – Statistics result of the ledger to recalculate (its measurement and segmentations). Default: the active one.
output_file_suffix (str, optional) – Suffix of the files saved (default: ‘_processed’).
verbose (bool, optional) – If True (default), prints the statistics.
- Returns:
Summary statistics, or None if no particle is left.
- Return type:
pandas.DataFrame or None
- Raises:
FileNotFoundError – If the sample folder is not found, or the sample has neither particle size statistics in its ledger nor a particle sizes file.