magscope.python_microscope

Contents

magscope.python_microscope#

Classes#

PythonMicroscopeHardwareManagerBase

Base class for hardware managers backed by python-microscope devices.

PythonMicroscopeFocusMotor

Focus motor adapter for a python-microscope stage or stage axis.

PythonMicroscopeCamera

Camera adapter for python-microscope devices and device-server URIs.

PythonMicroscopeHardwareManager

Concrete alias for users who only need the connection helper mixin.

Module Contents#

class magscope.python_microscope.PythonMicroscopeHardwareManagerBase(*, device: Any | None = None, device_factory: collections.abc.Callable[[], Any] | None = None, device_uri: str | None = None, device_getter: collections.abc.Callable[[Any], Any] | None = None)[source]#

Bases: _PythonMicroscopeDeviceMixin, magscope.hardware.HardwareManagerBase, abc.ABC

Base class for hardware managers backed by python-microscope devices.

connect() None[source]#
disconnect() None[source]#
class magscope.python_microscope.PythonMicroscopeFocusMotor(*, axis_name: str = 'z', device: Any | None = None, device_factory: collections.abc.Callable[[], Any] | None = None, device_uri: str | None = None, device_getter: collections.abc.Callable[[Any], Any] | None = None, position_scale: float = 1.0)[source]#

Bases: _PythonMicroscopeDeviceMixin, magscope.hardware.FocusMotorBase

Focus motor adapter for a python-microscope stage or stage axis.

axis_name = 'z'[source]#
position_scale[source]#
_axis: Any | None = None[source]#
_moving_target: float | None = None[source]#
connect() None[source]#
disconnect() None[source]#
move_absolute(z: float) None[source]#

Command the motor to move to an absolute Z position.

get_current_z() float[source]#

Return the motor’s reported current Z position.

get_is_moving() bool[source]#

Return the motor’s reported moving state.

get_position_limits() tuple[float, float][source]#

Return the allowed absolute Z limits for this motor.

_resolve_axis(device: Any) Any[source]#
_require_axis() Any[source]#
_to_device_units(z: float) float[source]#
_from_device_units(z: float) float[source]#
class magscope.python_microscope.PythonMicroscopeCamera(*, width: int, height: int, dtype: numpy.dtype, bits: int, nm_per_px: float, settings_map: collections.abc.Mapping[str, str] | None = None, readout_transform: tuple[bool, bool, bool] | None = None, device: Any | None = None, device_factory: collections.abc.Callable[[], Any] | None = None, device_uri: str | None = None, device_getter: collections.abc.Callable[[Any], Any] | None = None)[source]#

Bases: _PythonMicroscopeDeviceMixin, magscope.camera.CameraBase

Camera adapter for python-microscope devices and device-server URIs.

settings = ['framerate'][source]#
width[source]#
height[source]#
dtype[source]#
bits[source]#
nm_per_px[source]#
settings_map[source]#
_last_fetch_time = 0.0[source]#
_fps_estimate = 0.0[source]#
_fetch_count = 0[source]#
_fps_window_start[source]#
_readout_transform = (False, False, False)[source]#
connect(video_buffer) None[source]#

Attempts to connect to the camera.

But does not start an acquisition. This method should set the value of self.is_connected to True if successful or False if not.

fetch() None[source]#

Checks if the camera has new images.

If the camera has a new image, then it holds the camera’s buffered image in a queue (self.camera_buffers). And stores the image and timestamp in the video buffer (self._video_buffer).

The timestamp should be the seconds since the unix epoch: (January 1, 1970, 00:00:00 UTC)

release() None[source]#

Gives the buffer back to the camera.

release_all() None[source]#
get_setting(name: str) str[source]#

Should return the current value of the setting from the camera

set_setting(name: str, value: str) None[source]#

Should set the value of the setting on the camera

shutdown() None[source]#
static _build_settings(settings_map: collections.abc.Mapping[str, str]) list[str][source]#
static _grab_frame(device: Any) tuple[Any, float][source]#
_update_framerate_estimate(timestamp: float) None[source]#
class magscope.python_microscope.PythonMicroscopeHardwareManager(*, device: Any | None = None, device_factory: collections.abc.Callable[[], Any] | None = None, device_uri: str | None = None, device_getter: collections.abc.Callable[[Any], Any] | None = None)[source]#

Bases: PythonMicroscopeHardwareManagerBase

Concrete alias for users who only need the connection helper mixin.

abstractmethod fetch() None[source]#

Checks if the hardware has new data.

If the hardware has new data, then it stores the data and timestamp in the matrix buffer (self._buffer).

The timestamp should be the seconds since the unix epoch: (January 1, 1970, 00:00:00 UTC)