Next we will segment out the blue channel via Image->Adjust->Threshold…

In this dialog box, we choose the Default method for choosing a threshold, which has calulated to segment all pixel values between 92 and 255. (Try other algorithms using the menu dropdown.) And the Dark Background means we are choosing light objects on a dark background (rather than dark objects on a light background). Now one feature with ImageJ (that I don’t particularly like) is that once we choose Apply, our image will be transformed into a mask or binary image. Though the image type will still be 8-bit, there will be only two pixel values in the image: 0 and 255. Once we have this binary image, we can use binary operators. For example the watershed operator can separate many aggregated nuclei via Process->Binary->Watershed.
selectImage(bID);
setAutoThreshold("Default dark");
run("Convert to Mask");
run("Watershed");
Ultimately you may need to go to a more complicated algorithm to better pick out nuclei such as: https://imagej.net/Interactive_Watershed, but this at least gives you the idea. We are now ready to select and analyze objects using Analyze->Analyze Particles…. We still have objects that are composed of multiple nucleim so we will futher filter objects of interest to those that are below a certain size (<150 squared microns) and not too elliptical (circularity>0.8).

Now look at all the ROI’s you have! You can uncheck the labels to see them better. Let’s get rid of the blue channel because we no longer need it.
selectImage(bID);
close();
Your ROI’s are still in the ROI manager. Find the ROI manager window and toggle the show all check box while viewing the remaining green channel. Clearly some of the nuclei are positive and some are not. In the real scientific world, we would run controls to determine what is positive (such as unlabeled cells). Here we will arbitrarily choose a value given by the statistics of the image. The median (m) value is usually the background, so let’s choose the “positive” threshold value to be PV=m+sd where sd=the standard deviation of the pixel intensities.
selectImage(gID);
//see macro functions site
m=getValue("Median");
sd=getValue("StdDev");
pV=m+sd;
print(pV);
We will be checking whether the mean green value within each ROI is greater than this value. If it is, we will count it as positive. Make sure your measurements are set to mean gray value (Analyze->Set Measurements…).
run("Set Measurements...", "mean redirect=None decimal=0");
Now we will run through each of the ROI’s and determine whether it is positive or not, using what we have already learned from the previous modules. Try doing this with a single ROI by unselecting show all, selecting a single ROI and Analyze->Measure.
nROI=roiManager("count"); //total number of cells
npos=0; //number of positive cells
for (i = 0; i < nROI; i++) {
roiManager("Select", i);
run("Measure");
meanROI=getResult("Mean");
if (meanROI > pV) {npos=npos+1;}
}
//print fraction of positive cells
print(npos/nROI);
Try running all your code at once. You should come up with a fractional volume that is somewhere around 10%.