//Macro code I am trying to execute on many many files within a folder
//Gets the file name
fileName = getTitle();
originalName = replace( fileName, "_probs.tif", "");
//Separates the stack
run("Stack to Images");
close();
close();
//Select Yeast
selectWindow("Yeast");
//Threshold
setAutoThreshold("Default dark");
//run("Threshold...");
run("NaN Background");
setOption("BlackBackground", false);
//Convert to mask
run("Convert to Mask");
//Count
run("Analyze Particles...", "size=40-1000 pixels circularity=0.30-1.00 show=[Overlay Masks] display exclude summarize in_situ");
//Save counts
run("Read and Write Excel","file=[PATH/Counts.xlsx]","stack_results");
//Save masks
saveAs("Tiff",originalName + "_countmask.tif");
close();
Link to an example of an image stack I am trying to process: https://umich.box.com/s/moqt367pmclvpvufmqyh1fgq74u3hrpc
Hello! I am new to this kind of image analysis and would be grateful for your help in identifying what has gone wrong. I’ve included my code and a link to the image for reproducibility. Hoping that any also insight will benefit other newbies trying to execute similar pipelines.
The immediate challenge is that I’m trying to use a batch process macro in Fiji to replicate the results I get manually using Analyze Particles to count objects in an image. This seems like a trivial thing, but I cannot get a valid Analyze Particles count inside the macro even though i. the protocol works when I manually execute it, and ii. recording a macro from my manual actions produces code that is identical to what I’m trying to execute.
The larger image analysis goal is to segment and count cells in images of stained yeast cells that that may be touching, overlapping, or partially engulfed by a macrophage and therefore only partially stained. My current approach to this task uses Weka classification to export probability maps for what is a yeast cell vs macrophage vs background. Here I am trying to take those probability maps, split stacks to images, select the yeast image, threshold it appropriately setting the background to NaN with no black background, convert the image to a binary mask, and then count the resulting objects.
Again, running this process manually gives me useful counts of yeast cells. Inside a batch process macro, I get NaN for the counts. I thought that something about my file processing inside the macro might be off so I’ve tried executing the macro and saving a tif of the binary mask just before the Analyze Particles step. Manually running Analyze Particles on this binary mask file works just fine, but the batch process macro still produces NaN counts. Can you help? What am I missing?
I have searched this forum and others for relevant issues with batch process macros and analyze particles (for example: ImageJ Batch Processing for Analyze Particles Function or Make Binary Foreground/Background Issues or Inverted image, problems with Batch Processing / Macro), but I seem to be having a slightly different set of issues than what I can find. Links to more appropriate resources or even better search terms would be very welcome. If relevant, I am working with the 1.53c installation.
After solving this issue, I suspect I will have more troubleshooting to get the counts exported appropriately as a xls or csv file. I’m currently working with this package: Read and Write Excel - ImageJ, but other recommendations also welcome.
Thanks in advance!!
Andrea