I wrote this for a client, but figured others could make use of it. This code simply captures a number of images as defined by the user, and saves them to the specified folder without displaying them. This is useful if you don’t want all of the images open in memory during a timelapse.
So I needed to set up an Arduino Mega as a signal processor. I had a sawtooth signal coming from a device, and I wanted to convert that signal to a 0/5V TTL signal. Now, with something like a sine or sawtooth wave, the question becomes, “At what point do I want to consider this signal to be “ON”?” This is where a comparator comes in. Basically, a comparator references a different voltage you supply, and compares your supplied voltage to the measured voltage. There’s a detailed example of how this works using an Arduino in this instructable.
Now, that ‘ible is nice, but note it’s written using an UNO, and unbelievably, the Mega 2560, a more capable board, DOESN”T have the AIN0 pin connected to a breakout line!!!
Mega 2560 Pin Mapping
Looking closely at this pinout, we’ll see that indeed, AIN1 is mapped to D5, but AIN0 is just out there with no love!!
So what to do?
Well, I considered just soldering a tap directly to the pin, but I was afraid of thermal issued in doing this, and it’s a small pitch, so instead I looked around a bit more at the functions used for the cmparator (ACSR Command) in the Atmel docs. It turns out, there’s an on board reference (1.1V) which can be used w/ AIN0. This is called using the ACSR command, and I went ahead and used that, as for my needs it worked great. BUT, Your mileage may vary.
Here’s an example of the code I used:
void setup()
{
pinMode(5,INPUT);
pinMode(40,OUTPUT);
digitalWrite(40,HIGH);
//Serial.begin(9600);
ACSR = B01011000; // comparator interrupt enabled and tripped on falling edge.
}
/*ACSR =
(0<<ACD) | // Analog Comparator: Enabled
(0<<ACBG) | // Analog Comparator Bandgap Select: AIN0 is applied to the positive input
(0<<ACO) | // Analog Comparator Output: Off
(1<<ACI) | // Analog Comparator Interrupt Flag: Clear Pending Interrupt
(1<<ACIE) | // Analog Comparator Interrupt: Enabled
(0<<ACIC) | // Analog Comparator Input Capture: Disabled
(1<<ACIS1) | (1<ACIS0); // Analog Comparator Interrupt Mode: Comparator Interrupt on Rising Output Edge
*/
volatile boolean sOn=false;
unsigned long timer;
void loop()
{
if(sOn)
{
digitalWrite(40,!digitalRead(40));
sOn=false;
delay(10);
}
}
ISR(ANALOG_COMP_vect)
{
sOn=true;
}
Here’s the output generated from this code against my source wave, the red channel shows the behavior of my output pin. I’m happy with the result, and it’s fun to learn (another) cool thing that the Arduino can do!
Here’s a simple method to deal with varying intensities in a large run of images, assuming you have a known number of cells in a field. If I assume I should see, say, more than X cells per area, I can adjust my threshold to slowly increase it’s aggressiveness until that minimum counted value is met. The code can be downloaded as an imageJ macro here. but here’s a walk through of this simple script. My comments are preceded by a *.:
rnum = 0; *this creates a new variable, or container, for our # of regions
tval = 2000; *this is the starting object threshold value.
while (rnum<500) *this is a "while" loop. The loop runs until the argument is satisfied.
{
setAutoThreshold("Default");
setThreshold(tval, 4095); *note that tval = the minimum threshold value
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Nothing display clear add");
rnum = roiManager("count");
tval = tval - 100; *tval continues to become more aggressive in counting objects until the argument is met.
}
Simple routines like these can reduce your headache factor by a large margin if you learn how to harness the power of macros!
89 North has asked me to cook up a driver for the PhotoFluor 2, which I am now hosting under my Macros & Journals page, or you can use this link. This driver works in NIS Elements AR, and BR with Advanced Interpreter.
Please contact me if you have any trouble using it!
When acquiring images in NIS Elements, it is possible to acquire each image with a color over that is approximate to the wavelength used for acquisition. This is the easiest way to view and relate multi-channel data, but when converting the images for export to other programs, it cam become a problem.
In the image below I have two channels acquired – DAPI and FITC. If you note the overlay each of the two channels are completely independent.
Original 2 Channel Image
If I now use the Image -> Convert -> Convert to RGB command, some of the green and blue signal will be mixed within each other, and some of each channel will mix into the red channel:
Image Converted to RGB and now color mixed
So what causes this? If you note the channel data in the original image, the color is not a pure green. The 488nm and 405nm alexa dyes actually emit in blue-green hues and green-orange hues. So if we were to attempt to measure signal intensities in the RGB image using another program, our measurements would be invalid. In order to avoid this, you can modify and use this macro, which will force the channels to pure Blue, Green and Red colors. With these color settings no color mixing will occur in the conversion.
After a few requests for a report on x64 capability using this tethering technique, I tried installing the NK Remote software on a rather fresh copy of Windows 7×64 – it did not communicate with the camera at all. On the other hand, the open source application “DigiCamControl“, worked perfectly. Now, as far as micro-manager goes, there isn’t a connection from DigiCamControl to micro-manager. So – short term solution is to run the proposed setup below on an x32 system – if anyone gets x64 working please post here!!! -Austin
So I had a customer interested in a macro application for scanning. In some cases, applications like these don’t require a telecentric optical system such as the AZ-100, nor do they fit into a typical stereo microscope application. So, what to do? Well, when your object for imaging is too large for a microscope, one option may be a macro lens on a digital camera. Something like this:
Copy stand for SLR
This type of system will allow for a stable focusing and zoom setup, but is limited in magnification power and light control. In some cases though, this is the way to go.
The next problem is that of focal and positional control. No microscopy device control software available, such as elements or metamorph, supports non-scientific grade cameras. So, how do we position a specimen under this camera in an automated fashion? Well, it turns out micro-manager has a plugin available for such work, and it’s available in the nightly builds here .
What you end up with is a camera that can be controlled from a laptop, along with a stage, z motor and other automated imaging hardware. Here’s an example of my setup running on a windows 7 x64 laptop and a D80.
D80 and Win7 x64
Requirements
This setup requires the following items:
1. Suitable camera and lens (see below)
2. Copystand for camera.
3. Computer for control.
4. External power supply for camera or a battery extension (more for ease of use but I consider it a requirement).
5. USB Cable to camera.
6. Control Software for interfacing to uManager. This is pay-for software, found here. The software currently ranges from $90-180.
So, follow the instructions found here for setup. My summary of setup, which took a whopping 5 minutes (this is amazingly quick for open source software!) went as follows:
1. Download Breeze Systems trial for NKRemote & Install.
2. Download nightly uManager build & Install.
3. Set camera to PTP mode.
4. Run NKRemote and snap image to confirm communication with camera.
5. Run uManager. Edit hardware seup using the “Setup hardware” tool and removed the demo camera, and added the NikonDSLR.
6. started snapping images! Here is an example of running in uManager (click on the picture for a higher res version):
Nikon D-80 acquiring images in uManager
What cameras are supported:
All of the basic DSLR models from Nikon are included with the NKRemote software. Tethercam is the driver used for the uManager side, and it states an “incomplete list” of cameras as follows:
Some lenses that work as portrait lenses like a Nikon 50mm will work adequately as macro lenses. On the other hand, it’s recommended to shell out the extra cash for a well-made macro lens, such as this one. The nice thing about working with commonly available photo gear is that in many cases you can even rent lenses to see what works best for the job at hand.
This was a fun and quick test and I am excited to see how this capability is used for macro work in the future!
I’ve been running into a lot of programming applications lately. The fun part about using the Elements (or other) programming system is the amount of utility and flexibility it can offer to end users. Most people think about programming in our industry only as it relates to image analytics. I wanted to point out some other things macros can do for you:
Acquisition & Device Automation
Do you have a stimulus device or method you want to trigger from your acquisition software? Almost every device on the market (FRAP illumniators, Profusion systems, heating systems, electrical signaling systems) can accept a command input from TTL. You can use Elements (or other software) to control the parallel port on your computer – giving you control of the device you already have. A macro can tell the device to start, stop, adjust a setting and can then record that command into elements (i.e. at what time point in a timelapse the command was issued).
User convenience
Are you always pressing the same buttons in software to control the microscope? You can use macros to assign keyboard keys to run special functions. For instance when you press the “0” key on the number pad you can make the microscope load a “DAPI” illumination setting and acquire an image.
User interaction
Do you only run a few experiments over and over? You may be working harder than needed by re-configuring your software to image with a specific protocol. You can use a macro to configure all of the settings you want in one operation, and then dial in specific changes you may want to adjust before acquisition.
In general any button you press, number you enter or menu you click can automatically be performed inside of a macro. Keep this in mind any time you are repeatedly clicking on the same things and slowing down your work!!
EXAMPLE DOWNLOAD You can find an example macro for use in Elements here. Open Elements, open the Macro menu and click Edit (or press F8) and copy the code from this page into the empty macro. Then just save and run it!