Napari fails to create ellipse when specifying center and radius in 3 dimensions
See original GitHub issue🐛 Bug
The documentation for creating ellipses states that either the 4 corner vertices must be specified, or a center position and radius must be specified. I find that when attempting to create ellipses the second way, napari throws an error because it expects that the 4 corner method will be used instead. I suspect the issue originates in napari/layers/shapes/_shapes_models/ellipse.py on line 71 where it uses an if statement instead of else if.
To Reproduce
Steps to reproduce the behavior:
- Attempt to add an ellipse to a layer in 3 dimensions by specifying a center and radius
Error message:
~/anaconda3/lib/python3.7/site-packages/napari/layers/shapes/_shapes_models/ellipse.py in data(self, data)
74 "Data shape does not match a ellipse. Ellipse expects four corner vertices, {number} provided.",
75 deferred=True,
---> 76 number=len(data),
77 )
78 )
ValueError: Data shape does not match a ellipse. Ellipse expects four corner vertices, 2 provided.
Offending code in ellipse.py
@data.setter
def data(self, data):
data = np.array(data).astype(float)
if len(self.dims_order) != data.shape[1]:
self._dims_order = list(range(data.shape[1]))
if len(data) == 2 and data.shape[1] == 2:
data = center_radii_to_corners(data[0], data[1])
if len(data) != 4:
raise ValueError(
trans._(
"Data shape does not match a ellipse. Ellipse expects four corner vertices, {number} provided.",
deferred=True,
number=len(data),
)
)
self._data = data
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Using the shapes layer — napari
Ellipses can be added using either two vectors, one representing the center position of the ellipse and the other representing the radii of...
Read more >Display text for shapes in 3D - Usage & Issues - Image.sc Forum
I'm trying to follow Annotating segmentation with text and bounding boxes — napari, but it does not do what I expect in my...
Read more >Python add ellipse - ProgramCreek.com
This page shows Python code examples for add ellipse. ... anticlockwise, in radians asymmetry: float 3rd-order moment for directionality if known kwargs: ...
Read more >Proceedings of the 21st Python in Science Conference
3. Changes to Python ASDF package. Easier and more flexible mechanism to create new extensions. (2.8.0). The previous system for defining ...
Read more >3DeeCellTracker, a deep learning-based pipeline for ... - eLife
Despite recent improvements in microscope technologies, segmenting and tracking cells in three-dimensional time-lapse images (3D + T images) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can give it a shot.
On Fri, Mar 25, 2022 at 4:12 PM Nicholas Sofroniew @.***> wrote:
For info, most of the 3D rendering of ellipses is completely borked, and render non planar aligned ellipses in wrong orientation and stretching. #4330 should start fixing the rendering.
So I’ve been banging my head as why other representation don’t visually work.
That should still be (4,D) for ellipses, (2**D, D) would be for D-ellipsoids but I don’t think that should be in the shape layer, should it ? Do we want D-ellipsoids ? or D-shapes in General ?
https://miegakure.com/ and in particular https://www.youtube.com/watch?v=vZp0ETdD37E show some complexities with ND-shapes, and I’m unsure we want to tackle it in napari.
On top of that it would also be unclear to me how to manipulate a 2**D ellipsoid, in particular if the multiple axes are not axis aligned.