-
Notifications
You must be signed in to change notification settings - Fork 82
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
Simplify linear axis assignment logic #265
Conversation
This commit changes how the linear and enumerated axes are assigned. We now look for the "imagej" key in the xarray's global attributes. If the key is present we look for dim + "_axis_scale" to assign linear or enumerated axes.
Although the only calibrated axes used by nearly everyone are DefaultLinearAxis and EnumeratedAxis, I added metadata support for all CalibratedAxis types (e.g. PolynomialAxis etc...) just to be thorough. This metadata will be used for matching the Calibrated Axis type when going back to ImageJ/Java land.
145aa16
to
dd66fe0
Compare
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
==========================================
+ Coverage 76.93% 77.36% +0.42%
==========================================
Files 16 16
Lines 1869 1869
==========================================
+ Hits 1438 1446 +8
+ Misses 431 423 -8
☔ View full report in Codecov by Sentry. |
@elevans and I talked about this in person. I don't see much reason to remove EnumeratedAxis support, since it isn't hurting anything. Maybe we can just exert more pressure towards using DefaultLinearAxis, and we can use NumPy to check dimension linearity!
dd66fe0
to
717229d
Compare
Mwahahahahahaha
bd07bd4
to
8b281f9
Compare
The Finally block was always triggering, overwriting the EnumeratedAxis with DefaultLinearAxis.
Non-numeric scales were never handled correctly. If the coords are non-numeric, then trying to convert them to a numpy array without checking if they're numbers will fail. We now check if the coords are numeric or not and then replace them with a linear scale if they are.
I split this PR from my metadata PR (#247). This PR aims to simply how we assign calibrated linear axes to datasets. Currently we check if
net.imagej.axis.EnumeratedAxis
is available and use that as our first choice. Ifnet.imagej.axis.EnumeratedAxis
is not available, then we fall back tonet.imagej.axis.DefaultLinearAxis
. This is fine for most things, but unfortunately this logic has some unintended consequences. @gselzer informed me that the BoneJ plugin actually checks fornet.imagej.axis.DefaultLinearAxis
and is unable to use thenet.imagej.axis.EnumeratedAxis
. The changes this PR brings are the following:net.imagej.axis.EnumeratedAxis
from the axes assignment logic. While I would like to keep the option to use both, I don't realistically see how a user would indicate they wantEnumeratedAxis
or not. Also if they actually care about that, then it seems likely that they may have enough knowledge to change theCalibratedAxis
type. Are there instances where ImageJ2 will produce anet.imagej.Dataset
withnet.imagej.axis.EnumeratedAxis
? If not, then I think that is another point for dropping this behavior.main
already but I realize it has been passed around from one stale PR to another. Here it is! This change resolves a bug where getting the scale of a singleton dimension fails. This is because we calculate the slope from the dimensions coordinate array. The first two values are used for this math, which of course fails for singleton dimensions because their coordinate array is size1
. Thus all singleton dimensions should have their scale set to1
.update 1
Thanks @gselzer for adding in a good way to have both
EnumeratedAxis
andDefaultLinearAxis
as options based on coordinate array linearity.Things for me to do:
TODO:
update 2
I've added the following changes:
Finally
block and slightly reworked the logic.Finally
was always triggered and replaced theEnumeratedAxis
withDefaultLinearAxis
.DefaultLinearAxis
EnumeratedAxis
DefaultLinearAxis