macro "Save First Line [1]" { if (!isLine()) exit("No line selection"); Overlay.remove; Overlay.addSelection; } macro "Create ROI [2]" { if (!(isLine() && Overlay.size==1)) exit("No line selection and no line overlay"); getSelectionCoordinates(x1, y1); Array.reverse(x1); Array.reverse(y1); Overlay.activateSelection(0); getSelectionCoordinates(x2, y2); x = Array.concat(x1,x2); y = Array.concat(y1,y2); makeSelection("freehand", x, y); Overlay.remove; } function isLine() { return (selectionType>=5 && selectionType<=7); }