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!
Over the course of my career, I’ve flown across the US to attend a variety of imaging related instructional courses, all on the eastern seaboard. We are all familiar with the Woods Hole courses, the AQLM course, and so forth. What has boggled my mind is that here I am in the SF Bay area, surrounded by arguably the most densely populated and diverse centers of biological science innovation on earth, and there’s no major course?
I started pestering the owners of Technical Instruments about this one night, and they admitted the same question had long been on their minds. A few months later, we asked the NIC team at UCSF about it, and found to our surprise that they were already cooking something up. We offered to help as needed, and have been doing what we can to help support the course ever since.
If you are a regular reader of my blog, I’ll assume you’re involved enough in imaging that you would stand to gain much from attending the course. This won’t be a “sit in classes all day” kind of deal. The course has been designed around a kinesthetic approach, with lectures taking roughly 50% of the time, and the other 50% being hands-on bench work.
Yesterday we received our first shipment of Sola white light LED driven sources for microscopy. I had a chance to snag one and write a driver for it. Price is $300 USD. The driver controls both the shuttering and ND on the box, and integrates easily into Elements as a shutter and ND filter wheel.
I’ve written a Lumencor Spectra Driver that works with NIS Elements B3.2+. (AR or BR + Advanced Interpreter) The driver provides integrated control into elements for both intensity of lines and channel. These appear as a shutter and two filter wheels, offering full integration into Elements’ Optical configurations. We are selling it for $750, including online install on your system. Please contact me if you’d like to try it out!
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 installing a new imaging system it’s common to receive a phone call or email that goes like this, “The IT guys stopped by today and added our computer to our comany/university network. Now all of our settings are lost!”. Why does this happen and what can be done?
All settings for elements are stored on a per-user basis. When a different user logs in (i.e. the user assigned from a company network vs. the default user that is installed on the PC) the software expects that user to want his or her own settings. Thus no settings are copied over. In the majority of cases this should NOT be the use case for a user group. In my experience almst everyone would like to start with the “default settings” and then modify them to their needs. For now there isn’t a copy button available, so we need to manually copy the settings.
Getting Started:
Copying settings is actually a simple process if done correctly. A few notes on this:
When moving to a new domain or user, don’t delete the old user until the new user setup is working well for you!
Make sure to copy the backup files we generate to a common directory. For instance don’t save to the “desktop” when logged in as administrator, as non-admin accounts may not get access to the admin desktop, leaving you no way to snag the needed backup files. Instead copy the backup files into a folder like c:Elements_settings.
Backing up:
We need to back up 3 items: Program menu/docker layouts, optical configurations and macro settings.
With the program running and all devices connected, click the “explore optical configurations” button.
There are two backup buttons here. First click the Backup button that sits between the optical configs and the camera/scope settings. Save the file to back up the settings. Secondly click the backup button below the objective list. Name this backup_objectives.
Once these files are backed up we can close the optical configuration window. Next we will back up the menu layouts and docker settings. To do this select the View menu, then Layout, then Layout Manager.
In the layout manager we will export the current layout to an xml file. ***because all of these files are *.xml be sure to name them descriptively so you can figure out which file is for what backup later.
Next we will check up on our macros. In some installations macros may be configured to run every time elements starts. In these cases when users are switched these “start-up macros” will need to be re-specified. To check if you are running any startup macros, go to the Macro menu, then select Options. In the window on the left-hand side you’ll see any macros that are set to load when elements starts, as well as whether those macros are activated as “start-up”. See the example below where I have one macro set as a start-up macro.
Make sure to find where this macro file sits on the computer so that we can add it into the new user account later. This can be found by viewing the “full path” info below the white macro box.
Copying Over
With the backup complete we can log out of the current user and log in to our new user. Once logged in as the new user launch Elements.
Open the optical configurations window. Click the Restore button below the objectives list and load the objectives backup file.
Click the restore button next to the optical configurations and load the optical config backup file you saved earlier.
Select the View menu, then layouts, then layout manager. Click the “Import Layouts” button and select the layout file backed up earlier.
If you had any startup macros selected, click the Macro menu, then Options. Add any macros needed and set them to startup if required.
Test the system to make sure the previous user account settings have been transferred successfully.
Hopefully this guide will help users when needing to copy settings to new user accounts. There is nothing wrong with using the same three or four backup files and loading them into multiple user accounts as well! Please post here or email me if you’d like to see any additions or changes made to this entry.