// Jan Wisniewski, EIB/NCI/NIH, Bethesda, MD //segments nuclei and measures intensity of the target, corrected for the cytoplasm //data for individual nuclei are stored in a custom table //segmentation map, combined into motage with color channels and composite allows confirmation of segmentation process print("Cell Segmentation Macro\nJan Wisniewski, Experimental Immunology Branch\nNational Cancer Institute, NIH, Bethesda, Maryland"); getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec); print(""); print("run: ", month, "/", dayOfMonth, "/", year, " at ", hour, ":", minute); print(""); // specify folders res=getDirectory("Choose a Results Directory") myDir1 = res+"temp1"+File.separator; File.makeDirectory(myDir1); myDir2 = res+"temp2"+File.separator; File.makeDirectory(myDir2); myDir3 = res+"temp3"+File.separator; File.makeDirectory(myDir3); myDir4 = res+"temp4"+File.separator; File.makeDirectory(myDir4); myDir5 = res+"temp5"+File.separator; File.makeDirectory(myDir5); input=getDirectory("Select a Source Directory"); NAMES=getFileList(input); run("Brightness/Contrast..."); //set measured parameters run("Set Measurements...", "area mean min bounding integrated median display redirect=None decimal=2"); //create custom table title1 = "Analysis Table"; title2 = "["+title1+"]"; f=title2; run("New... ", "name="+title2+" type=Table"); print(f,"\\Headings:Image\tTarget\tID\tBackground(ADUs)\tArea(pixels)\tArea(um2)\tIntensity(ADUs)\tADUs/um2)"); //channel setup open(); ttl=File.nameWithoutExtension; getDimensions(width, height, channels, slices, frames); rename("x"); run("Split Channels"); run("Tile"); selectWindow("C1-x"); run("Enhance Contrast", "saturated=0.35"); selectWindow("C2-x"); run("Enhance Contrast", "saturated=0.35"); Dialog.create("Channel selection"); items=newArray("C1-x", "C2-x"); itemz=newArray("Grays", "Blue", "Cyan", "Green", "Yellow" ,"Red", "Magenta"); Dialog.addRadioButtonGroup("Select channel to create mask:", items, 1, 2, "C1-x"); Dialog.addString("Name the mask:", " "); Dialog.addChoice("Display it in:", itemz, "Red"); Dialog.addMessage(" * * * * * * * * * *"); Dialog.addRadioButtonGroup("Select channel to measure:", items, 1, 2, "C2-x"); Dialog.addString("Name the measured structure:", " "); Dialog.addChoice("Display it in:", itemz, "Green"); Dialog.show(); MCh=Dialog.getRadioButton(); MNm=Dialog.getString(); MCo=Dialog.getChoice(); OCh=Dialog.getRadioButton(); ONm=Dialog.getString(); OCo=Dialog.getChoice(); print("setup image:", ttl); print(MNm, MCh, MCo); print(ONm, OCh, OCo); close("C1-x"); close("C2-x"); //proces images for (i=0; i