module documentation

OpenFlexure Microscope autofocus module.

This module defines a Thing that is responsible for using the stage and camera together to perform an autofocus routine, and for collecting stacks of images (a 'z-stack').

See repository root for licensing information.

Class AutofocusThing The Thing concerned with combinations of z axis movements and the camera.
Class CaptureInfo The information from a capture in a z_stack.
Class JPEGSharpnessMonitor A class with direct access to the CameraThing for monitoring the MJPEG stream.
Class SharpnessDataArrays A BaseModel with the position and sharpness data from JPEGSharpnessMonitor.
Class StackParams A class for holding for stack parameters, and returning computed ones.
Exception NoFocusFoundError No focus found during looping Autofocus.
Exception NotAPeakError The data to fit isn't a peak.
Exception NotStreamingError No images captured from stream. The camera is almost certainly not streaming.
Constant EXTRA_STACK_CAPTURES Undocumented
Constant LOGGER Undocumented
Constant MAX_TEST_IMAGE_COUNT Undocumented
Constant MIN_TEST_IMAGE_COUNT Undocumented
Function _count_turning_points Count the number of turing points, after rejecting those from noise.
Function _get_capture_by_id Return the capture from a list of CaptureInfo objects with the matching id.
Function _get_capture_index_by_id Return the index of the capture with the matching id.
Function _get_peak_turning_point Get the turning point for a sharpnesses in a z-stack.
EXTRA_STACK_CAPTURES: int = (source)

Undocumented

Value
15

Undocumented

Value
logging.getLogger(__name__)
MAX_TEST_IMAGE_COUNT: int = (source)

Undocumented

Value
9
MIN_TEST_IMAGE_COUNT: int = (source)

Undocumented

Value
3
def _count_turning_points(sharpnesses: np.ndarray) -> int: (source)

Count the number of turing points, after rejecting those from noise.

def _get_capture_by_id(captures: list[CaptureInfo], buffer_id: int) -> CaptureInfo: (source)

Return the capture from a list of CaptureInfo objects with the matching id.

Parameters
captures:list[CaptureInfo]A list of capture objects
buffer_id:intThe buffer id of the image to return
Returns
CaptureInfothe CaptureInfo object of the capture with matching id
Raises
ValueErrorif buffer_id does not match the buffer_id of any captures
def _get_capture_index_by_id(captures: list[CaptureInfo], buffer_id: int) -> int: (source)

Return the index of the capture with the matching id.

Parameters
captures:list[CaptureInfo]A list of capture objects
buffer_id:intThe buffer id of the image to return
Returns
intthe list index of the capture with matching id
Raises
ValueErrorif buffer_id does not match the buffer_id of any captures
def _get_peak_turning_point(sharpnesses: np.ndarray) -> float: (source)

Get the turning point for a sharpnesses in a z-stack.

Parameters
sharpnesses:np.ndarrayA numpy array of sharpnesses
Returns
floatThe x value of the turning point where x-axis is 0 to N-1 for the N sharpness values
Raises
NotAPeakErrorIf the fit doesn't have a maximum within 95% confidence.