autoemx.core.saved_frames module

Particle detection in saved frame images, with other segmentation settings than those of the acquisition.

Used to reanalyse particle size statistics (autoemx.runners.reanalyze_particle_statistics), and to segment the frames searched by EDS again with the settings of the particle size statistics measured after them (EMXSp_Composition_Analyzer.collect_particle_stats_after_eds), so that all the frames of the statistics are segmented alike. The results are added to the frames under a segmentation id: none is replaced.

class autoemx.core.saved_frames.SavedFrames(sample_id: str, microscope_id: str)[source]

Bases: object

Stand-in for the microscope controller: the particle finder analyses saved frames, at their position.

property current_frame_label
show_frame(label: str | None, center_mm, image: ndarray) → None[source]

Set the frame being analysed: its label, position and size.

convert_pixel_pos_to_mm(pos_pixels)[source]
save_frame_image(*args, **kwargs)[source]
autoemx.core.saved_frames.load_frame_image(images_dir: str, frame) → ndarray | None[source]

Greyscale image saved for a frame, or None if it has none.

autoemx.core.saved_frames.segment_frames(frames: Sequence[FrameRecord], saved_frames: SavedFrames, powder_meas_cfg: PowderMeasurementConfig, images_dir: str, segmentation_id: int, sample_dir: str | None = None) → Tuple[Dict[str, FrameSegmentation], List[str]][source]

Segment frames again from their saved images with the segmentation settings of powder_meas_cfg, each among the diameters searched in it: the result of segmentation segmentation_id of each frame (by frame id), and the frames without saved image. With sample_dir, the outlines of the particles of each frame are saved (see particle_outlines).

autoemx.core.saved_frames.resegment_frames(ledger: SampleLedger, sample_dir: str, frames: Sequence[FrameRecord], powder_meas_cfg: PowderMeasurementConfig, source: str = 'reanalysis') → Tuple[int, List[str]][source]

Segment frames of a sample again, from their saved images, with the segmentation settings of powder_meas_cfg: the results are added to the frames (those already segmented with these settings are kept; no result is replaced), and the outlines of their particles saved (see particle_outlines). Frames already segmented with these settings but without saved outlines (segmented before AutoEMX saved them) are segmented again for their outlines, kept only if the same particles are found.

Returns:

  • segmentation_id (int) – Id of the segmentation with these settings (added to the ledger if new).

  • without_image (list of str) – Frames without saved image, not segmented.