annotation#
Annotation mixins add plotting overlays to analyzer image plots. They are
designed as class mixins that compose with Analyzer subclasses through
annotate_image(). The method can be used by itself as well.
annotation.metatext#
Metadata text annotation for image analyzers.
- pyleem.annotation.metatext.format_value(value, value_format=None)[source]#
Return a metadata value formatted for metadata text.
If the value_format is not provided, return the string value.
- pyleem.annotation.metatext.format_unit(metadata_unit, unit_name)[source]#
Return the unit text for a metadata field.
- pyleem.annotation.metatext.format_line(label, value_text, unit_text='')[source]#
Return one metadata text line.
- pyleem.annotation.metatext.format_lines(metadata, metadata_labels)[source]#
Return formatted metadata text lines from metadata and metadata labels.
metadata_labels maps source metadata keys to (display_name, value_format, unit_name) tuples. Dictionary order controls the output order.
- class pyleem.annotation.metatext.MetadataTextMixin[source]#
Bases:
objectMixin that adds selected metadata text to Analyzer image plots.
Inherit from this mixin before the analyzer class, then call annotate_metadata from the subclass annotate_image method.
Example:
class MetadataXPSAnalyzer(MetadataTextMixin, XPSAnalyzer): metadata_labels = DEFAULT_METADATA_LABELS def annotate_image(self, index, ax): ax = super().annotate_image(index, ax) return self.annotate_metadata(index, ax)
annotation.scalebar#
FOV-calibrated scale bar annotations for image analyzers.
- pyleem.annotation.scalebar.scalebar_width(width_um, fov_um, image_width)[source]#
Return scale bar width in pixels.
- class pyleem.annotation.scalebar.ScaleBarMixin[source]#
Bases:
objectAnnotation class that adds a FOV-calibrated scale bar.
Inherit from this class before the analyzer class, then call annotate_scalebar from the subclass annotate_image method.
Example:
class ScaleBarAnalyzer(ScaleBarMixin, Analyzer): def annotate_image(self, index, ax): ax = super().annotate_image(index, ax) return self.annotate_scalebar(index, ax, target_um=5)
- annotate_scalebar(index, ax, target_um=5, bar_width=None, x_margin=20, y_margin=20, thickness=5, color='white', unit_label='um', **kwargs)[source]#
Add a FOV-calibrated scale bar to an image axes.
The scale bar width can be specified. In this case, it skips the FOV calculation and directly uses the bar width pixels. In this case the target_um parameter is purely a label.
annotation.drawroi#
- pyleem.annotation.drawroi.draw_line_roi(ax, roi, color='yellow', linewidth=2, **kwargs)[source]#
Draw a line ROI on an image axes.
- pyleem.annotation.drawroi.draw_rect_roi(ax, roi, color='yellow', linewidth=2, **kwargs)[source]#
Draw a rectangular ROI on an image axes.
- pyleem.annotation.drawroi.draw_oval_roi(ax, roi, color='yellow', linewidth=2, **kwargs)[source]#
Draw an oval ROI on an image axes.
- pyleem.annotation.drawroi.draw_polygon_roi(ax, roi, color='yellow', linewidth=2, **kwargs)[source]#
Draw a polygon ROI on an image axes.
- pyleem.annotation.drawroi.draw_roi(ax, roi, color='yellow', linewidth=2, **kwargs)[source]#
Draw an ROI object on an image axes.