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

Circle draw tool must produce circle #370

Closed
wants to merge 2 commits into from

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Jul 5, 2023

User was confused on why they get back elliptical region when they used the circular draw tool on their image. You can basically reproduce this behavior using spacetelescope/jdaviz#697 even though I think @camipacifici reported a different workflow.

With this patch, even though the circle tool obviously produced something that does not look circular in Lab, it still gives a circle.

Screenshot 2023-07-05 173720

I don't see the affected code tested anywhere in this repo, so I am unable to add new tests.

🐱

@pllim
Copy link
Contributor Author

pllim commented Jul 5, 2023

I don't think the pydantic.errors.PydanticImportError: BaseSettings has been moved to the pydantic-settings package. error in CircleCI is related.

@pllim pllim marked this pull request as ready for review July 5, 2023 22:05
@pllim
Copy link
Contributor Author

pllim commented Jul 5, 2023

p.s. I tried having both tools subclass from a common base class but that broke the click-and-drag feature for some reason.

@astrofrog
Copy link
Member

astrofrog commented Jul 10, 2023

Thanks! This approach doesn't quite work because if I make a simple scatter plot in glue-jupyter where the two axes might be quantities with different scales (e.g. x is velocity between -1 and 1 and y is position between -100 and 100) the current 'circle' tool will produce weird results - e.g.

Screenshot 2023-07-10 at 13 45 48

In this scenario users would expect the circular tool to draw a circle.

I think a cleaner solution would be to keep the current circular tool as is but add a class attribute e.g. _strict_circle that defaults to False and check that attribute where we currently construct a CircularROI. You can then make a 'strict circle' subclass that simply sets _strict_circle = True, and use bqplot:strictcircle in Imviz.

roi = CircularROI(xc=xc, yc=yc, radius=rx)
else:
roi = EllipticalROI(xc=xc, yc=yc, radius_x=rx, radius_y=ry)
r = (rx + ry) * 0.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r = (rx + ry) * 0.5
r = np.sqrt((rx**2 + ry**2) * 0.5)

adds a little computational overhead, but I think using arithmetic mean here could create a circle passing somewhat besides the actual pointer position

@pllim
Copy link
Contributor Author

pllim commented Jul 10, 2023

@camipacific's workflow on standalone Jdaviz (read: she ran this stuff on voila)

  • create circular subset on object of interest
  • create annulus subset around that circular subset for background
  • go in the subset tool plugin to properly center the circular subset on the object of interest after recentering, notice that the circular subset is actually an ellipse (i could see it in the image when compared to the annulus subset and i noticed that the subset had two radii)

at this point i was confused and thought i did something wrong so I deleted the subsets and started again. by redoing it, i noticed that the circular subset turned automatically in an ellipse, while the annulus stayed a circular annulus. this can be confusing for a user.

@pllim
Copy link
Contributor Author

pllim commented Jul 10, 2023

As per offline discussions, I will wait for the alternative solution that @astrofrog is going to propose.

@pllim
Copy link
Contributor Author

pllim commented Aug 1, 2023

This has been superseded by #376

@pllim pllim closed this Aug 1, 2023
@pllim pllim deleted the its-the-circle-of-life branch August 1, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants