Created
March 22, 2017 03:27
-
-
Save zktuong/66c507da5f006184cbcad22d21b69231 to your computer and use it in GitHub Desktop.
Basic imageJ macro to separate purple and pink areas from H&E stained IHC images to quantify size of tumor vs necrotic tissues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTool("line"); | |
waitForUser("Image selection", "Please zoom in (+) to where the scale bar is and then draw a line over the scale bar. Click 'OK' when ready.") | |
run("Original Scale"); | |
run("Set Scale..."); | |
run("Select None"); | |
setTool("polygon"); | |
waitForUser("Image selection", "Please draw to select area you want to keep for analysis\nIf you need to adjust, finish drawing first. Click 'OK' when ready.") | |
roiManager("Add"); | |
run("Make Inverse"); | |
setBackgroundColor(255, 255, 255); | |
run("Clear", "slice"); | |
run("Select All"); | |
run("Colour Deconvolution", "vectors=H&E hide"); | |
close(); | |
close(); | |
run("8-bit"); | |
run("Invert"); | |
makeRectangle(528, 581, 50, 50); | |
waitForUser("MOVE THE SQUARE", "Please move the square to where you think is noise/background. Then Click 'OK'.") | |
IJ.deleteRows(0, 9999); | |
run("Set Measurements...", "area mean limit redirect=None decimal=3"); | |
run("Measure"); | |
selectWindow("Results") | |
run("Select All"); | |
waitForUser("REMEMBER MEAN VALUE", "Remember/Copy the 'mean' value. Paste the value for the next pop up. Click 'OK' when ready."); | |
run("Subtract..."); | |
//run("Threshold..."); | |
setThreshold(1, 255); | |
setOption("BlackBackground", false); | |
run("Convert to Mask"); | |
run("Close-"); | |
run("Analyze Particles...", "size=0.1-Infinity show=Masks display clear"); | |
setTool("Paintbrush Tool"); | |
waitForUser("ERASE NOISE", "Bring up the original image to compare where is true signal. Click and hold to erase noise in the black and white image. Then Click 'OK'.") | |
run("Invert"); | |
setThreshold(0, 254); | |
run("Set Measurements...", "area limit redirect=None decimal=3"); | |
IJ.deleteRows(0, 9999); | |
run("Measure"); | |
roiManager("Select", 0); | |
run("Subtract...", "value=255"); | |
run("Measure"); | |
run("Close All"); | |
roiManager("Deselect"); | |
roiManager("Delete"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment