The microscopy package

This page gives a quick overview of the MicroscoPy environment. For more details, refer to the documentation of the individual modules.

Introduction

MicroscoPy is a simple platform for scanning confocal microscopy and spectroscopy in Python. It is controlled entirely from the (I)Python interactive console, with the addition of a few graphic widget to control the instruments and visualise data.

The core modules are:

  • hal: a simple API that makes it easy to integrate new hardware in MicroscoPy

    by wrapping any existing device as microscopy.hal.Actuator or microscopy.hal.Sensor objects.

  • scan: flexible, scalable scanning routines. Multidimensional scans are build from arbitrary

    combinations of unidimensional scans

  • keypad: Tkinter widgets to control actuators from the keyboard

  • display: Tkinter widgets to display camera images and 1D spectra in real time.

The tutorial provide a quick overview of MicroscoPy’s usage:

Hardware abtraction layer

The microscopy.hal module dictates a API for any piece of hardware used in a MicroscoPy application. Two abstract device classes are defined : microscopy.hal.Actuator and microscopy.hal.Sensor, for motion devices (be they linear actuators on analog outputs) and acquisition devices (such as cameras and analog inputs).

The API specification is extremely simple, so it only takes a few minutes to integrate a new piece of hardware to a MicroscoPy application:

The API defines other, optional functionalities.

MicroscoPy includes a few device adapters that wrap existing third-party device drivers into Sensor or Actuator objects (module microscopy.device_adapters):

  • Actuators:
    • ESP: Newport ESP 100 & 300 (based on the driver newportESP)
    • VoltOut: generic analog output
    • Time: no motion, just a time sequence
    • Piezo: smooth voltage trajectory to drive a piezo with minimum ringing
    • ZaberAxis: Zaber ASR microscope stage (driver zaber)
  • Sensors: - Andor: EMCCD cameras (SDK v.2, driver andor2) - Pixelfly: PCO Pixelfly CCD cameras (driver pxlfly) - VoltIn: generic analog input

Reference:

See the the documentation of the microscopy.hal module for the API specification, and to the built-in adapters in module microscopy.device_adapters for working example:

Scanning microscopy

Microscopy tries to keep it simple while being flexible and powerful:

  • 1D scanning is the job of the Scan1D class, which combines an Actuator and Sensor.
  • 2D scanning is done repackaging a Scan1D object as an Actuator and another as a Sensor, and creating another Scan1D object.
  • 3D, and higher-dimensional scans, are created by repeating the process.

Scans can be paused, resumed and extended seamlessly.

Modyfying the behaviour of a scan and interacting with other parts of a larger application is possible via several microscopy.hooks, as described in the module documentation.

Reference:

Graphic user interface

Although MicroscoPy is primarly controlled from the interactive Python console, it also comes with handy (semi-)graphical Tkinter widgets:

  • the microscopy.keypad module provides a microscopy.Tkinter widget to control any number of microscopy.hal.Actuator object from the keyboard. In the example below, a keypad controls a XYZ stage (in reality, one vertical stage and two scanning mirrors) with the Page Up/Page Down, Up/Down and Left/Right keys:

    _images/xyz-keypad.png
  • the microscopy.display module provides a video display for 2D camera data, and another for 1D data (e.g. spectra). The later can optionally include widgets to control data formatting, camera exposure, and information about running scans:

    _images/display-spectrum.png

Reference:

Utilities

MicroscoPy also comes with a couple of small modules providing additional functionalities:

  • the waveform module defines an API for ‘waveforms’, regularly sampled time series. Required by the Piezo device adapter.
  • the interruptible_region module will delay KeyboardInterrupts until it is safe to stop the program.
  • the terminal module provides functions to manipulate and print in the terminal.
  • the plotting module provides widgets to display multiple data, useful for monitoring parameters.