Skip to content

🆕 Address TIAViz Review Comments #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
efdf790
address review comments
measty Jul 31, 2024
deb1d12
Merge branch 'develop' into address-review-comments
measty Jul 31, 2024
3e7938b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2024
2724b26
Merge branch 'develop' into address-review-comments
shaneahmed Aug 9, 2024
b0414d5
Merge branch 'develop' into address-review-comments
shaneahmed Aug 16, 2024
e770710
Merge branch 'develop' into address-review-comments
shaneahmed Aug 23, 2024
9a2938b
Merge branch 'develop' into address-review-comments
shaneahmed Sep 20, 2024
b8b3a71
Merge branch 'develop' into address-review-comments
shaneahmed Sep 27, 2024
aca8588
Merge branch 'develop' into address-review-comments
shaneahmed Oct 25, 2024
d7e33f8
Merge branch 'develop' into address-review-comments
shaneahmed Nov 22, 2024
82b7bd1
Merge branch 'develop' into address-review-comments
shaneahmed Jan 24, 2025
b342823
Merge branch 'develop' into address-review-comments
shaneahmed Feb 7, 2025
b2ff5c1
Merge branch 'develop' into address-review-comments
shaneahmed Feb 21, 2025
768fb27
Merge branch 'develop' into address-review-comments
shaneahmed Mar 7, 2025
1efaaaf
Merge branch 'develop' into address-review-comments
shaneahmed Mar 14, 2025
126c65c
Merge branch 'develop' into address-review-comments
shaneahmed Apr 4, 2025
4ac6e61
Merge branch 'develop' into address-review-comments
shaneahmed Apr 11, 2025
f2783bf
Merge branch 'develop' into address-review-comments
shaneahmed Apr 25, 2025
6c89b1c
Merge branch 'develop' into address-review-comments
shaneahmed May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tiatoolbox/annotation/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,20 @@ def transform_geometry(geom: Geometry) -> Geometry:
)
for feature in geojson["features"]
]
# check for presence of 'nucleusGeometry' key in features
# if present, add them (qupath export format)
annotations += [
transform(
Annotation(
transform_geometry(
feature2geometry(feature["nucleusGeometry"]),
),
{},
),
)
for feature in geojson["features"]
if "nucleusGeometry" in feature
]

logger.info("Adding %d annotations.", len(annotations))
self.append_many(annotations)
Expand Down
36 changes: 34 additions & 2 deletions tiatoolbox/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,41 @@ def render_pt(
top_left,
scale,
)[0][0],
np.maximum(self.edge_thickness, 1),
np.maximum(int(16 / scale**0.5), 1),
col,
thickness=self.thickness,
thickness=-1,
)

def render_pts(
self: AnnotationRenderer,
tile: np.ndarray,
annotation: Annotation,
top_left: tuple[float, float],
scale: float,
) -> None:
"""Render a multipoint annotation onto a tile using cv2.

Args:
tile (ndarray):
The rgb(a) tile image to render onto.
annotation (Annotation):
The annotation to render.
top_left (tuple):
The top left corner of the tile in wsi.
scale (float):
The zoom scale at which we are rendering.

"""
col = self.get_color(annotation, edge=False)
for pt in annotation.coords:
cv2.circle(
tile,
self.to_tile_coords([pt], top_left, scale)[0][0],
np.maximum(int(16 / scale**0.5), 1),
col,
thickness=-1,
)

def render_line(
self: AnnotationRenderer,
tile: np.ndarray,
Expand Down Expand Up @@ -1058,5 +1088,7 @@ def render_by_type(
self.render_poly(tile, annotation, top_left, scale)
elif geom_type == GeometryType.LINE_STRING:
self.render_line(tile, annotation, top_left, scale)
elif geom_type == GeometryType.MULTI_POINT:
self.render_pts(tile, annotation, top_left, scale)
else:
logger.warning("Unknown geometry: %s", geom_type, stacklevel=3)
5 changes: 3 additions & 2 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ def add_layer(lname: str) -> None:
end=1,
value=0.75,
step=0.01,
title=lname,
height=40,
width=100,
max_width=90,
Expand Down Expand Up @@ -1053,7 +1052,9 @@ def layer_slider_cb(
UI["vstate"].layer_dict[obj.name.split("_")[0]]
].glyph.line_alpha = new
else:
UI["p"].renderers[UI["vstate"].layer_dict[obj.name.split("_")[0]]].alpha = new
UI["p"].renderers[
UI["vstate"].layer_dict["_".join(obj.name.split("_")[0:-1])]
].alpha = new


def color_input_cb(
Expand Down
2 changes: 1 addition & 1 deletion tiatoolbox/visualization/tileserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def change_overlay(self: TileServer) -> str:
overlay_path = self.decode_safe_name(overlay_path)

if overlay_path.suffix in [".jpg", ".png", ".tiff", ".svs", ".ndpi", ".mrxs"]:
layer = f"layer{len(self.pyramids[session_id])}"
layer = overlay_path.stem
if overlay_path.suffix == ".tiff":
self.layers[session_id][layer] = OpenSlideWSIReader(
overlay_path,
Expand Down
Loading