top bar

Using the Micro-Manager python library

Revision as of 08:16, 17 May 2013 by Mark Tsuchida (Talk | contribs)

MMCorePy is a python library that wraps the Micro-Manager C++ core (on both Mac and Windows). The library allows you to control microscope hardware from python scripts or a python command line.

Here is how to get started with the Micro-Manager python library:

  1. Download and install Micro-Manager on your computer.
  2. Familiarize yourself with Micro-Manager and learn how to connect it to your hardware by using the existing Java-based GUI (graphical user interface).
  3. Install Python and Numpy:
  4. will be located in the main Micro-Manager directory; it requires many library files in that directory (with suffixes like .dll, .so, .pyd) to operate. At present it is necessary to run python from inside the Micro-Manager directory so that these files can be discovered.

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.

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