RunImageJ with JACoP

I’m attempting to quantify co-localization in two fluorescent channels. I have used the JACoP plugin for ImageJ, and found it to be exactly what I need, as it performs the Costes Randomization, but I would like to use CellProfiler for batch processing. The issue I’m running into is creating a macro to get the CellProfiler version of ImageJ to run through the images I’ve loaded into the Input modules. I have them as multichannel .tif “stacks” which both CellProfiler and ImageJ have not previously had trouble separating. Here is the preliminary macro I’m working with, which came from the “Record Commands” function within ImageJ, while I ran through analysis of the first of my images:

run(“TIFF Virtual Stack…”, “open=C:\Users\Circulating\Desktop\CFPYPF\cfpnegyfppos00.tif”);
run(“Stack to Images”);
run("JACoP ");
run("JACoP ", “imga=cfpnegyfppos00-0001 imgb=cfpnegyfppos00-0002 thra=46 thrb=165 pearson overlap mm costesthr costesrand=2-1-200-0.001-0-false-false-true”);
selectWindow(“Costes’ threshold cfpnegyfppos00-0001 and cfpnegyfppos00-0002”);
selectWindow(“Costes’ mask”);
selectWindow(“Randomized images of cfpnegyfppos00-0002”);
selectWindow(“Costes’ method (cfpnegyfppos00-0001 & cfpnegyfppos00-0002)”);
selectWindow(“Costes’ threshold cfpnegyfppos00-0001 and cfpnegyfppos00-0002”);
selectWindow(“Costes’ mask”);
selectWindow(“Randomized images of cfpnegyfppos00-0002”);
selectWindow(“Costes’ method (cfpnegyfppos00-0001 & cfpnegyfppos00-0002)”);

I have never used macros before, and was unsure about how to go about debugging, in addition to modifying it for better use with CellProfiler. I am also not sure if I have installed the JACoP plugin to the ImageJ which pops up within CellProfiler in conjunction with the RunImageJ module, but I think I followed the plugin installation instructions included on the example RNA sequencing pipeline. Any tips you might have would be appreciated, as well as any resources which discuss how to use RunImageJ with a plugin. I will also attach a sample of my images, which are at this point just positive and negative controls.
Thank you!

Hi Cayla,

I’ve put together a pipeline to get you started; it’s attached. But before you run it, you’ll need to make sure that JACoP plugin is placed in a folder where CellProfiler can find it (e.g., C:\Program Files\CellProfiler\plugins) and then go to File > Preferences to point the ImageJ plugin folder setting to this location.

Once that’s done, you can see how the pipeline works. In a nutshell, here’s what’s doing:

  • Loads each stack and splitting out the channels.
  • The 1st RunImageJ module loads one channel into ImageJ
  • The 2nd RunImageJ module loads the other channel, and then runs the plugin calling both channels.
  • Selects the proper ImageJ window and retrieves the image therein.
  • Closes all windows, and the pipeline continues from there.

pipeline.cppipe (7.27 KB)

Wonderful! This solves my issues with loading the two channels. I am still unable to save the output from ImageJ for each set of images. It comes up in ImageJ as the Log window, using the macro saveAs(“Text”) with the folder I want it to save to prompts an error message from ImageJ that says “This command requires a TextWindow, such as the “Log” window, or an Editor window. Use File>Save>Text Image to save an image as text.”

I need to save the log window that pops up, preferably as a different file for each multichannel image analyzed. Is there a way to do this with a macro in CellProfiler?
Attached is the pipeline I’m now working with, modified for a 4 channel image and two separate runs of JACoP, along with one sample image. It seems like the log file holds both runs, which is exactly what I would like to have saved.

Thanks again,
Cayla (7.47 MB) (12.5 KB)

You can save the log file text with a RunImageJ module using a macro:

path = 'C:\\\\Users\\\\cayla\\\\Desktop\\\\log.txt' string = getInfo("log") File.append(string, path) (I really did need all those slashes to get it to work)

However, this places everything into one file. I’m not sure if it’s possible to split the results up.

Ok, so I have been working on this for a bit, and I while I had success saving the log files with a new RunImageJ module that ran the macro “saveAs (“Text”)” which opens a dialog box and asks me to save the .txt file each time a new image went through the pipeline. When I ran the pipeline, it saved the same number of .txt files as I had images, but the data in these logs did not make sense at all. It calculated 30 coefficients when I was only meaning for 18 to come out, each log file was a different size, and there were only 8 unique coefficients, that were repeated in patterns that were not reproducible. This makes me think there might be some issue with the sequence in which CellProfiler is feeding things to ImageJ.

I ran all my pictures through ImageJ manually, and got totally different results. Also when I use CellProfiler, it takes ~8min to (supposedly) do the entire set of 9 images, comparing two pairs of channels for one image. But in ImageJ alone, it takes around 15 minutes to do a single comparison between only one pair of images. This fact also leads me to believe there is something being skipped in CellProfiler, or iterated more than once instead of moving to the next thing when it should.

I don’t quite know how the RunImageJ module is meant to work in other contexts, or how it was designed, but it doesn’t seem to be working very well in this situation, where I both want to use a plugin, and access the Log window. Any ideas about where I should look further into this issue, should I report this as a bug on a different forum?

  • Cayla

Could you post your most recent version of your pipeline?

Here is the pipeline, and two more of the images I’m working with. In my set I have 8 but since the files are so big I figured three, including the one from earlier, would be sufficient. (8.05 MB) (7.47 MB) (12.7 KB)

Another question: What are the settings that the JACop plugin needs to have in order to get the values that you are expecting? To narrow things down, what’s appropriate for the cotransfect000 image stack?

Analysis to perform:
Pearson’s coefficient
M1 & M2 coefficients
Overlap coeff., k1 & k2
Costes’ automatic threshold
Costes’ randomization

The threshold should be around 1000 for the DAPI stain (channel 2), around 200 for the DsRed stain (channel 3) and around 50 for the YFP stain (channel 4). These thresholding settings shouldn’t have an effect on Pearson’s Coefficient though, which is what I’ve been using to evaluate the success of the pipeline.

Under the Costes’ Rand tab, the number of random rounds should be 200. and un-check the first two check boxes:“Slices to be considered independent” and “z randomization as well.”

All other settings can remain as defaults.

I hope this helps! And I have no strong attachment to these settings, I haven’t really evaluated them yet. There could be some issue here, or with my pictures that is giving bad results, but I figured since there was such weird saved outputs from RunImageJ, it was probably something with CellProfiler