dsa-helpers 0.9__tar.gz → 0.9.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {dsa_helpers-0.9/dsa_helpers.egg-info → dsa_helpers-0.9.dev1}/PKG-INFO +1 -1
  2. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/__init__.py +2 -0
  3. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/dash/header.py +10 -14
  4. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/girder_utils.py +21 -26
  5. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/datasets/__init__.py +1 -1
  6. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/object_detection/__init__.py +1 -1
  7. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/segformer_semantic_segmentation/__init__.py +1 -1
  8. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/segformer_semantic_segmentation/inference.py +2 -4
  9. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/tiling/__init__.py +1 -1
  10. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1/dsa_helpers.egg-info}/PKG-INFO +1 -1
  11. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers.egg-info/SOURCES.txt +0 -4
  12. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/pyproject.toml +1 -1
  13. dsa_helpers-0.9/.readthedocs.yaml +0 -16
  14. dsa_helpers-0.9/docs/requirements.txt +0 -16
  15. dsa_helpers-0.9/docs/source/conf.py +0 -42
  16. dsa_helpers-0.9/docs/source/index.rst +0 -18
  17. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/.gitignore +0 -0
  18. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/LICENSE +0 -0
  19. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/README.md +0 -0
  20. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/app.py +0 -0
  21. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/dash/__init__.py +0 -0
  22. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/dash/dash_paperdragon_utils.py +0 -0
  23. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/dash/header_callbacks.py +0 -0
  24. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/imread.py +0 -0
  25. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/imwrite.py +0 -0
  26. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/__init__.py +0 -0
  27. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/datasets/SegFormerSegmentationDataset.py +0 -0
  28. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/datasets/utils.py +0 -0
  29. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/metrics.py +0 -0
  30. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/object_detection/get_pearce_roi_images.py +0 -0
  31. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/object_detection/tile_image.py +0 -0
  32. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/object_detection/utils.py +0 -0
  33. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/tiling/semantic_seg_tile_wsi_with_dsa_annotations.py +0 -0
  34. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/transforms/__init__.py +0 -0
  35. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/ml/transforms/segformer_transforms.py +0 -0
  36. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/mongo_utils.py +0 -0
  37. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/tile_utils.py +0 -0
  38. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/tiling.py +0 -0
  39. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers/utils.py +0 -0
  40. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers.egg-info/dependency_links.txt +0 -0
  41. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers.egg-info/requires.txt +0 -0
  42. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/dsa_helpers.egg-info/top_level.txt +0 -0
  43. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/setup.cfg +0 -0
  44. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/tests/app/Dockerfile +0 -0
  45. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/tests/app/app.py +0 -0
  46. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/tests/docker-compose.yaml +0 -0
  47. {dsa_helpers-0.9 → dsa_helpers-0.9.dev1}/tests/test.ipynb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dsa_helpers
3
- Version: 0.9
3
+ Version: 0.9.dev1
4
4
  Summary: Utility functions for working with the DSA girder client.
5
5
  Author-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
6
6
  Maintainer-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
@@ -16,6 +16,8 @@ __all__ = [
16
16
  "girder_utils",
17
17
  "dash",
18
18
  "ml",
19
+ "imread",
20
+ "imwrite",
19
21
  "mongo_utils",
20
22
  "tiling",
21
23
  "utils",
@@ -15,8 +15,13 @@ def get_header(
15
15
  Args:
16
16
  dsa_api_url (str): The URL of the DSA API.
17
17
  title (str, optional): The title of the application. Defaults to "App".
18
- config (dict, optional): The configuration of the component.
19
- Defaults to None which uses default settings.
18
+ config (dict, optional): The configuration of the component. Defaults to None.
19
+ If None the default configuration is:
20
+ {
21
+ "backgroundColor": "#012169",
22
+ "titleColor": "#d9d9d6",
23
+ "fontColor": "#f2a900",
24
+ }
20
25
 
21
26
  Returns:
22
27
  html.Div: The header component.
@@ -33,8 +38,7 @@ def get_header(
33
38
  dbc.ModalBody(
34
39
  [
35
40
  html.Div(
36
- "Login or email",
37
- style={"margin": 5, "fontWeight": "bold"},
41
+ "Login or email", style={"margin": 5, "fontWeight": "bold"}
38
42
  ),
39
43
  dbc.Input(
40
44
  id=f"{store_id}=login",
@@ -44,11 +48,7 @@ def get_header(
44
48
  ),
45
49
  html.Div(
46
50
  "Password",
47
- style={
48
- "margin": 5,
49
- "marginTop": 15,
50
- "fontWeight": "bold",
51
- },
51
+ style={"margin": 5, "marginTop": 15, "fontWeight": "bold"},
52
52
  ),
53
53
  dbc.Input(
54
54
  id=f"{store_id}=password",
@@ -60,11 +60,7 @@ def get_header(
60
60
  "Login failed.",
61
61
  hidden=True,
62
62
  id=f"{store_id}=login-failed",
63
- style={
64
- "color": "red",
65
- "fontWeight": "bold",
66
- "margin": 10,
67
- },
63
+ style={"color": "red", "fontWeight": "bold", "margin": 10},
68
64
  ),
69
65
  ],
70
66
  ),
@@ -88,19 +88,19 @@ def get_region(
88
88
  height: int,
89
89
  mag: float | None = None,
90
90
  ) -> np.ndarray:
91
- """Get image region from DSA. Note that the output image might not
92
- be in the shape (width, height) if left + width or top + height
93
- exceeds the image size.
94
-
95
- Args:
96
- gc (girder_client.GirderClient): The authenticated girder client.
97
- item_id (str): The item id.
91
+ """Get a region of the image for an item. Note that the output image might
92
+ not be in the shape (width, height) if left + width or top + height exceeds
93
+ the image size. The outpuzerositem id.
98
94
  left (int): The left coordinate.
99
95
  top (int): The top coordinate.
100
96
  width (int): The width of the region.
101
97
  height (int): The height of the region.
102
- mag (float, optional): The magnification. Defaults to None which
103
- returns the image at the scan magnification.
98
+ mag (float, optional): The magnification. Defaults to None which returns
99
+ the image at scan magnification. Using a mag lower than the scan
100
+ magnification will result in an ouptut image smaller than the
101
+ width and height. Similarly, using a mag higher than the scan
102
+ magnification will result in an output image larger than the width
103
+ and height.
104
104
 
105
105
  Returns:
106
106
  np.ndarray: The region of the image.
@@ -258,16 +258,17 @@ def _rotate_point_list(point_list, rotation, center=(0, 0)):
258
258
  return point_list_rotated
259
259
 
260
260
 
261
- def get_rectangle_element_coords(element: dict) -> np.ndarray:
261
+ def get_rectangle_element_coords(element):
262
262
  """Get the corner coordinate from a rectangle HistomicsUI element, can handle rotated elements.
263
263
  Adapted from: https://github.com/DigitalSlideArchive/HistomicsTK/blob/master/histomicstk/annotations_and_masks/annotation_and_mask_utils.py
264
-
265
- Args:
266
- element (dict): rectangle element from HistomicsUI annotation.
267
-
268
- Returns:
269
- corner_coords (np.ndarray): 4x2 array of corner coordinates of rectangle.
270
-
264
+ INPUTS
265
+ ------
266
+ element : dict
267
+ rectangle element, in HistomicsUI format
268
+ RETURN
269
+ ------
270
+ corner_coords : array
271
+ array of shape [4, 2] for the four corners of the rectangle in (x, y) format
271
272
  """
272
273
  # element is a dict so prevent referencing
273
274
  element = deepcopy(element)
@@ -400,9 +401,7 @@ def get_roi_with_yolo_labels_from_single_doc(
400
401
  if element.get("group") == roi_element_group:
401
402
  # Append the ROI element, there can't more than one.
402
403
  if roi_element is not None:
403
- raise ValueError(
404
- "Multiple ROI elements found in the document."
405
- )
404
+ raise ValueError("Multiple ROI elements found in the document.")
406
405
 
407
406
  roi_element = element
408
407
  elif element.get("group") in group_map:
@@ -461,9 +460,7 @@ def get_roi_with_yolo_labels_from_single_doc(
461
460
  for element in box_elements:
462
461
  if element.get("group") in group_map:
463
462
  if element.get("type") != "rectangle":
464
- print(
465
- f"Skipping element: {element.get('type')} not supported."
466
- )
463
+ print(f"Skipping element: {element.get('type')} not supported.")
467
464
  continue
468
465
 
469
466
  group_id = group_map[element.get("group")]
@@ -526,9 +523,7 @@ def post_annotations_from_gdf(
526
523
  # Process the dataframe.
527
524
  for _, row in gdf.iterrows():
528
525
  # Flatten multipolygon to list of polygons.
529
- list_of_polygons = list(
530
- row["geometry"].geoms
531
- ) # assuming multipolygons
526
+ list_of_polygons = list(row["geometry"].geoms) # assuming multipolygons
532
527
  label = row["label"]
533
528
 
534
529
  for poly in list_of_polygons:
@@ -1,3 +1,3 @@
1
1
  from .SegFormerSegmentationDataset import SegFormerSegmentationDataset
2
2
 
3
- __all__ = ["utils"]
3
+ __all__ = ["SegFormerSegmentationDataset", "utils"]
@@ -2,4 +2,4 @@
2
2
  from .get_pearce_roi_images import get_pearce_roi_images
3
3
  from .tile_image import tile_image
4
4
 
5
- __all__ = ["utils"]
5
+ __all__ = ["utils", "get_pearce_roi_images", "tile_image"]
@@ -1,3 +1,3 @@
1
1
  from .inference import inference
2
2
 
3
- __all__ = []
3
+ __all__ = ["inference"]
@@ -10,7 +10,7 @@ import torch
10
10
  import torch.nn as nn
11
11
 
12
12
  from ... import imread
13
- from ...tiling import tile_image
13
+ from ...image_utils import tile_image
14
14
 
15
15
 
16
16
  def inference(
@@ -115,9 +115,7 @@ def inference(
115
115
  predicted_mask = predicted_mask[:h, :w]
116
116
 
117
117
  # Extract the contours of the mask.
118
- contours = cv.findContours(
119
- predicted_mask, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE
120
- )[0]
118
+ contours = cv.findContours(predicted_mask, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)[0]
121
119
 
122
120
  # Return the mask.
123
121
  return predicted_mask, contours
@@ -2,4 +2,4 @@ from .semantic_seg_tile_wsi_with_dsa_annotations import (
2
2
  semantic_seg_tile_wsi_with_dsa_annotations,
3
3
  )
4
4
 
5
- __all__ = []
5
+ __all__ = ["semantic_seg_tile_wsi_with_dsa_annotations"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dsa_helpers
3
- Version: 0.9
3
+ Version: 0.9.dev1
4
4
  Summary: Utility functions for working with the DSA girder client.
5
5
  Author-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
6
6
  Maintainer-email: "Juan C. Vizcarra" <jvizcar@emory.edu>
@@ -1,12 +1,8 @@
1
1
  .gitignore
2
- .readthedocs.yaml
3
2
  LICENSE
4
3
  README.md
5
4
  app.py
6
5
  pyproject.toml
7
- docs/requirements.txt
8
- docs/source/conf.py
9
- docs/source/index.rst
10
6
  dsa_helpers/__init__.py
11
7
  dsa_helpers/girder_utils.py
12
8
  dsa_helpers/imread.py
@@ -35,7 +35,7 @@ classifiers = [
35
35
  "License :: OSI Approved :: MIT License",
36
36
  ]
37
37
  keywords = ["dsa", "girder", "girder_client"]
38
- version = "v0.9"
38
+ version = "v0.9dev1"
39
39
 
40
40
  [project.urls]
41
41
  Repository = "https://github.com/Gutman-Lab/dsa-python-utils"
@@ -1,16 +0,0 @@
1
- version: 2
2
-
3
- build:
4
- os: "ubuntu-24.04"
5
- tools:
6
- python: "3.12"
7
- jobs:
8
- pre_build:
9
- - sphinx-apidoc -o docs/source dsa_helpers/
10
-
11
- python:
12
- install:
13
- - requirements: docs/requirements.txt
14
-
15
- sphinx:
16
- configuration: docs/source/conf.py
@@ -1,16 +0,0 @@
1
- girder-client
2
- numpy
3
- setuptools
4
- opencv-python
5
- pandas
6
- pymongo
7
- pillow
8
- dash
9
- dash-bootstrap-components
10
- shapely
11
- geopandas
12
- transformers[torch]
13
- datasets
14
- torchvision
15
- large-image
16
- sphinx_rtd_theme
@@ -1,42 +0,0 @@
1
- # Configuration file for the Sphinx documentation builder.
2
- #
3
- # For the full list of built-in configuration values, see the documentation:
4
- # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
-
6
- # -- Path setup --------------------------------------------------------------
7
-
8
- # If extensions (or modules to document with autodoc) are in another directory,
9
- # add these directories to sys.path here. If the directory is relative to the
10
- # documentation root, use os.path.abspath to make it absolute, like shown here.
11
- #
12
- import os
13
- import sys
14
-
15
- sys.path.insert(0, os.path.abspath("../.."))
16
-
17
- # -- Project information -----------------------------------------------------
18
- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
19
-
20
- project = "DSA Helpers"
21
- copyright = "2024, Juan Carlos Vizcarra"
22
- author = "Juan Carlos Vizcarra"
23
- release = "00.00.01"
24
-
25
- # -- General configuration ---------------------------------------------------
26
- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
27
-
28
- extensions = [
29
- "sphinx.ext.autodoc",
30
- "sphinx.ext.viewcode",
31
- "sphinx.ext.napoleon",
32
- ]
33
-
34
- templates_path = ["_templates"]
35
- exclude_patterns = []
36
-
37
-
38
- # -- Options for HTML output -------------------------------------------------
39
- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
40
-
41
- html_theme = "sphinx_rtd_theme"
42
- html_static_path = ["_static"]
@@ -1,18 +0,0 @@
1
- .. DSA Helpers documentation master file, created by
2
- sphinx-quickstart on Fri Dec 6 12:07:31 2024.
3
- You can adapt this file completely to your liking, but it should at least
4
- contain the root `toctree` directive.
5
-
6
- DSA Helpers documentation
7
- =========================
8
-
9
- Add your content using ``reStructuredText`` syntax. See the
10
- `reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
11
- documentation for details.
12
-
13
-
14
- .. toctree::
15
- :maxdepth: 2
16
- :caption: Contents:
17
-
18
- modules
File without changes
File without changes
File without changes
File without changes
File without changes