Correcting Inconsistent Illumination

There are two approaches discussed in this article to correct uneven illumination gradients: prospective and retrospective. Let’s take a closer look.

Prospective Methods

Methods that build corrective functions from reference images are prospective. The authors mention caveats due to incorrect assumptions leading to incomplete corrections of uneven illumination.

 

Reference images are suppose to capture all noise inherent to a system and surroundings; plus any background fluorescence (due to mounting media or specialized substrates). One of the referenced articles recommends capturing reference images across a range of exposure times to create a linear curve for each pixel. Then the noise at each pixel can be subtracted based on the exposure used to capture sample image. Unfortunately, I cannot explore using prospective methods, because I no longer have access to the microscopes used to collect the images I am processing.

Retrospective Single- and Multi-image Methods

Retrospective approaches use only images from the actual experiment. In other words, retrospective methods correct uneven illumination without the use of cell/sample free microscope images. Retrospective methods computationally smooth out intensity gradients.

 

Open-source tools that apply corrections to single images, like ImageJ’s Rolling Ball Correction, are effective. However, when considering a set of images in an experiment, illumination correction per image may not be sufficient, because the correction does not take into consideration all intensities in a set of images. Therefore, the relative intensity of labeled cells across a set of images may be incorrectly changed.

 

Multi-image methods consider groups of images when correcting illumination so that the range of intensities are relatively maintained in these groups. Groups are created based on how cells were immunocytochemicaly labeled and imaged. Let’s use Cell Profiler for applying multiple-image illumination correction.

Illumination Correction with Cell Profiler

On GNU/Linux OS setup Cell Profiler following these steps with Anaconda. The fastest way to start is importing the illumination correction pipeline into Cell Profiler and process your images. The authors of the illumination correction pipeline, described the details of their methodology here.

Select how the illumination function is calculated: “Background” or “Regular”. According to the documentation “Background” is applicable to images with few cells/objects of interest or where few cells are labeled; and “Regular” is applicable when cells cover the entire field of view. For more details and guidance please see the illumination correction pipeline documentation.

 

The following are my examples of the illumination correction process. In each group of three images below are my original image, the illumination function, and the processed image with corrected illumination. As you can see the results are impressive. The illumination gradients were corrected and the dynamic range increased due to a reduction in the background intensity. What I find most impressive was the removal of an artifact in the third image! In comparison, changing the brightness, contrast, and applying a threshold manually would not be as effective. The advantage of using software that creates a robust illumination correction function is evident in these examples.

Python and Command Line for Processing 4000+ Images

In an attempt to process a large batch of images and eventually create a workflow integrating multiple software I tried using Python but there was very little documentation on how to use Python to run Cell Profiler. So, I opted for running Cell Profiler from the command line. After several failed attempts and creating a bash script, I successfully ran the pipeline at the command line interface. I mentioned my issues on GitHub and the CellProfiler community was responsive – which is great!

Regex in CellProfiler’s Metadata Module

 

At first, I created a list of images using Python to feed into the CellProfiler at the command line. However, I then realized, one can use filters and regular-expressions in CellProfiler’s Images, Metadata, and NamesAndTypes modules to create images sets in the Groups module. This is one of CellProfiler’s strengths. The combination of string matching and reg-ex makes carving out image sets from files, spread out in folders and sub-folders, possible.

Prior experience using regular expressions was extremely useful in Cell Profiler. Even without much experience determining the correct regular expressions was good practice/training because you can see what meta data is being captured as the regular expression is crafted. Furthermore, you can see what images are filtered as you build and improve your filters and reg-ex. Thus, CellProfiler allows you to quickly iterate what images are included or excluded your analysis.

 

One limitation was creating image sets with missing channels (fluoresce emission wavelengths). For example, I didn’t have CY5 fluorescence in all experimental repetitions so I had to ignored CY5. Otherwise, I would’ve had very few image sets to use in my analysis. In other words if one channel is missing all images in the set are not processed.

Cell Profiler Mini Review and Performance

Once you get the hang of cell profiler it is extremely useful. It took some trial an error to get the idea of how to run CellProfiler. However, I recall a similar learning curve when getting started with ImageJ and/or Metamorph. One minor “gotcha” was realizing the difference between Start Test Mode and Analyze Images. Start Test Mode, will only run the pipeline for one image. Once you successfully run one image you can then use Analyze Images to run the pipeline for all images.

I chose “Background” and applied the illumination correction created from a batch of images. After some good trial and error I successfully applied image correction to my first set of images and eventually to a large data set with many images. However, the learning curve is worth getting over because of what can be accomplished using Cell Profiler.

On a 3.4GHz quad core AMD A10 and 8GB of memory with a swap (virtual memory) of 8GB, I couldn’t completely process approximately 2300 image sets, with two images in each set. Memory was consumed and at some point images stopped processing. You can limit resources to prevent the computer from hanging and having to force quit or reboot. For example, the number of CPU cores used can be changed in File>Preferences>Maximum Number of Workers. Either way, I was able to processing smaller batches of images successfully. Note, save your work often because I did experience program crashes when setting up image selection filtering, metadata (regex) extraction, and image set grouping.

Once I managed to run CellProfiler without the GUI using the command line performance improved significantly.

 

Next, let’s take a look at segmentation!