AFL.automation.shared.samplecells#

Geometry and diagnostic plotting for shared sample-cell image pipelines.

Classes

ImageProcessing()

Provide circular ROI, RGB, background, and turbidity processing.

NeutronSampleCell([overrides])

Describe the circular optical region of a neutron sample cell.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

SampleCell([overrides])

Base interface for sample-cell image geometry.

ScrewCapVial([overrides])

Describe the rectangular body of an upright cylindrical screw-cap vial.

class AFL.automation.shared.samplecells.SampleCell(overrides=None, **config)[source]#

Base interface for sample-cell image geometry.

Sample-cell configuration deliberately lives on the cell instead of on a camera or instrument driver. Subclasses should implement extract_sample_image(); they may reuse the image-processing helpers inherited from ImageProcessing.

defaults = {}#
__init__(overrides=None, **config)[source]#
extract_sample_image(image, **kwargs)[source]#

Return the image and mask for the sample region.

save_geometry_plot(raw_image, sample_image, *, save_path, filename, title='Detected sample-cell region', color_order='RGB', overlay_mask=None, show_full_image_axes=True, full_image_x_label='px', full_image_y_label='py')[source]#

Save a reusable full-frame and extracted-region diagnostic plot.

A crop rectangle and circular outline are drawn when the corresponding metadata is present, so subclasses with non-circular geometry can use this routine without supplying neutron-cell-specific fields.

save_mask_comparison_plot(reference_image, measurement_image, mask, *, save_path, filename, title, invert_mask=False)[source]#

Save a reference/measurement mask diagnostic plot.

class AFL.automation.shared.samplecells.NeutronSampleCell(overrides=None, **config)[source]#

Describe the circular optical region of a neutron sample cell.

This is deliberately not a Driver. Instrument drivers hold a sample-cell instance so its crop, circular ROI, and geometry configuration remain independent of camera acquisition and measurement settings.

geometry_defaults = {'col_crop': [0, 479], 'hough_radii': 98, 'row_crop': [0, 479]}#
defaults = {'col_crop': [0, 479], 'hough_radii': 98, 'row_crop': [0, 479]}#
extract_sample_image(image, *, row_crop=None, col_crop=None, hough_radii=None, color_order='RGB')[source]#

Crop image to the cell and locate its circular sample region.

class AFL.automation.shared.samplecells.ScrewCapVial(overrides=None, **config)[source]#

Describe the rectangular body of an upright cylindrical screw-cap vial.

The configured row and column bounds first isolate the complete vial. A band at the top of that crop is then excluded from the sample mask so the screw cap does not contribute to image measurements. cap_height may be supplied in pixels for a calibrated camera; otherwise cap_height_fraction is used relative to the cropped image height.

geometry_defaults = {'cap_height': None, 'cap_height_fraction': 0.2, 'col_crop': [0, 479], 'row_crop': [0, 479]}#
defaults = {'cap_height': None, 'cap_height_fraction': 0.2, 'col_crop': [0, 479], 'row_crop': [0, 479]}#
extract_sample_image(image, *, row_crop=None, col_crop=None, cap_height=None, cap_height_fraction=None, color_order='RGB')[source]#

Crop image to the vial and mask out its screw cap.