autoemx.runners.reanalyze_particle_statistics module

Runner: reanalyse a particle size statistics measurement from its saved frame images, with other segmentation settings (brightness threshold, segmentation model and its options, minimum number of pixels per particle).

The frames of each size band (and the frames searched by EDS on the sample) are segmented again, as during the measurement, from the images saved in SEM images: the results are added to the frames under a segmentation id (those of other segmentations are kept, see SampleLedger.segmentations), and the statistics rebuilt from them with the same size bands, frames and scanned area are added as a new result, made the active one. The statistics are also saved with the suffix _reanalysed.

Frames recorded without image (frames without particles of measurements made before AutoEMX 1.6.3) are kept as frames without particles; frames whose image is missing are left out. Particles measured by EDS stay in the ledger.

Created on Fri Oct 16 2026 @author: Andrea

autoemx.runners.reanalyze_particle_statistics.reanalyze_particle_statistics(sample_ID: str, results_path: str, par_brightness_thresh: int | None = None, par_segmentation_model: str | None = None, min_par_pixels: int | None = None, par_segmentation_params: Dict[str, Any] | None = None, include_eds_frames: bool = True, output_file_suffix: str = '_reanalysed', verbose: bool = True) → DataFrame | None[source]

Reanalyse the particle size statistics measurement of a sample from its saved frame images.

Parameters:
  • sample_ID (str) – Sample ID (name of the sample folder).

  • results_path (str) – Folder containing the sample folder (also searched in its subfolders).

  • par_brightness_thresh (optional) – Segmentation settings to use instead of those of the measurement (see PowderMeasurementConfig).

  • par_segmentation_model (optional) – Segmentation settings to use instead of those of the measurement (see PowderMeasurementConfig).

  • min_par_pixels (optional) – Segmentation settings to use instead of those of the measurement (see PowderMeasurementConfig).

  • par_segmentation_params (dict, optional) – Options of the segmentation model (e.g. {"checkpoint": "facebook/sam2.1-hiera-small"} for SAM2). Default: those of the measurement if the model is the same, else none (the model defaults).

  • include_eds_frames (bool, optional) – Whether to also reanalyse the frames searched by EDS on the sample (default: True).

  • output_file_suffix (str, optional) – Suffix of the files saved (default: ‘_reanalysed’).

  • 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 or its ledger is not found.

  • ValueError – If the sample has no completed particle size statistics measurement.