magscope.utils#

Classes#

AcquisitionMode

Enum for acquisition modes.

PoolVideoFlag

Enum where members are also (and must be) ints

Units

Functions#

crop_stack_to_rois(stack, rois)

numpy_type_to_qt_image_type(numpy_type)

date_timestamp_str(timestamp)

register_script_command(command_type)

Decorator marking a method as callable from a MagScope script.

check_cupy(→ bool)

Return True when the CuPy package is usable.

Module Contents#

class magscope.utils.AcquisitionMode[source]#

Bases: enum.StrEnum

Enum for acquisition modes.

The UI redesign changed the enum values to match the new display labels. Existing scripts that compare or pass raw strings should update old values such as "video (full)" to the new values such as "Video (Full)". The old member names remain as aliases so scripts using AcquisitionMode.FULL_VIDEO continue to resolve to the new canonical mode.

TRACK = 'Track'[source]#
TRACK_AND_VIDEO_ROIS = 'Track and Video (ROIs)'[source]#
TRACK_AND_VIDEO_FULL = 'Track and Video (Full)'[source]#
VIDEO_ROIS = 'Video (ROIs)'[source]#
VIDEO_FULL = 'Video (Full)'[source]#
TRACK_AND_CROP_VIDEO[source]#
TRACK_AND_FULL_VIDEO[source]#
CROP_VIDEO[source]#
FULL_VIDEO[source]#
magscope.utils.crop_stack_to_rois(stack, rois)[source]#
magscope.utils.numpy_type_to_qt_image_type(numpy_type)[source]#
magscope.utils.date_timestamp_str(timestamp)[source]#
class magscope.utils.PoolVideoFlag[source]#

Bases: enum.IntEnum

Enum where members are also (and must be) ints

READY = 0[source]#
RUNNING = 1[source]#
FINISHED = 2[source]#
class magscope.utils.Units[source]#
m = 1.0[source]#
cm = 0.01[source]#
mm = 0.001[source]#
um = 1e-06[source]#
nm = 1e-09[source]#
N = 1.0[source]#
mN = 0.001[source]#
uN = 1e-06[source]#
nN = 1e-09[source]#
pN = 1e-12[source]#
fN = 1e-15[source]#
ms = 0.001[source]#
us = 1e-06[source]#
ns = 1e-09[source]#
ps = 1e-12[source]#
fs = 1e-15[source]#
magscope.utils.register_script_command(command_type: type[magscope.ipc_commands.Command])[source]#

Decorator marking a method as callable from a MagScope script.

Each script command must be paired with the IPC Command that will be dispatched when the script executes that step. The decorator mirrors magscope.ipc_commands.command_handler() by attaching metadata to the wrapped function without constraining how it is collected.

magscope.utils.check_cupy() bool[source]#

Return True when the CuPy package is usable.