Microscope class

The main microscope class handles microscope settings, passing these between the settings file and their appropriate components (camera, stage), basic metadata about the current device status, and interfacing with the separate camera and stage components.

Defines a microscope object, binding a camera and stage with basic functionality.

class openflexure_microscope.microscope.Microscope(settings=<openflexure_microscope.config.OpenflexureSettingsFile object>, configuration=<openflexure_microscope.config.OpenflexureSettingsFile object>)[source]

A basic microscope object.

The camera and stage objects may already be initialised, and can be passed as arguments.

lock = None

Composite lock for locking both camera and stage

Type:labthings.CompositeLock
camera = None

Currently connected camera object

stage = None

Currently connected stage object

close()[source]

Shut down the microscope hardware.

setup(configuration: dict)[source]

Attach microscope components based on initially passed configuration file

set_stage(configuration: Optional[dict] = None, stage_type: Optional[str] = None)[source]

Set or change the stage geometry

has_real_stage() → bool[source]

Check if a real (non-mock) stage is currently attached.

has_real_camera() → bool[source]

Check if a real (non-mock) camera is currently attached.

state

Dictionary of the basic microscope state.

Returns:Dictionary containing complete microscope state
Return type:dict
update_settings(settings: dict)[source]

Applies a settings dictionary to the microscope. Missing parameters will be left untouched.

read_settings(full: bool = True) → dict[source]

Get an updated settings dictionary.

Reads current attributes and properties from connected hardware, then merges those with the currently saved settings.

This is to ensure that settings for currently disconnected hardware don’t get removed from the settings file.

save_settings()[source]

Merges the current settings back to disk

force_get_metadata() → dict[source]

Read cachable bits of microscope metadata. Currently ID, settings, and configuration can be cached

get_metadata(cache_key: Optional[str] = None)[source]

Read microscope metadata, with partial caching