Skip to content

Commit

Permalink
fix: fix extraction of xy points in extruded shapes (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Oct 10, 2023
1 parent 82e7005 commit 2fe31e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nd2/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def _from_meta_dict(cls, val: dict) -> ExtrudedShape:
return cls(
sizeZ=val.get("SizeZ") or val.get("sizeZ") or 0,
basePoints=[
XYPoint(*val[f"BasePoints_{i}"].get("", []))
XYPoint(*val[f"BasePoints_{i}"].values())
for i in range(val.get("BasePoints_Size", 0))
],
)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_rois.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path

import nd2
from nd2.structures import InterpType

DATA = Path(__file__).parent / "data"

Expand All @@ -10,3 +11,16 @@ def test_rois():
rois = f.rois.values()
assert len(rois) == 18
assert [r.id for r in rois] == list(range(1, 19))

roi1 = f.rois[1]
assert roi1.info.label == "rect bgrd"

roi16 = f.rois[16]
assert roi16.info.label == "S3:16 stim 3 poly"
assert roi16.info.interpType == InterpType.StimulationROI
assert roi16.animParams[0].extrudedShape.basePoints == [
(-0.05231780847932399, -0.10247210748706266),
(0.09780325689597874, 0.04522765038218665),
(0.030006646726487105, 0.11302426055167814),
(-0.0959013435882828, -0.05646726487205058),
]

0 comments on commit 2fe31e0

Please sign in to comment.