Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
FIX: Wrong initialization of panorama coordinates #74. Store all rect…
Browse files Browse the repository at this point in the history
…'s coordinates (like in raw data) due to some confusion and unclarity which point is served as a center of rotation.
  • Loading branch information
plankter committed May 4, 2020
1 parent fbb6b90 commit 3eb3abe
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 28 deletions.
72 changes: 48 additions & 24 deletions imctools/data/panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ class PanoramaDict(TypedDict):
id: int
image_type: str
description: str
start_position_x: float
start_position_y: float
width: float
height: float
x1: float
y1: float
x2: float
y2: float
x3: float
y3: float
x4: float
y4: float
rotation_angle: float
metadata: Optional[Dict[str, str]]

Expand All @@ -35,10 +39,14 @@ def __init__(
id: int,
image_type: str,
description: str,
start_position_x: float,
start_position_y: float,
width: float,
height: float,
x1: float,
y1: float,
x2: float,
y2: float,
x3: float,
y3: float,
x4: float,
y4: float,
rotation_angle: float,
metadata: Optional[Dict[str, str]] = None,
):
Expand All @@ -53,14 +61,22 @@ def __init__(
Image type (Imported, Instrument, Default).
description
Panorama description.
start_position_x
X coordinate of start panorama position on the slide (in μm).
start_position_y
Y coordinate of start panorama position on the slide (in μm).
width
Panorama physical width (in μm).
height
Panorama physical height (in μm).
x1
X1 coordinate of panorama position on the slide (in μm).
y1
Y1 coordinate of panorama position on the slide (in μm).
x2
X2 coordinate of panorama position on the slide (in μm).
y2
Y2 coordinate of panorama position on the slide (in μm).
x3
X3 coordinate of panorama position on the slide (in μm).
y3
Y3 coordinate of panorama position on the slide (in μm).
x4
X4 coordinate of panorama position on the slide (in μm).
y4
Y4 coordinate of panorama position on the slide (in μm).
rotation_angle
Panorama rotation angle (degrees).
metadata
Expand All @@ -70,10 +86,14 @@ def __init__(
self.id = id
self.image_type = image_type
self.description = description
self.start_position_x = start_position_x
self.start_position_y = start_position_y
self.width = width
self.height = height
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.x3 = x3
self.y3 = y3
self.x4 = x4
self.y4 = y4
self.rotation_angle = rotation_angle
self.metadata = metadata

Expand All @@ -87,10 +107,14 @@ def from_dict(d: PanoramaDict):
d.get("id"),
d.get("image_type"),
d.get("description"),
d.get("start_position_x"),
d.get("start_position_y"),
d.get("width"),
d.get("height"),
d.get("x1"),
d.get("y1"),
d.get("x2"),
d.get("y2"),
d.get("x3"),
d.get("y3"),
d.get("x4"),
d.get("y4"),
d.get("rotation_angle"),
metadata=d.get("metadata"),
)
Expand Down
10 changes: 6 additions & 4 deletions imctools/io/mcd/mcdxmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ def __init__(self, mcd_xml: str, source_path: str, process_namespaces=False):
session.slides[slide.id] = slide

for p in self.metadata.get(const.PANORAMA):
width = abs(float(p.get(const.SLIDE_X3_POS_UM, 0)) - float(p.get(const.SLIDE_X1_POS_UM, 0)))
height = abs(float(p.get(const.SLIDE_Y3_POS_UM, 0)) - float(p.get(const.SLIDE_Y1_POS_UM, 0)))
panorama = Panorama(
int(p.get(const.SLIDE_ID)),
int(p.get(const.ID)),
p.get(const.TYPE),
p.get(const.DESCRIPTION, "Pano"),
float(p.get(const.SLIDE_X1_POS_UM, 0)),
float(p.get(const.SLIDE_Y1_POS_UM, 0)),
width,
height,
float(p.get(const.SLIDE_X2_POS_UM, 0)),
float(p.get(const.SLIDE_Y2_POS_UM, 0)),
float(p.get(const.SLIDE_X3_POS_UM, 0)),
float(p.get(const.SLIDE_Y3_POS_UM, 0)),
float(p.get(const.SLIDE_X4_POS_UM, 0)),
float(p.get(const.SLIDE_Y4_POS_UM, 0)),
float(p.get(const.ROTATION_ANGLE, 0)),
metadata=dict(p),
)
Expand Down

0 comments on commit 3eb3abe

Please sign in to comment.