Fix: 2D coords into atlas space - #110
Conversation
- BR coords to atlas space - Remove coord negation in slicer_2D example
- logic moved in-line to Slicer.get_structures_slice_coords
- checks, mesh coords are correct - checks, tuple orientation coords(1, 0, 0), etc. VS named orientation
- checks, ax.patches are drawn on ax.images - runs test directly with runpy
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
+ Coverage 69.63% 77.50% +7.86%
==========================================
Files 5 5
Lines 326 360 +34
==========================================
+ Hits 227 279 +52
+ Misses 99 81 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@IgorTatarnikov It closes your issues, would be great to get your review and see if the coords are as expected or something still broken. tysm |
IgorTatarnikov
left a comment
There was a problem hiding this comment.
Hi @zenWai, apologies it took so long for me to look at this.
This looks great! The axis aligned slicing now returns the correct positions.
However, for the oblique case, some of the axes end up displaying as negative. This should not be the case if we're referring to the real world anatomical coordinates. See below for a screenshot.
| projected = {} | ||
| for actor in regions: | ||
| intersection = self.plane0.intersect_with(actor._mesh) | ||
| if not intersection.vertices.shape[0]: | ||
| continue | ||
| pieces = intersection.split() | ||
| for piece_n, piece in enumerate(pieces): | ||
| points = piece.join(reset=True).vertices | ||
| projected[actor.name + f"_segment_{piece_n}"] = ( | ||
| self._project_to_2d(points) | ||
| ) |
There was a problem hiding this comment.
Is there a way to avoid duplicating this with the function that already exists in plane.py?
Description
What is this PR
Why is this PR needed?
Related to 2D:
brainglobe-heatmapare potentially wrong #55)slicer_2D.pyexample contours not overlapping with reference ([BUG] slicer_2D.py example is broken #72)get_coordinates.pyexample returning brain center of mass coordinatesWhat does this PR do?
This PR adds a separate projection step in the Slicer
_project_to_2d( )that:New tests:
test_get_coordinates.pytest_slicer_2d_example.pyslicer_2D.pyexample end-to-end, verifies region contours are drawn on top of the brain imageNew example:
heatmap_2d_subplots_oblique.pyThe
get_projections( )method is preserved for anyone using plane centered coordinates and doc updated.References
brainglobe-heatmapare potentially wrong #55How has this PR been tested?
plan.pyexample-like to confirm every plane0 projections on 3D match 2D new example images.Is this a breaking change?
Yes ✔
Expectations of get_structures_slice_coords() changes:
slicer_2D.pydid with -cont[:, 1]) will need to remove that negationDoes this PR require an update to the documentation?
No
Checklist: