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 MicroscoPyby wrapping any existing device as
microscopy.hal.Actuatorormicroscopy.hal.Sensorobjects.
scan: flexible, scalable scanning routines. Multidimensional scans are build from arbitrarycombinations of unidimensional scans
keypad: Tkinter widgets to control actuators from the keyboarddisplay: 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:
microscopy.hal.Actuatormust be extended with two functions,move_to()andposition()(to request a motion and query the position).microscopy.hal.Sensormust be extended with a single functionsnap()that return some data.
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:
- Sensors:
-
Andor: EMCCD cameras (SDK v.2, driverandor2) -Pixelfly: PCO Pixelfly CCD cameras (driverpxlfly) -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
Scan1Dclass, which combines anActuatorandSensor. - 2D scanning is done repackaging a
Scan1Dobject as anActuatorand another as aSensor, and creating anotherScan1Dobject. - 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.keypadmodule provides amicroscopy.Tkinterwidget to control any number ofmicroscopy.hal.Actuatorobject 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:![]()
the
microscopy.displaymodule 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:![]()
Reference:
Utilities¶
MicroscoPy also comes with a couple of small modules providing additional functionalities:
- the
waveformmodule defines an API for ‘waveforms’, regularly sampled time series. Required by thePiezodevice adapter.- the
interruptible_regionmodule will delay KeyboardInterrupts until it is safe to stop the program.- the
terminalmodule provides functions to manipulate and print in the terminal.- the
plottingmodule provides widgets to display multiple data, useful for monitoring parameters.