1. Overview of Microscope‐Cockpit - aasmaa11/microscope GitHub Wiki

Microscope is a Python package that provides handlers for different devices used in a Microscope (Laser, Camera, Stage, ...) while Cockpit provides a user-friendly UI to control these devices by communicating with Microscope's handlers.

Cockpit

Architecture

There are four levels to Cockpit, each one of them has its own package: devices, handlers, interfaces and gui. The gui package contains the code related to the user interface; it is where windows, buttons, canvas, checkboxes, etc., are added to the UI. Interactive UI components like buttons and checkboxes can trigger an event or call a function in the interfaces package. The interfaces package calls the corresponding function in the appropriate handler class inside the handler package. The handler class inside the handler package calls the callback function. Callbacks mappings are defined in the class inside the devices package. They map strings to functions in classes inside devices package. These functions call methods from the backend (Microscope) by using an instance of the appropriate handler (the handler is instanciated using Pyro4). The following image sums up how Cockpit works overall.

image

Further documentation about Cockpit can be found in Microscope-Cockpit's online documentation

Microscope

Architecture

Microscope includes several Abstract Base Classes (ABC) for the different device types. These ABC are found in the file microscope.abc and are implemented according to the following hierarchical structure.

image

The devices that are already supported can be found here. However, it is possible to extend these abstract classes and add our own devices. In our case, we have added the ASI stage and the PCO camera handlers. Since we had to add a new stage and camera device to Microscope, we had to make these handlers inherit functions from respectively the Stage and Camera abstract base classes.

Stage Abstract Base Class

The stage superclass contains the following abstract functions that must be implemented by any class that inherits them:

  • axes: Returns a mapping of axis names to their corresponding instances of StageAxis.
  • position: Returns a mapping of axis names to their corresponding current position.
  • limits: Returns a mapping of axis names to their corresponding microscope.AxisLimits.
  • move_by: Takes as input a mapping of axis names to delta values and moves each axis by the corresponding delta value.
  • move_to: Takes as input a mapping of axis names to float values and moves each axis to the corresponding float value.

Camera Abstract Base Class

The camera superclass contains the following abstract functions that must be implemented by any class that inherits them:

  • set_exposure_time: Sets the camera's exposure time to the input float value (expressed in seconds).
  • _get_sensor_shape: Returns the sensor shape as a tuple of integers: (width, height).
  • _get_binning: Returns the camera's current microscope.Binning.
  • _set_binning: Sets the camera's binning to the input microscope.Binning.
  • _get_roi: Retrieves the the camera's current region of interest (ROI) and returns it as microscope.ROI.
  • _set_roi: Sets the camera's ROI to the input microscope.ROI.

It also contains the following non-abstract functions that are not implemented. Hence, they should also be implemented by its subclasses.

  • set_readout_mode: Sets the readout mode with the input description.
  • get_exposure_time: Returns the camera's current exposure time (in seconds).
  • get_cycle_time: Returns the camera's cycle time (in seconds).
  • get_trigger_type: Returns the camera's current trigger mode (TRIGGER_AFTER, TRIGGER_BEFORE or TRIGGER_DURATION)

Further documentation about Microscope can be found in Python Microscope's online documentation.