Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.plot method for RoIs #443

Open
willGraham01 opened this issue Feb 26, 2025 · 2 comments · May be fixed by #447
Open

.plot method for RoIs #443

willGraham01 opened this issue Feb 26, 2025 · 2 comments · May be fixed by #447

Comments

@willGraham01
Copy link
Contributor

willGraham01 commented Feb 26, 2025

It is currently possible to plot RoIs by interating over their coordinates and passing this to a matplotlib function, like in the example in #440. However as highlighted in the PR discussion:

One other food for thought; in this example I plot the region of interest manually, using the coordinates that are stored on the object. But it probably wouldn't be too much effort (and quite nice for users!) to have a .plot method for Regions of Interest. It might also be useful for us given that we'll have to "plot" the regions in napari anyway, eventually!

That's a great idea! Thogh the "plot" method would be a maptlotlib wrapper like the ones we already have right? The method for showing the ROIs in napari has to be different.

Originally posted by @niksirbi in #440 (comment)

Within the BaseRegionOfInterest class, all we'd need is a method like

def plot(self, ax, **matplotlib_kwargs) -> None:
    # self.coordinates iterates over (x,y) pairs of vertices that define the region,
    # so unpacking this into an array of x and array of y positions should be easy.
    # Then pass to the matplotlib method.

There are some differences between considering segments / lines (1D) and polygons (2D). We might want to fill the region occupied by a polygon for example, and these polygons might have holes too. For 1D objects I think the convention is fairly clear-cut - we can even just use matplotlib.pyplot.plot to draw the regions right away.

@niksirbi
Copy link
Member

niksirbi commented Feb 26, 2025

I'd favor "filled" regions for PolygonOfInterest and just "lines" for LineOfInterest (including loops). I thinks that's what you mean as well, right?

@willGraham01
Copy link
Contributor Author

I'd favor "filled" regions for PolygonOfInterest and just "lines" for LineOfInterest (including loops). I thinks that's what you mean as well, right?

Yeah that was my intended meaning.

I just wanted to flag in the issue that it means that we might need subclass-specific implementations of .plot rather than one implementation in the base class. It won't be the same matplotlib method that is used to create both plots; plot for the lines and most likely fill for the polygons, plus some wriggling to deal with holes in the polygons.

@willGraham01 willGraham01 linked a pull request Feb 27, 2025 that will close this issue
7 tasks
@willGraham01 willGraham01 moved this from 🤔 Triage to 🚧 In Progress in movement progress tracker Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚧 In Progress
Development

Successfully merging a pull request may close this issue.

2 participants