Export polygonal ROI vertices (XY)

Hi there, I would like to export not all selection (xy-)coordinates of multiple polygonal ROI, but merely the vertices. Is there another (Macro-based) way besides multi-point selection? I have hundreds of ROI and this would take a while manually, unfortunately. Many thanks in advance!

Here is a small snippet which iterates over the ROI Manager and prints the coordinates of the selected ROI.
You have to add your ROI’s to the ROI Manager before:

n = roiManager("count");
for (index = 0; index < n; index++) {
    print("ROI Nr.:" + index + 1);
    roiManager("select", index);
    getSelectionCoordinates(x, y);
    for (i = 0; i < x.length; i++) {
        print("vertice_" + i + 1 + ": " + x[i] + " " + y[i]);
    }
}
1 Like

Updated the script so it is more readable (see previous post).

Thank you, but this prints all coordinates. I mentioned in my question that I would like to only print the vertices of the polygons, e.g. 6 coordinate pairs for a hexagon. But I guess that’s not feasible here. How would I include the ROI identifier in that loop, such that I know, which coordinate pairs belong to which ROI? Guess I could work with that. Thanks!

Got it. :slight_smile:

n = roiManager("count");
for (index = 0; index < n; index++) {
    roiManager("select", index);
    getSelectionCoordinates(x, y);
    for (i = 0; i < x.length; i++) {
        print(index + 1 + " " + x[i] + " " + y[i]);
    }
}