PK d.Nl6 6 pH3CountsFromUserROI.ijm// Macro written for Kevin Lee to count total cells and pHistone cells in a defined ROI. //Dale Moulding, ICH Imaging facility, September 2017. //Please acknolwedge its use in any presentation or publication. // requires IJPB plugins. // Update Fiji (Press help, Update...), choose "manage update site"s, tick IJPB-plugins. macro "pHistone counts"{ // set colours, draw an ROI and save to ROI manager run("Colors...", "foreground=white background=black selection=yellow"); name=File.nameWithoutExtension; run("Make Composite", "display=Composite"); waitForUser("Draw ROI then add to ROI manager by pressing T\nOR open a previously saved ROI\nThen press OK"); number=roiManager("count"); roiManager("select", number-1); roiManager("Rename", name+"-ROI"); run("Select None"); //Copy the input image to a single greyscale image, do difference of gaussians to identify cells. run("Duplicate...", "title=OrigImage duplicate"); run("Duplicate...", "title=Dapi duplicate channels=3"); roiManager("select", number-1); run("Clear Outside"); run("Select None"); run("Morphological Filters", "operation=Opening element=Disk radius=3"); run("Duplicate...", "title=DapiG3"); run("Duplicate...", "title=DapiG6"); selectWindow("DapiG3"); run("Gaussian Blur...", "sigma=3"); selectWindow("DapiG6"); run("Gaussian Blur...", "sigma=6"); imageCalculator("Subtract create", "DapiG3","DapiG6"); selectWindow("Result of DapiG3"); //run("Enhance Contrast...", "saturated=0.3"); run("Find Maxima...", "noise=5 output=[Single Points]"); rename("Nuclei"); selectWindow("OrigImage"); run("Duplicate...", "title=pHistone duplicate channels=1"); run("Median...", "radius=10"); setAutoThreshold("Yen dark"); //adjust threshold strategy if needed run("Convert to Mask"); rename("pHistone"); imageCalculator("AND create", "Nuclei","pHistone"); run("Dilate"); rename("pHistone Counts"); selectWindow("Nuclei"); run("Dilate"); run("Set Measurements...", " redirect=None decimal=3"); run("Find Maxima...", "noise=1 output=Count light"); run("Analyze Particles...", "clear summarize"); selectWindow("pHistone Counts"); run("Analyze Particles...", "clear summarize"); selectWindow("OrigImage"); run("8-bit"); run("Split Channels"); run("Merge Channels...", "c1=C1-OrigImage c2=C2-OrigImage c3=C3-OrigImage c4=Nuclei c5=[pHistone Counts] create"); selectWindow("OrigImage"); Stack.setChannel(4); run("Invert LUT"); Stack.setChannel(5); run("Invert LUT"); run("Red"); rename(name+"-analysed"); run("Channels Tool..."); print("Save the ROI manager ROI.\nSave the resulting image stack.\nCopy the results (summary) window to excel.\nPress CTRL & SHIFT and W to close all windows."); print("\nClose the Summary window and ROI manager"); print("\nYou can check the counts by unticking channels.\nChannel 4 = all cells\nChannel 5 = pHistone"); selectWindow("Summary"); selectWindow("Log"); }PK? d.Nl6 6 $ pH3CountsFromUserROI.ijm 5:5:~CT'PKjl