Dear All,
Can anyone please help me to improve the code? My goal is to segment first mcheery cell and then gfp cell. Then and operation to select the cells which have both gfp and mcherry. Then select the cells one by one for detecting droplets or SGs. My problem is that I could not optimize any proper threshold which will work for all. I shared some cells and my code. I will be highly obliged if someone can help. Thank you very much.daa_test.zip (2.4 MB)
following is my code (I would like to acknowledge Dr. Robert Haase for helping to improve the code few months ago and also his Bio-Image Analysis course in youtube helps a lot to learn):
@String(value=“calibrate image”,visibility=“MESSAGE”) hint
@double(label=“distance in pixel”) pixel
@double(label=“known distance(micron)”) micron
@String(choices={“Gaussian Blur…”,“Meadian…”},style=“list”) filter
@double(value=10,min=2,max=100,style=“slider”) sigmamCh
@double(value=10,min=2,max=100,style=“slider”) sigmaGFP
@double(value=400,min=200,max=500,style=“slider”) cellminsize
@double(value=0.5,min=0,max=5,stepSize=0.1,style=“slider”) SGminsize
@double(value=1,min=2,max=40,style=“slider”) SGmaxsize
//Count cells which are common in both GFP and mCherry Ch and analysis the droplet/SGs in mCherry Ch. @ Dr. Nirnay Samanta
// close all images
run(“Close All”);
//clearing ROI manager before run
if (roiManager(“count”)>0) {
roiManager(“deselect”);
roiManager(“Delete”);
}
//------------------------------------------------------------------------------------------------------------INPUT1
//give the path and file name for Ch:gfp
open(“C:/Users/mail2/Desktop/daa_test/gfp0001.tif”);
//give proper value distance=?(in pixel) known=?(in micron)
run(“Set Scale…”, “distance=”+pixel+" known="+micron+" pixel=1 unit=micron");
run(“Rename…”, “title=CH_GFP.tif”);
//give the path and file name for Ch:mch-----------------------------------------------------------------------INPUT2
open(“C:/Users/mail2/Desktop/daa_test/mch0001.tif”);
//give proper value distance=?(in pixel) known=?(in micron)
run(“Set Scale…”, “distance=”+pixel+" known="+micron+" pixel=1 unit=micron");
run(“Rename…”, “title=CH_mCherry.tif”);
// duplicate mCherry image and segment it**************************************************************************
run(“Duplicate…”, " ");
//run(“Subtract Background…”, “rolling=2”);
if(filter==“Gaussian Blur…”){
run(“Gaussian Blur…”, “sigma=sigmamCh”);
} else {
run(“Median…”, “radius=sigmavalue”);
}
setAutoThreshold(“Huang dark”);
//run(“Threshold…”);
waitForUser(“is it okay?”);
setOption(“BlackBackground”, true);
run(“Convert to Mask”);
run(“Watershed”);
//waitForUser(“is it okay?”);
// select GFP and segment it*************************************************************************************
selectWindow(“CH_GFP.tif”);
run(“Subtract Background…”, “rolling=2”);
run(“Gaussian Blur…”, “sigma=sigmaGFP”);
setAutoThreshold(“Default dark”);
waitForUser(“choose threshold”);
setOption(“BlackBackground”, true);
run(“Convert to Mask”);
run(“Watershed”);
waitForUser(“is it okay?”);
// select all pixels which are positive in GFP AND mCherry
imageCalculator(“AND create”, “CH_GFP.tif”,“CH_mCherry-1.tif”);
selectWindow(“Result of CH_GFP.tif”);
// make Regions of interest, Input cell size-----------------------------------------------------------
run(“Analyze Particles…”, “size=”+cellminsize+"-Infinity circularity=0.0-1.00 exclude add");
// show result and close intermediate results
selectWindow(“CH_mCherry.tif”);
close("\Others");
// go through all ROIs and search for objects inside
number_of_rois = roiManager(“count”);
for (r = 0; r < number_of_rois; r++) {
// dupllicate the image to not screw up the original
run(“Duplicate…”, “title=duplicate1.TIF”);
// remove noise
run("Smooth");
// remove background
run("Subtract Background...", "rolling=20");
// remove pixels outside ROIs
roiManager("select", r);
run("Make Inverse");
run("Multiply...", "value=0");
run("Make Inverse");
// automatic threshold*************************************************************************************
setAutoThreshold("MaxEntropy dark");
setOption("BlackBackground", true);
run("Convert to Mask");
// find objects for SGs*************************************************************************************
run("Analyze Particles...", "size="+SGminsize+"-"+SGmaxsize+" circularity=0.25-1.00 summarize record add");
// close duplicate image
close();
}
// show all ROIs
roiManager(“Show None”);
roiManager(“Show All”);
roiManager(“Show None”);
//measure each cell and droplet intensity
//number_of_rois = roiManager(“count”);
//for (i = 0; i < number_of_rois; i++) {
//roiManager(“select”, i);
//roiManager(“Measure”);
//}