Science blog‎ > ‎

Cheap and lazy gel imager using Raspberry Pi

posted Oct 3, 2017, 9:16 AM by Lindsay Clark   [ updated Oct 4, 2017, 1:23 PM ]
Our lab has a UV transilluminator that we inherited from someone who was retiring, but for taking gel photos we had been reliant on using imagers in other labs.  It's slightly inconvenient (and slightly hazardous) to have to walk around the building carrying an ethidium bromide gel, plus if you don't have a key to the other lab you are dependent on their schedule, and I hate to impose.  I'd been thinking of trying to make an imager using a Raspberry Pi, so when the imager at one of our go-to labs broke down, I finally did it.  I don't know much about optics so I did a bit of research online and found people who had done similar things.

The whole thing cost our lab about $150.  A couple caveats: 1) It doesn't zoom or focus.  I am okay with this since the camera is positioned such that it can get a decent picture of any gel.  If I need a publication-quality image, I'll consider other options.  2)  I just used a styrofoam box rather than buying or constructing something fancier.  We already have the UV transilluminator in a separate room with UV face shields available.  If you want to have this setup out in the open in your lab, you might need a box that will completely contain the light from the transilluminator.

What you need:
 
Raspberry Pi board, camera, power supply, and SD card with operating system.  I find it convenient to just buy a kit, which is just under $100.

MCM Raspberry Pi with Camera kit

A computer monitor, USB keyboard, and USB mouse.  We just get used ones for free from our IT department.  The output on the Raspberry Pi is HDMI, so assuming you have an old monitor without HDMI input like I do, you need a cable that does HDMI to DVI.  This was $8 from Amazon.  Don't let Best Buy convince you that you need a $50 gold-plated cable.
 
DVI to HDMI adapter cable

A cheap pair of reading glasses from the pharmacy.  I bought +2.00 glasses, although since the focus isn't perfect I wonder if a stronger pair would be a little better.  The Raspberry Pi camera has a fixed plane of focus from 1 m to infinity.  The reading glasses bring that plane of focus a bit closer.

An orange camera filter.  This is not strictly necessary but will filter out the glare from the UV lamp and will make the picture much better.  $30, well worth it in my opinion.  (And hey, if I want a publication-quality image, maybe I can just take the orange filter out of my imager and stick it into the lab's DSLR camera, done.)  This is for ethidium bromide gels; if you are working with a dye that emits a shorter wavelength, orange might not be the right choice.

Tiffen Orange 16 filter
Tiffen orange 16 filter opened

A styrofoam box that can fit over your gels, and is about 6" deep in its outer dimensions.  (Note: later I found the focus was better if I lifted the box up so the the camera was about 12" away from the transilluminator.)

Setting up the Raspberry Pi

If you are already a Pi enthusiast, you can probably skip this part.  Otherwise read on!

Open the box.  Before you touch the electronics, touch something metal to discharge any static electricity on your person.

Take the Raspberry Pi board and snap it into the bottom half of the case.  I recommend angling it slightly to put it under the tabs (which are on the side opposite from the HDMI output) rather than trying to put it straight in and muscle past the tabs.  I have weak lady hands so it was a little tricky but I was able to do it.

Take the micro SD card out of its holder (which looks like a regular SD card) and insert it into the Pi.  The SD card slot is on the side opposite the USB ports.  Make sure the contacts are facing the right way when you put it in.

Thread the camera cable through the appropriate slot in the top half of the case, then insert the cable into the slot labeled "camera", again making sure the contacts are facing the right way.  It will look like the picture on the box, except on the box the cable is not passing through the top half of the case like it should.  Snap the top and bottom halves of the case together.  There is also an option to mount the camera inside the case, but for me I couldn't get the Pi correctly positioned over the reading glasses that way, so I used the version with the camera outside of the case.

Plug in the monitor, mouse, keyboard, and ethernet.  (You won't need internet for taking pictures, but it is useful for getting the OS up-to-date.  I just did this in my office, rather than taking it into the transilluminator room at this point.)  Lastly, plug in the micro-USB power supply.  The Pi should boot up.

If you are booting off of a NOOBS card, such as the one that comes with MCM kits, you'll have the option of picking an OS to install.  I recommend Raspbian.  Get that going, and it will take about an hour.

NOOBS launch screen

Here's a picture of the NOOBS launch screen before beginning the installation of Raspbian.  Note in this picture I have the camera mounted inside of the Raspberry Pi case, rather than outside.  I took it back out later when I realized I would need to do it that way.

Once you boot up into Raspbian, you should have a nice, friendly graphical interface with menus, a desktop, etc.  In the upper left there's a picture of a terminal window, which you should click to start the terminal.

To update the OS, type:

sudo apt-get update

after that, there's more that you should update, by typing

sudo apt-get upgrade

Lastly, type

sudo raspi-config

then go into Interfacing Options using the arrow keys and enable the camera.  Test out the camera by typing

raspistill -o ~/Desktop/test.jpg

The picture should now be an icon on your desktop, and if you open it you'll have a picture of the ceiling or whatever else your camera was pointing at.  This is a good opportunity to take some test pictures of a printed sheet of paper to see how far away you will want the camera to be from your gel (i.e., make sure you have the right size styrofoam box).  Maybe get someone to lend you a second pair of hands, holding the reading glasses in front of the camera while you snap some pictures.  The part of the camera board where the cable goes in corresponds to the bottom of the picture, although you can always rotate pictures later.

In the upper left corner of the screen there's a picture of a raspberry, and when you click it there's a menu with a shutdown option.  After you shut down the system, don't unplug the Pi until you see the green light stop flashing and turn off.  The red light will stay on until you unplug the power.

Building the imager

Flip over the styrofoam box.  In the middle, trace around the camera filter.  Position the reading glasses so the middle of one lens is right in the middle of where the filter was, then trace around the reading glasses.

Styrofoam box with camera filter on top, traced in marker
Styrofoam box with reading glasses on top, traced in marker

Cut a hole straight through the box where the "aperture" will be.

Styrofoam box with hole cut through it

Now carve out a shallow trench that the glasses will sit in.  They are going to need to be immediately next to the Pi camera.  Cut a deeper hole for the camera filter to sit in, underneath the glasses.   Widen the aperture as much as you can while still having it hold the filter in place.  Underneath the filter you may even want it to fan out in a cone shape.

Glasses and filter sitting in carved up styrofoam box

Now to mount the camera.  In this picture you'll see that I unfolded a couple large paperclips, bent them nearly in half, then threaded them through the holes in the camera board.  I have also used some packing tape to secure the reading glasses.

Pi camera board in the process of having paperclips threaded through it

Press the paperclips into the box to position the camera right above the reading glasses.  Here I have also secured the Raspberry Pi to the styrofoam box using several pieces of packing tape, on every side that doesn't have some port that I need.

Raspberry Pi and camera mounted on styrofoam box

I took a few test pictures here to make sure that I was happy with it, and also widened the aperture a bit more at this point.  Then I taped aluminum foil over the assembly to block out ambient light.

Camera assembly with aluminum foil taped over it

Here's the final setup on the transilluminator.

Rasberry Pi gel imager setup

Now you can plug it in and boot it up to take pictures just like before, except now you are ready to take pictures of actual gels!  By default, raspistill shows a preview for a couple seconds before taking the picture, in which time I can shift the box a little bit in order to line it up right.

The final product:

Gel image taken with Raspberry Pi

Just like a regular computer, you can stick a USB flash drive into the Raspberry Pi to retrieve your image files.
ą
Lindsay Clark,
Oct 3, 2017, 9:17 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:17 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:17 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:18 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:18 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:18 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:18 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:24 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:28 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:34 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:34 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:34 AM
ą
Lindsay Clark,
Oct 3, 2017, 9:34 AM
Comments