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.Actuator
ormicroscopy.hal.Sensor
objects.
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.Actuator
must be extended with two functions,move_to()
andposition()
(to request a motion and query the position).microscopy.hal.Sensor
must 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
Scan1D
class, which combines anActuator
andSensor
. - 2D scanning is done repackaging a
Scan1D
object as anActuator
and another as aSensor
, and creating anotherScan1D
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 amicroscopy.Tkinter
widget to control any number ofmicroscopy.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: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:
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 thePiezo
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.