Cell Profiler is a wonderful software for batch processing of cell images, but the available functions are limited compared to ImageJ. Luckily, Cell Profiler included the capability to run ImageJ macros, which is a simple way to import functions otherwise not available. This article will walk through the steps required to call an ImageJ macro through Cell Profiler itself.
We need to add the “RunImageJMacro” to the Cell Profiler pipeline, which can be found under the “Advanced” modules (Figure 1). This module has several inputs: pointer to the executable (Fiji folder and ImageJ.exe), pointer to the macro you would like to call, identifier for the image you would like the function to be applied, and several strings to identify the image directory, input image, and resulting image (Figure 2). Before we start filling in these inputs, we need to write the macro in which this module calls.
Figure 1: “RunImageJMacro” can be found under the “Advanced” modules within Cell Profiler.
Figure 2: The default parameters for the “RunImageJMacro” module.
First, let’s create the variable in which the macro defines the folder that ImageJ should use. This is done in line 1 of my example (Figure 3), where “#@String” is used to notify ImageJ this variable is incoming. The default for this variable is “Directory” in Cell Profiler, so this is reflected in my macro. Next, we need to replace both “None.tiff” for both the temporary and resulting image file. In line 3 of my code, I point to the Directory, and use “input.tiff”. I do the same in line 7, where the resulting image is named “output.tiff”. Within three lines of code, we now have a macro that can be run within Cell Profiler… but it does do anything yet!
What do I want this macro to do? For my application, I am very interested in using the “Enhance Local Contrast (CLAHE)”, which increases contrast in areas of an image that are dimmer than others (Figure 4).
Figure 3: Example code used to call any ImageJ macro from Cell Profiler.
Figure 4: The Enhance Local Contrast (CLAHE) filter can be found at the bottom of the Process tab.
To access this functionality, I take advantage of the Plugins/Record tool within ImageJ (Figure 5), which records every function completed and spits out the macro language equivalent. To complete our macro, we simply need to paste the string from the Recorder between lines 3 and 8 (Figure 6). In line 7, I added a command that would also close all other image open besides “input.tiff”. After saving the macro, it is now time to update the module within Cell Profiler (Figure 7).
Figure 5: After running CLAHE, the recorder should update with the macro language equivalent.
Figure 6: The completed ImageJ macro that will be called from Cell Profiler.
Figure 7: The updated parameters for the “RunImageJMacro” module in Cell Profiler.
The great thing about this capability is that lines 5 & 7 can be replaced with any functions you want! Through this method, you can combine as many preprocessing steps as needed without expanding your Cell Profiler pipeline! Visikol’s Image Analysis Team routinely use this capability to build complex pipelines for non-routine analysis endpoints. If you have any questions, or are curious about any of these applications, please don’t be afraid to reach out today!