// This Tool is useful for labeling somas (cell bodies or // other elliptical structures in images.Ê It behaves // similarly to the stock Elliptical Selection Tool, except // that the user can specify the default ROI diameter. A left // mouse click creates a circle of the specified diameter, // and then a mouse drag can be used to resize the ellipse. macro 'Soma ROI Tool-C00cO11cc' { diameter = parseInt(call("ij.Prefs.get", "SomaRoiTool.diameter", 16)); r = diameter / 2; left = 16; //left-click flag right = 4; //right-click flag getCursorLoc(x0, y0, z, flags); makeOval(x0-r, y0-r, 2*r, 2*r); prevX = -1; prevY = -1; setOption("Show All", true); setOption("DisablePopupMenu", true); showStatus("Right-click to cancel current ROI."); do { getCursorLoc(x, y, z, flags); if ((flags&right)>0) { run("Select None"); setOption("DisablePopupMenu", false); return; } moved = (x!=x0 || y!=y0); if (moved && (prevX != x || prevY != y)) { prevX = x; prevY = y; getCursorLoc(x, y, z, flags); makeOval(x0-r, y0-r, 2*(r-(x0-x)), 2*(r-(y0-y))); } } while ((flags&left)>0) //roiManager("Add"); //roiManager("select", roiManager("count")-1); setOption("DisablePopupMenu", false); } macro "Soma ROI Tool Selected" { diameter = parseInt(call("ij.Prefs.get", "SomaRoiTool.diameter", 16)); diameter = getNumber("Region Diameter (pixels):", diameter); call("ij.Prefs.set", "SomaRoiTool.diameter", diameter); }