Skip to content


Subversion checkout URL

You can clone with
Download ZIP
MindControl closed-loop computer vision software to manipulate neural activity in a freely moving C. elegans.
C Objective-C C++ Matlab Python

Fix potentially critical bug

On some systems, when using an illumination protocol, errant patterns may be being sent to the DLP.

These patterns occur because the cvCreateImage function does not seem to always initialize images to zero. So here we have added cvSetZero to set the temp image to zero and this has fixed the problem.
latest commit 7fc7cb0597
@aleifer aleifer authored
Failed to load latest commit information.
MyLibs Fix potentially critical bug
.cproject added .project and .cproject back into the repo


Welcome to MindControl


MindControl is a software tool that allows a researcher to utilize optogenetics to manipulate neural activity in a freely moving worm for behavioral neuroscience experiments. MindControl analyzes a video stream of a swimming nematode and in real time it generates an illumination pattern that targets specific neurons or cells within the worm. The software can output these patterns to a digital micrommirror device in a closed loop. In this way, a researcher can train arbitrary pulses of laser light only on specific cells or neurons of a worm as it moves. The software records detailed information about the worm's position, orientation and the state of the system for every frame of the video stream. This data is recorded in a human- and computer- readable YAML file. The software optionally also outputs raw and annotated video streams for later analysis. The MindControl-analysis software suite generates quantitative graphs and figures of nematode behavior based on the output from MindControl.

MindControl is the software component of CoLBeRT (Controlling Locomotion and Behavior in Real-Time) as described in Leifer, A.M., Fang-Yen, C., Gershow, M., Alkema, M., Samuel, A.D.T., "Optogenetic manipulation of neural activity in freely moving Caenorhabditis elegans," Nature Methods, in press (2010).


MindControl is written by Andrew Leifer with help from Marc Gershow. It is a product of the Samuel Lab in the Department of Physics and the Center for Brain Science at Harvard University.

Most Up To Date Version

The most up to date version of the MindControl software will always be available at


With the exception of certain libraries in the 3rdPartyLibs/ folder, all of MindControl is released under the GNU Public License. This means you are free to copy, modify and redistribute this software.

How to Cite

If you use any portion of this code or software in your research, please cite:

Leifer, A.M., Fang-Yen, C., Gershow, M., Alkema, M., Samuel, A.D.T., "Optogenetic manipulation of neural activity in freely moving Caenorhabditis elegans," Nature Methods, in press (2010).


The software was developed on Intel hardware running Windows XP. It was compiled with the MinGW gcc compiler. The software has different requirements depending on whether you plan to compile the code, or run an existing pre-compiled binary. Moreover, there are different compile targets and executables for different hardware environments. For example, to control a micromirror device requires compiling an executable that links to commercial software libraries included with the micromirror device.

Quick Start

The quickest way to get a feel for the software is to run the VritualMC.exe pre-built executable which is packaged in a zip file and availabe for download at VirtualMC.exe will run on any Windows XP system and requires only the included OpenCV 1.1 run-time libraries. No special hardware is required. Follow the README in the zip.

Compiling Your Own Binaries

To utilize camera or micromirror hardware functionality, you will need to compile the software from source.

The code compiles under Windows XP. At a minimum it requires:

  • mingw
  • OpenCV 1.1
  • msysgit
  • make
  • awk

To compile any of the calibration routines additionally requires:


To compile an executable that uses a camera and DLP requires

  • BitFlow framegrabber SDK

See the makefile for more details about the different compile targets.


Please contact Andrew Leifer, leifer (at) fas (dot) with questions or feedback.

Something went wrong with that request. Please try again.