Skip to content

Commit

Permalink
Use image scale for points annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-sweet committed Mar 29, 2024
1 parent e285545 commit 18659d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/napari_cryoet_data_portal/_open_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ def _loadTomogram(
# Materialize low resolution immediately on this thread to prevent napari blocking.
if resolution is LOW_RESOLUTION:
image_data = np.asarray(image_data)
# Get scale before resolution scaling for annotations.
image_scale = image_attrs["scale"]

Check warning on line 150 in src/napari_cryoet_data_portal/_open_widget.py

View check run for this annotation

Codecov / codecov/patch

src/napari_cryoet_data_portal/_open_widget.py#L150

Added line #L150 was not covered by tests
image_attrs["scale"] = tuple(
resolution.scale * s for s in image_attrs["scale"]
resolution.scale * s for s in image_scale
)
image_translate = image_attrs.get("translate", (0,) * len(image_attrs["scale"]))
image_attrs["translate"] = tuple(
Expand All @@ -171,7 +173,13 @@ def _loadTomogram(
if f.shape_type == "Point"
)
if len(point_paths) > 0:
yield read_annotation(annotation, tomogram=tomogram)
anno_data, anno_attrs, anno_type = read_annotation(annotation, tomogram=tomogram)

Check warning on line 176 in src/napari_cryoet_data_portal/_open_widget.py

View check run for this annotation

Codecov / codecov/patch

src/napari_cryoet_data_portal/_open_widget.py#L176

Added line #L176 was not covered by tests
# Inherit scale from full resolution image so that we can pick up
# that scale when it changes.
anno_attrs["scale"] = image_scale

Check warning on line 179 in src/napari_cryoet_data_portal/_open_widget.py

View check run for this annotation

Codecov / codecov/patch

src/napari_cryoet_data_portal/_open_widget.py#L179

Added line #L179 was not covered by tests
# Scaling points also changes the size, so adjust accordingly.
anno_attrs["size"] /= np.mean(image_scale)
yield anno_data, anno_attrs, anno_type

Check warning on line 182 in src/napari_cryoet_data_portal/_open_widget.py

View check run for this annotation

Codecov / codecov/patch

src/napari_cryoet_data_portal/_open_widget.py#L181-L182

Added lines #L181 - L182 were not covered by tests
else:
logger.warn("Found no points annotations. Skipping.")

Expand Down

0 comments on commit 18659d0

Please sign in to comment.