-
Notifications
You must be signed in to change notification settings - Fork 71
improviements to transforms: robustness and ergonomics #100
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
Conversation
…ansform from input and output coordinate system; 2. fixed but in sequence (now inferring coordinate systems from its components); 3. added missing test for inferencen of intermediate coordinate systems for nested sequences
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
==========================================
+ Coverage 84.22% 87.76% +3.54%
==========================================
Files 19 22 +3
Lines 1914 3105 +1191
==========================================
+ Hits 1612 2725 +1113
- Misses 302 380 +78
|
for more information, see https://pre-commit.ci
…erse/spatialdata into feature/transform_ergonomics
for more information, see https://pre-commit.ci
|
EDIT: this post referst to the first tentative implementation. I removed the code which generated these complex transformation in favor of the new transformation classes. As mentioned in my previous post, a downside of "setter for elements to check that the transfomration makes sense (if not, tries to fix it)" is that very verbose transformations are generated. For instance this code here: Leads to this transformation here: Which saved to json is insanely verbose: The corresponding affine matrix is the following: So maybe we should just save the affine matrix to disk, which is something reasonable: |
…erse/spatialdata into feature/transform_ergonomics
…tching cs; added relative test
|
After discussing with @giovp I will refactor into separate classes to divide what is purely a NGFF transform from what is built on top of it for ergonomics. The reasons are the following:
The old version of the code can be found in the previous commit, as well as in a separate branch created from it. If the new code works as planned I'll delete the branch (which I already tagged for archiving purposes and can be found here). |
Co-authored-by: Giovanni Palla <[email protected]>
for more information, see https://pre-commit.ci
I think that we need two functions:
The need to have methods of Still we could change the second function to this: Here are the pro and cons of this second approach.
Con:
My proposal is to require unique names for elements (separate PR) and after that to change the second function as described (another PR). For the moment, I don't think we will have problems of copy/views, things should work. |
…erse/spatialdata into feature/transform_ergonomics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @LucaMarconato ! I think this is a solid step in the right direction. I am approving so that we can keep things moving forward. I think we will have to continue to iterate on API, etc., but it will be easier to do so when we actually use it to make vignettes, etc.
one for getting a transformation between one target and one source, and this would need to be a method of SpatialData since it needs to build the digraph of the transformations of the elements that are inside. This is currently the function map_coordinate_systems(). We can change the name, it's a bit confusing. Maybe map()?
Perhaps it could be called something like get_transformation_between_coordinate_systems()? Probably too long, but more descriptive. In any case, I agree that map_coordinate_systems() is probably not the most clear name.
Does this method actually need to be on SpatialData? It seems to me that one could still construct the directed graph of the transformations on a given element. Perhaps I'm missing something though.
|
Thanks for the comments @kevinyamauchi, I have removed the functions |
|
I will now merge the new points io pr, it will take some times to fix all the tests, but then we'll be ready to merge! |
Co-authored-by: Kevin Yamauchi <[email protected]>
…erse/spatialdata into feature/transform_ergonomics
for more information, see https://pre-commit.ci
…erse/spatialdata into feature/transform_ergonomics
…ssing optional FEATURE_KEY); added tests
|
@LucaMarconato quick thing I noticed from working in #132 : the |
|
Hi, true I didn't fix it actually. A quick fix would be great thanks. |
This pr improves stability and ergonomics of coordinate systems, and in particular helps with #39
Detailed list of what will be implemented.
Some tick boxes are deleted because I have decided to perform a deeper code restructuring (introducing new transformations classes); if I had the item already implemented I then deleted the code.
For the moment I allow only one transformation per element and I am not using at all the coordinate systems. I already set the code ready to do that but will do this in the next PR to keep this PR a bit more contained.
Major (updated plan: new transformation classes)
SpatialDataobjectspa.Tableobjects (Points)GeoDataFrameobjects (Polygons)AnnDataobjects (Shapes`SpatialImage(Image and Labels)MultiscaleSpatialImage(Image and Labels)set_transformandget_transform, when applied to the whole object. Specifically:set_transformwill update all of them (taking as input the one on the largest level) andget_transformwill get the one of the largest level.Major (original plan)
the following crossed out points are not needed anymore with the new transform classes
- [X] simplify the logic of inference of coordinate systems inSequence(functioncheck_and_infer_coordinate_systems())- [x] makeSequencealso accept the concatenation of transformations with axes mismatch (eg. xy with cyx), by adding automatically the appropriate axis permutations, insertion/deletion- [x] setter for elements to check that the transfomration makes sense (if not, suggests how to fix) (see my next comment for a downside of this)- [ ] save the affine transformation to the file to avoid verbosity__repr__for coordinate transformationsMinor
Sequencetransformation: make input and output in contatenation inferred from initSequence, covering the case of inference of the intermediate coordinate system for nestedSequencetransformationsinput_coordinate_systemandoutput_coordinate_systemas a string inside a transformation object, to deal with some edge cases of implicit coordinate systems. Now this complexity is not needed because thanks to the schema mechanism, the spatial elements are more structured, and we can easily infer from them what is the implicit coordinate system.Affine.from_input_output_coordinate_systems())Bonus