-
Notifications
You must be signed in to change notification settings - Fork 86
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
Make ImagePlus subscriptable #194
Comments
See also this Gitter chatlog. |
I think our four choices are:
The advantage of (2) is that those types are already in place. But the disadvantage is that it's inconsistent with how PyImageJ handles So I think (1) is probably the cleanest solution. |
This partially reverts commit 62178c1. As per this discussion: https://gitter.im/imagej/pyimagej?at=6269dc98949ae940067e9830 @gselzer pointed out that slicing an ImagePlus down to a single element should -- in the same way that numpy and ImgLib2 images behave -- return the element as an instance of the same class that dtype reports. For ImageJ, this is not so easy, though, because ImageJ does not have sample value container types like ImgLib2 does. So we would need to: A) Invent some ImageJ-specific ones; or B) Reuse the numpy ones; or C) Use plain Python types but that is ambiguous (GRAY8 vs GRAY16); or D) Break the convention. See also #194.
I'd propose not actually making a decision on this. I'd rather focus on making pixel access (i.e. slicing) work the way we want it. Then I think this question of the |
My current thinking is: let's not ever implement this. What we could do instead is, if someone tries to slice or subscript an ImagePlus, raise an exception explaining that the original ImageJ data structures do not support this, and to recommend using ImgLib2 structures instead. 👍 No need to make it any easier than we already have for people to keep using ImagePlus forever. |
PyImageJ lets you subscript RandomAccessibleInterval objects, but not ImagePlus objects.
For single-element access:
numpy.uint8
.numpy.uint16
.numpy.float32
.numpy.uint8
...Note also that to be consistent with numpy and ImgLib2's behavior, the
dtype
function should also be implemented, and it should return a class object corresponding to the returned type of single elements.For slicing: maybe we can use the Duplicator's crop and/or run to limit dimensional min/maxes. But step values other than 1 require more effort. Better to wrap the ImagePlus into some kind of Python-side view object?
The text was updated successfully, but these errors were encountered: