module documentation

OpenFlexure Microscope API extension for stage calibration.

This file contains the HTTP API for camera/stage calibration. It includes calibration functions that measure the relationship between stage coordinates and camera coordinates, as well as functions that move by a specified displacement in pixels, perform closed-loop moves, and return the calibration data.

This module is only intended to be called from the OpenFlexure Microscope server, and depends on that server and its underlying LabThings library.

Class CameraStageMapper A Thing to manage mapping between image and stage coordinates.
Class CSMUncalibratedError An Exception raised if camera stage mapping data is needed but unavailable.
Exception MappingError Failure during the Camera Stage Mapping procedure.
Function csm_img_to_stage Apply any CSM matrix to image coordinates.
Function csm_stage_to_img Apply any CSM matrix to stage coordinates to get image coordinates.
Constant SETTLING_TIME Undocumented
Function _csm_matrix_to_string Undocumented
def csm_img_to_stage(matrix: np.ndarray | list[list[float]], *, x: float | int, y: float | int, **_kwargs: int) -> Mapping[str, int]: (source)

Apply any CSM matrix to image coordinates.

x and y must be kwargs and extra kwargs are ignored, allowing: csm_img_to_stage(matrix, **position) to run for a mapping position.

Note that x and y are the actual (x, y) of the image, not the (m, n) indices used by numpy

Parameters
matrix:np.ndarray | list[list[float]]The matrix to use in the calculation
x:float | intthe x image coordinate (keyword only)
y:float | intthe y image coordinate (keyword only)
**_kwargs:intUndocumented
Returns
Mapping[str, int]The resulting stage coordinates as a mapping.
def csm_stage_to_img(matrix: np.ndarray | list[list[float]], *, x: float | int, y: float | int, **_kwargs: int) -> Mapping[str, float]: (source)

Apply any CSM matrix to stage coordinates to get image coordinates.

x and y must be kwargs and extra kwargs are ignored, allowing: csm_img_to_stage(matrix, **position) to run for a mapping position.

Note that x and y are the actual (x, y) of the image, not the (m, n) indices used numpy

Parameters
matrix:np.ndarray | list[list[float]]The matrix to use in the calculation
x:float | intthe x stage coordinate (keyword only)
y:float | intthe y stage coordinate (keyword only)
**_kwargs:intUndocumented
Returns
Mapping[str, float]The resulting img coordinates as a mapping.
SETTLING_TIME: float = (source)

Undocumented

Value
0.1
def _csm_matrix_to_string(mat: np.ndarray) -> str: (source)

Undocumented