3D Objects Counter giving different results depending on image that's in view

I have an image stack of fluorescent neurons in a mouse brain slice that I want to analyze with 3D Objects Counter. The stack contains images with no fluorescence on either end (corresponding to optical sections above and below the tissue). However, the results vary depending on the exact image that I am currently viewing when I run 3D Objects Counter. If I begin the object counter on a nearly blank image, the thresholding is completely off. I get the best results (closest to manual counting) if I am set to viewing an image that has strong signal and low background. Why is it that the results differ by the current slice in view? Can someone please help me with this? Thank you!

To be more precise, we have made a macro to run 3D Objects Counter on our images. This macro gives us the best results we’ve found, but as I mentioned above, its performance hinges on having the image stack set to view an image that has strong signal and low background:

run(“Subtract Background…”, “rolling=4 stack”);
midstack = nSlices/2;
waitForUser // check if middle slice of z-stack is a good one
currentSlice = getSliceNumber();
print("current slice: " + currentSlice);
run(“Gaussian Blur 3D…”, “x=0.5 y=0.5 z=0.5”);
setAutoThreshold(“RenyiEntropy dark no-reset”);
setOption(“BlackBackground”, true);
run(“Convert to Mask”, “method=RenyiEntropy background=Dark black”);
run(“Watershed”, “stack”);
run(“3D Objects Counter”, “threshold=128 slice=currentSlice min.=30 max.=880000 exclude_objects_on_edges objects statistics summary”);

I have never use RenyEntropy for thresholding before. However, I assume the basic argument set is the same as other thresholding methods. Right now, your macro is determining the threshold based on whichever slice is active at the time you click “OK” in the dialog box that pops-up. That is why you are supposed to make sure it is a “good” slice before proceeding. The macro auto-selects the middle slice but it changes to which ever slice you scroll to. Therefore, if you scroll to an end slice, it will try to determine the threshold based on the color distribution of the end slice rather than the “good” slice in the middle.