//Jan Wisniewski Confocal Microscopy Core at Experimental Immunology Branch NCI NIH Bethesda MD //Creates rotating 3D projection of cells selected from a Z-stack //Applies false-color LUT to visualize areas containing different amounts of target // specify folders res=getDirectory("_Choose a Destination for Results"); myDir1 = res+"Selected Cells"+File.separator; File.makeDirectory(myDir1); myDir2 = res+"3D Cells"+File.separator; File.makeDirectory(myDir2); input=getDirectory("Select a Source Directory"); NAMES=getFileList(input); //functions function setChannel() { Dialog.addString("Name This Channel", " "); items = newArray("B&W", "Blue", "Cyan", "Green", "Yellow", "Red", "Magenta"); Dialog.addRadioButtonGroup("In the Final Composite, Display This Channel as:", items, 1, 7, "B&W"); Dialog.show(); } //channel setup open(); getDimensions(width, height, channels, slices, frames); rename("y"); run("Z Project...", "projection=[Max Intensity]"); rename("x"); close("y"); if(channels==1) {run("Enhance Contrast", "saturated=0.10"); Dialog.create("Set Channel"); setChannel(); chnname1=Dialog.getString(); chncolor1=Dialog.getRadioButton(); print(chnname1, " ", chncolor1); close("x"); } if(channels>1) {run("Split Channels"); run("Tile"); selectWindow("C1-x"); run("Enhance Contrast", "saturated=0.10"); selectWindow("C2-x"); run("Enhance Contrast", "saturated=0.10"); if(channels>2) {selectWindow("C3-x"); run("Enhance Contrast", "saturated=0.10"); } //multiple channel selection rows = 1; columns = 4; n = channels; labels = newArray(n); defaults = newArray(n); for (i=0; i2) {cx3=Dialog.getCheckbox(); } selectWindow("C1-x"); if(cx1==0) {close("C1-x"); } else {run("Enhance Contrast", "saturated=0.10"); Dialog.create("Set Channel"); setChannel(); chnname1=Dialog.getString(); chncolor1=Dialog.getRadioButton(); print(chnname1, " ", chncolor1); close("C1-x"); } selectWindow("C2-x"); if(cx2==0) {close("C2-x"); } else {run("Enhance Contrast", "saturated=0.10"); Dialog.create("Set Channel"); setChannel(); chnname2=Dialog.getString(); chncolor2=Dialog.getRadioButton(); print(chnname2, " ", chncolor2); close("C2-x"); } if(channels>2) {selectWindow("C3-x"); if(cx3==0) {close("C3-x"); } else {run("Enhance Contrast", "saturated=0.10"); Dialog.create("Set Channel"); setChannel(); chnname3=Dialog.getString(); chncolor3=Dialog.getRadioButton(); print(chnname3, " ", chncolor3); close("C3-x"); } } } // open files for (q=0; q0) { for (i = 0; i < rois; i++) {j=i+1; run("Duplicate...", "duplicate"); setTool("rectangle"); waitForUser("Select Cell"); run("Crop"); saveAs("Tiff", myDir1+name+"_cell_"+j); close(); } close("z"); } } //fetch selected regions NAMES2=getFileList(myDir1); for (k=0; k2) {selectWindow("C3-x"); if(cx3==0) {close("C3-x"); } else {if(chncolor3=="B&W") {run("Grays"); } else {run(chncolor3);run("Median...", "radius=1 stack"); waitForUser("Adjust B&C - Check across whole stack!"); run("16 colors"); run("Gamma...", "value=0.50 stack"); run("Apply LUT", "stack"); run("3D Project...", "projection=[Brightest Point] axis=Y-Axis slice=1 initial=0 total=360 rotation=3 lower=1 upper=255 opacity=0 surface=100 interior=50 interpolate"); saveAs("Tiff", myDir2+name3+"-"+chncolor3); close(); close(); } } } } }