Dialog.create("Image stained nuclei"); Dialog.addMessage(" Open image with DAPI Channel: C2 "); Dialog.show(); open(); // make result directory dir1 = getDirectory("current"); dir2 = dir1+"results"+File.separator; File.makeDirectory(dir2); if (!File.exists(dir2)) exit("Unable to create directory"); filename_Nuc=getTitle(); index_ext=lastIndexOf(filename_Nuc,".tif"); index_basename=(index_ext-9); index_channel=(index_ext-1); filename_sh=substring(filename_Nuc,0,index_basename); Stack.getDimensions(width, height, channels, slices, frames); channels= channels; zslices= slices; timeframes=frames; Zreduction=1; //set z stack reduction factor //--------------------------------automated z-slice reduction\ //new_slnr=floor(zslices/Zreduction); //new_slicenr=new_slnr*Zreduction; //run("Make Substack...", " slices=1-"+(new_slicenr)+"");rename("temp_substack"); //run("Grouped Z Project...", "projection=[Sum Slices] group="+(Zreduction)+""); //run("Subtract...", "value=50 stack"); //selectWindow("temp_substack");close(); //selectWindow(filename_Nuc);close(); //selectWindow("SUM_temp_substack"); //-------------------------------automated z slice reduction\ //pre-process nuclei// DAPI stack================================================= //setMinAndMax(800, 4095); rename("Nuc_orig"); //setBatchMode(true); run("Duplicate...", "title=Nuc_Mask duplicate range=1-zslices"); run("Gaussian Blur...", "sigma=7 stack"); imageCalculator("Subtract create stack", "Nuc_orig","Nuc_Mask"); run("Smooth", "stack"); // -------------------------------------threshold binary mask setThreshold(80, 3500); run("Convert to Mask", "method=IJ_IsoData background=Dark black"); run("Median...", "radius=3 stack"); run("Watershed", "stack"); //================================================== //--------------------------------open and automated z-slice reduction EdU filename_EdU=filename_sh+".lif - C1.tif"; open(filename_EdU); new_slnr=floor(zslices/Zreduction); new_slicenr=new_slnr*Zreduction; run("Make Substack...", " slices=1-"+(new_slicenr)+"");rename("temp_substack"); run("Grouped Z Project...", "projection=[Sum Slices] group="+(Zreduction)+""); //run("Subtract...", "value=50 stack"); selectWindow("temp_substack");close(); selectWindow(filename_EdU);close(); selectWindow("SUM_temp_substack"); //pre-process EdU nuclei// stack================================================= rename("EdU_orig"); //setBatchMode(true); run("Duplicate...", "title=EdU_Mask duplicate range=1-zslices"); run("Gaussian Blur...", "sigma=7 stack"); imageCalculator("Subtract create stack", "EdU_orig","EdU_Mask"); run("Smooth", "stack"); // -------------------------------------threshold binary mask setThreshold(100, 3500); run("Convert to Mask", "method=IJ_IsoData background=Dark black"); run("Median...", "radius=3 stack"); run("Watershed", "stack"); // FOR EdU: clean up roi set for double centroids close to z------------------------------------------ roiManager("Reset"); run("Set Measurements...", " centroid stack"); run("Analyze Particles...", "size=75-1000 pixel circularity=0.30-1.00 show=Nothing clear add stack"); r02=roiManager("count"); k2=0;t=0; n=nResults; for(i=0; i