Micro-Manager on the Raspberry Pi
Micro-Manager is an open source platform for controlling microscope hardware, automating image acquisition, and tracking metadata about how images are acquired. In biomedical imaging research, it serves as an incredibly important tool because it is free and open source, which means that scientists can benefit from the contributions of others to the software without paying costly licensing fees.
I recently managed to compile Micro-Manager version 2.0 on the Raspberry Pi. I did this for a small hobby project I am working on to build a cheap yet effective tool for at-home microscope projects and hacking. Though I am not yet convinced that Micro-Manager will be the best tool for this particular job given it's relatively heavy footprint on the Pi's slower hardware, I thought that I would post my notes so that others could benefit from my experience.
Software versions
I am working with a Raspberry Pi 3 Model B:
pi@raspberrypi:~ $ uname -a & gcc -dumpversion & make -v & ldd --version Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux pi@raspberrypi:~ $ gcc -dumpversion 4.9.2 pi@raspberrypi:~ $ make -v GNU Make 4.0 pi@raspberrypi:~ $ ldd --version ldd (Debian GLIBC 2.19-18+deb8u7) 2.19
Building MM
Once I was able to mount the share containing 3rd party libraries, I installed the following packages on the Pi and checked out the Micro-Manager source code:
sudo apt-get install autoconf automake libtool pkg-config swig ant libboost-dev libboost-all-dev cd ~/src/micro-manager git clone https://github.com/micro-manager/micro-manager.git cd micro-manager git checkout mm2
The last command switches to the mm2 branch where the Micro-Manager
2.0 source code is found. Note that it may not be necessary to install
all of the boost libraries with sudo apt-get install
libboost-all-dev
, but I did this anyway because I encountered
multiple errors due to missing boost library files the first few times
I tried compiling.
The next step follows the normal Micro-Manager build routine using make, with the exception of the configuration step. From inside the Micro-Manager source code directory on the Pi, run the following commands one at a time:
./autogen.sh PYTHON=/usr/bin/python3 ./configure --prefix=/opt/micro-manager --with-ij-jar=/usr/share/java/ij.jar --with-python=/usr/include/python3.4 --with-boost-libdir=/usr/lib/arm-linux-gnueabihf --with-boost=/usr/include/boost make fetchdeps make sudo make install
In the configuration step, I set the Python interpreter to Python 3
because I greatly prefer it over Python 2. This is done by setting the
PYTHON environment variable before running
configure. --prefix=/opt/micro-manager/ indicates the preferred
installation directory of
Micro-Manager. --with-ij-jar=/usr/share/java/ij.jar is the path to
the ImageJ Java library, though I am uncertain whether this was
necessary. (I installed ImageJ with a sudo apt-get install
imagej
a while ago.) --with-python=/usr/include/python3.4 should
point to the directory containing the Python.h header file for the
version of Python you are compiling against. with-boost-libdir
should point to the directory containing the boost libraries (.so
files). This was critical for getting MM2 to build. If you are unsure
where they are located, you can search for them with sudo find
/ -name "libboost*"
. Finally, the last option, with-boost, may or
may not be necessary. I set it to the directory containing the boost
headers but never checked to see whether MM compiles without it.
If all goes well, Micro-Manager will compile and install without problems. Compilation time on my Pi took around one hour.
Set the maximum amount of direct memory
In the next step, we need to make a minor edit to the Micro-Manager Linux start script. Edit the script (/opt/micro-manager/bin/micromanager) to reduce the maximum direct memory to something reasonable:
/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/bin/java -Xmx1024M \ -XX:MaxDirectMemorySize=1000G \ -classpath "$CLASSPATH" \ -Dmmcorej.library.loading.stderr.log=yes \ -Dmmcorej.library.path="/opt/micro-manager/lib/micro-manager" \ -Dorg.micromanager.plugin.path="/opt/micro-manager/share/micro-manager/mmplugins" \
Change 1000G to 512M or 256M; otherwise the Pi will complain that the MaxDirectMemorySize of 1000G is too large. You can start Micro-Manager by running this modified script.
What's next?
Though Micro-Manager compiles and runs on the Pi, I have not yet tested it thoroughly acquisitions. I am currently waiting on a camera board to arrive in the mail, and when it does, I will attempt to interface with it through Micro-Manager. Though I could write my own Python library, Micro-Manager is appealing because it can save a lot of time by providing a ready-made means to annotate, process, and store imaging data.
Running Micro-Manager on the Pi also raises the possibility of a fully open, embedded biomedical imaging platform, though I am uncertain at the moment whether the hardware on the Pi is up to the task. If you manage to do anything cool with Micro-Manager and the Raspberry Pi, please let me know in the comments!
Comments
Comments powered by Disqus