diff --git a/src/nd2/structures.py b/src/nd2/structures.py index 98c26b9..400bbb4 100644 --- a/src/nd2/structures.py +++ b/src/nd2/structures.py @@ -450,10 +450,22 @@ def _from_meta_dict(cls, val: dict) -> ROI: # 'Id', 'Info', 'GUID', 'AnimParams_Size', 'AnimParams_{i}' # where GUID and AnimParams keys are optional anim_params = [ - AnimParam(**{_lower0(k): v for k, v in val[f"AnimParams_{i}"].items()}) + AnimParam( + **{ + _lower0(k): v + for k, v in val[f"AnimParams_{i}"].items() + if _lower0(k) in AnimParam.__annotations__ + } + ) for i in range(val.get("AnimParams_Size", 0)) ] - info = RoiInfo(**{_lower0(k): v for k, v in val["Info"].items()}) + info = RoiInfo( + **{ + _lower0(k): v + for k, v in val["Info"].items() + if _lower0(k) in RoiInfo.__annotations__ + } + ) return cls( id=val["Id"], info=info, @@ -486,7 +498,11 @@ class AnimParam: def __post_init__(self) -> None: if isinstance(self.boxShape, dict): self.boxShape = BoxShape( - **{_lower0(k): v for k, v in self.boxShape.items()} + **{ + _lower0(k): v + for k, v in self.boxShape.items() + if _lower0(k) in BoxShape.__annotations__ + } ) if isinstance(self.extrudedShape, dict): self.extrudedShape = ExtrudedShape._from_meta_dict(self.extrudedShape)