// APL phagosomal neutrophil image analysis Macro // March 2013 var pmCmds = newMenu("Popup Menu", newArray("Measure pH", "Measure area", "-", "Repeat last identifier", "Advance forward", "-", "Counter", "Clear all", "Suffix", "Save to file", "Open folder")); macro "Popup Menu" { cmd = getArgument(); run(cmd); } var cell = 0 var dir = "" var suffix = "" macro "Measure pH" { Stack.getPosition(channel, slice, frame); Stack.setChannel(1); channel_1_profile = getProfile(); Array.getStatistics(channel_1_profile, min, max, mean, stdDev); channel_1_mean = mean; Stack.setChannel(2); channel_2_profile = getProfile(); Array.getStatistics(channel_2_profile, min, max, mean, stdDev); channel_2_mean = mean; ratio = channel_2_mean/channel_1_mean; Stack.setChannel(1); position = nResults setResult("Identifier", position, cell); setResult("Ratio", position, ratio); setResult("C1",position,channel_1_mean); setResult("C2",position,channel_2_mean); updateResults; roiManager("Add"); roiManager("select",roiManager("count")-1); roiManager("Rename",cell+"_pH"); cell= cell + 1; print(cell); } macro "Suffix" { Dialog.create("User input"); Dialog.addString("Suffix", suffix); Dialog.show(); suffix=Dialog.getString(); print("Suffix: " + suffix); } macro "Measure area" { getStatistics(area); position = nResults setResult("Identifier", position, cell); setResult("Area", position, area); updateResults; roiManager("Add"); roiManager("select",roiManager("count")-1); roiManager("Rename",cell+"_area"+"_"+suffix); cell= cell + 1; print(cell); } macro "Counter" { Dialog.create("User input"); Dialog.addNumber("Identifier", cell); Dialog.show(); cell=Dialog.getNumber(); print("Identifier: " + cell); } macro "Repeat last identifier" { cell= cell + -1 print(cell); } macro "Advance forward" { cell= cell + 1 print(cell); } macro "Clear all"{ print("\\Clear"); run("Clear Results"); roiManager("deselect"); roiManager("delete"); cell=0; } macro "Save to file" { this = getTitle; print(this); roiManager("deselect"); roiManager("save", dir+this+"_roi.zip"); roiManager("delete"); selectWindow("Log"); saveAs("text", dir+this+"_log.txt"); selectWindow("Results") saveAs("Measurements",dir+this+"_results.txt"); print("Results saved"); } macro "Open folder" { dir = getDirectory("Choose a Directory"); print(dir); } macro "Delete last entry"{ selectWindow("Results"); IJ.deleteRows(nResults-1, nResults-1); roiManager("deselect"); roiManager("select", roiManager("count")-1); roiManager("delete"); }