Skip to content

Commit

Permalink
docstring improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
measty committed Oct 13, 2023
1 parent 30c7230 commit 1f73712
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in the slides folder should be all the slides you want to use, and the overlays
When a slide is selected in the interface, any valid overlay file that can be found that *contains the same name* (not including extension) will be available to overlay upon it.

Segmentation
^^^^^^^^^^^^^
^^^^^^^^^^^^

The best way of getting segmentations (in the form of contours) into the visualization is by putting them in an AnnotationStore (more information about hte tiatoolbox annotation store can be found at :obj:`storage <tiatoolbox.annotation.storage>`. The other options are .geojson, or a hovernet -style .dat, both of which can usually be loaded within the interface but will incur a small delay while the data in converted internally into an AnnotationStore.

Expand Down
1 change: 1 addition & 0 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from bokeh.plotting import figure
from bokeh.util import token

# github actions seems unable to find tiatoolbox unless this is here
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent))
from tiatoolbox import logger # noqa: E402
from tiatoolbox.models.engine.nucleus_instance_segmentor import ( # noqa: E402
Expand Down
45 changes: 41 additions & 4 deletions tiatoolbox/visualization/tileserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,12 @@ def change_secondary_cmap(self: TileServer) -> str:
return "done"

def update_renderer(self: TileServer, prop: str) -> str:
"""Update a property in the renderer."""
"""Update a property in the renderer.
Args:
prop (str): The property to update.
"""
session_id = self._get_session_id()
val = request.form["val"]
val = json.loads(val)
Expand All @@ -448,6 +453,9 @@ def load_annotations(self: TileServer) -> str:
Adds to an existing store if one is already present,
otherwise creates a new store.
Returns:
str: A jsonified list of types.
"""
session_id = self._get_session_id()
file_path = request.form["file_path"]
Expand Down Expand Up @@ -485,6 +493,9 @@ def change_overlay(self: TileServer) -> str:
is replaced with the new one. If the path points to an image,
it is added as a new layer.
Returns:
str: A jsonified list of types.
"""
session_id = self._get_session_id()
overlay_path = request.form["overlay_path"]
Expand Down Expand Up @@ -536,7 +547,15 @@ def change_overlay(self: TileServer) -> str:
return json.dumps(types)

def get_properties(self: TileServer, ann_type: str) -> str:
"""Get all the properties of the annotations in the store."""
"""Get all the properties of the annotations in the store.
Args:
ann_type (str): The type of annotations to get the properties for.
Returns:
str: A jsonified list of the properties.
"""
session_id = self._get_session_id()
where = None
if ann_type != "all":
Expand All @@ -552,7 +571,15 @@ def get_properties(self: TileServer, ann_type: str) -> str:
return json.dumps(list(set(props)))

def get_property_values(self: TileServer, prop: str, ann_type: str) -> str:
"""Get all the values of a property in the store."""
"""Get all the values of a property in the store.
Args:
prop (str): The property to get the values of.
ann_type (str): The type of annotations to get the values for.
Returns:
str: A jsonified list of the values of the property.
"""
session_id = self._get_session_id()
where = None
if ann_type != "all":
Expand Down Expand Up @@ -639,7 +666,17 @@ def get_secondary_cmap(self: TileServer) -> Response:
return jsonify(mapper)

def tap_query(self: TileServer, x: float, y: float) -> Response:
"""Query annotations at a point."""
"""Query for annotations at a point.
Args:
x (float): The x coordinate.
y (float): The y coordinate.
Returns:
Response: The jsonified dict of the properties of the
smallest annotation returned from the query at the point.
"""
session_id = self._get_session_id()
anns = self.get_ann_layer(session_id).store.query(
Point(x, y),
Expand Down

0 comments on commit 1f73712

Please sign in to comment.