top bar

Using the Micro-Manager python library

Revision as of 10:00, 8 June 2014 by Radioxoma (Talk | contribs)

MMCorePy is a wrapper that allows you to control microscope hardware from python interactive session or scripts. It's support Windows, Mac and Linux.

Micromanager's main parts:

  • CMMCore - basic module, written in C++. Script languages like python just wrap it by swig.
  • Device adapters - various libraries that allow support for various hardware. If you want to built one and extend MM devise support, feel free to use SDK.
  • MMCorePy - python wrapper. MM build scripts are support both python 2 and 3, but windows version ships with python 2 bindings only.
  • MMCoreJ - java wrapper
  • MMStudio - Micromanager GUI (technically it is ImageJ plugin).

Environment setup

You must install python2 and numpy. Windows users may prefer using an python distribution instead manual separate installation.


  • python 2.7.x (python2 is default for windows now)
  • numpy 1.7.x Micormanager represent imaging data as multidimensional numpy arrays.

Using python distributions

It's convenient to install a distribution which includes Python, numpy, scientific libraries, GUI frameworks and IDEs. All distributions have a free version, some of them have extended paid version, but you can request free academic license.

Useful libraries

  • Scipy - scientific algorithms, multidimensional image processing toolbox.
  • Matplotlib - fastest way to show your image data.
  • Opencv - computer vision and image processing library. Sometimes faster than scipy.
  • Pillow - very basic image processing. Scipy uses it for image loading and writing.
  • Scikit-image - "pythonic" scientific-oriented image processing algorithms collection.
  • IPython - improved interactive python environment

Micromanager installation

Windows & Mac

Download and install Micro-Manager on your computer. Add Micromanager installation folder to PYTHONPATH (i.e. "C:\Program Files\Micro-Manager-1.4", it should contain and _MMCorePy.pyd files). Create variable if it not exist. At now you can import MMCorePy without an error.


MM package from your distribution repository, in most cases, ships with CMMCore, MMCorePy (python 2 or 3 wrapper) and MMCoreJ, but without GUI. At least your system variables should be already configured properly. Python and Numpy would be installed by your package manager as dependency.

First steps

Familiarize yourself with Micro-Manager and learn how to connect it to your hardware by MMStudio GUI.

Images returned by calls to an instance of the pythonized Micro-Manager core class (CMMCore) are stored in numpy arrays for convenience, and can be easily displayed by pylab (matplotlib) commands. Here is a short example (using matplotlib) that demonstrates use of the python wrapper to acquire and display an image.

# Create a Micro-Manager core object:
import MMCorePy
mmc = MMCorePy.CMMCore()

#  Load and initialize the demo camera device:

# Snap and retrieve an image:
im1 = mmc.getImage()

# Display the image:
from pylab import *
ion() # Activate interactive mode
imshow(im1,cmap = cm.gray)

A longer example script,, is available in the Micro-Manager root directory.

Also check out micromanager-samples repo for python code samples (live video acquisition, property discovery etc).

Further reading

Micromanager code

Written by Eugene Dvoretsky -- Radioxoma (talk) 10:00, 8 June 2014 (PDT)

© Micro-Manager : Vale Lab, UCSF 2006-2011 | All Rights Reserved | Contact