dsa-helpers 1.0.2.dev0__tar.gz → 1.0.3__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.
- {dsa_helpers-1.0.2.dev0/dsa_helpers.egg-info → dsa_helpers-1.0.3}/PKG-INFO +3 -14
- dsa_helpers-1.0.3/README.md +13 -0
- dsa_helpers-1.0.3/dsa_helpers/__init__.py +6 -0
- dsa_helpers-1.0.3/dsa_helpers/dash/__init__.py +3 -0
- dsa_helpers-1.0.3/dsa_helpers/ml/__init__.py +2 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/datasets/__init__.py +2 -1
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/object_detection/__init__.py +1 -1
- dsa_helpers-1.0.3/dsa_helpers/ml/transforms/__init__.py +1 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/tiling.py +97 -1
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3/dsa_helpers.egg-info}/PKG-INFO +3 -14
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/pyproject.toml +1 -1
- dsa_helpers-1.0.2.dev0/README.md +0 -24
- dsa_helpers-1.0.2.dev0/dsa_helpers/__init__.py +0 -23
- dsa_helpers-1.0.2.dev0/dsa_helpers/dash/__init__.py +0 -3
- dsa_helpers-1.0.2.dev0/dsa_helpers/ml/__init__.py +0 -20
- dsa_helpers-1.0.2.dev0/dsa_helpers/ml/transforms/__init__.py +0 -1
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/.gitignore +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/.readthedocs.yaml +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/LICENSE +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/app.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/docs/requirements.txt +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/docs/source/conf.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/docs/source/index.rst +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/dash/dash_paperdragon_utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/dash/header.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/dash/header_callbacks.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/girder_utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/imread.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/imwrite.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/callbacks.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/datasets/SegFormerSegmentationDataset.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/datasets/utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/evaluate.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/metrics.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/object_detection/get_pearce_roi_images.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/object_detection/tile_image.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/object_detection/utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/segformer_semantic_segmentation/__init__.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/segformer_semantic_segmentation/inference.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/transforms/segformer_transforms.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/mongo_utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/tile_utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/utils.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers.egg-info/SOURCES.txt +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers.egg-info/dependency_links.txt +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers.egg-info/requires.txt +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers.egg-info/top_level.txt +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/setup.cfg +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/tests/app/Dockerfile +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/tests/app/app.py +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/tests/docker-compose.yaml +0 -0
- {dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/tests/test.ipynb +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: dsa_helpers
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
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>
|
|
@@ -39,15 +39,4 @@ This Python PyPI package is found [here](https://pypi.org/project/dsa-helpers/).
|
|
|
39
39
|
## Extra dependencies
|
|
40
40
|
If you are getting a large image error, then install large image using the instructions provided in their [GitHub page](https://github.com/girder/large_image#:~:text=pip%20install%20large%2Dimage%5Ball%5D%20%2D%2Dfind%2Dlinks%20https%3A//girder.github.io/large_image_wheels).
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
1. Install requirements for building and distributing package:
|
|
44
|
-
```
|
|
45
|
-
$ python3 -m pip install --upgrade build # for building package
|
|
46
|
-
$ python3 -m pip install --upgrade twine # for uploading to PyPI
|
|
47
|
-
```
|
|
48
|
-
2. When ready to build:
|
|
49
|
-
- Modify "pyproject.toml" file, change the "version" key to a different value than a version already pushed.
|
|
50
|
-
- Run ```$ python3 -m build```. This will create a dist directory and put your new wheel and tar distribution files there.
|
|
51
|
-
3. To install locally for development: ```$ pip3 install dist/dsa_helpers-*.whl```, choosing the wheel version you want to test.
|
|
52
|
-
4. Upload to PyPI using twine: ```python3 -m twine upload --repository pypi dist/*```
|
|
53
|
-
* You can specify specific files to upload, the line above pushes everything in dist directory.
|
|
42
|
+
A readthedocs for this library can be found [here](https://david-andrew-gutman-dsa-helpers.readthedocs-hosted.com/en/latest/index.html).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Digital Slide Archive (DSA) Helpers
|
|
2
|
+
Digital Slide Archive Python utility library.
|
|
3
|
+
|
|
4
|
+
This library is available for installation through [Python Package Index (PyPI)](https://pypi.org/).
|
|
5
|
+
|
|
6
|
+
This library was tested using Python version 3.11.8 and uses the dependencies described in requirements.txt.
|
|
7
|
+
|
|
8
|
+
This Python PyPI package is found [here](https://pypi.org/project/dsa-helpers/).
|
|
9
|
+
|
|
10
|
+
## Extra dependencies
|
|
11
|
+
If you are getting a large image error, then install large image using the instructions provided in their [GitHub page](https://github.com/girder/large_image#:~:text=pip%20install%20large%2Dimage%5Ball%5D%20%2D%2Dfind%2Dlinks%20https%3A//girder.github.io/large_image_wheels).
|
|
12
|
+
|
|
13
|
+
A readthedocs for this library can be found [here](https://david-andrew-gutman-dsa-helpers.readthedocs-hosted.com/en/latest/index.html).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__all__ = []
|
|
@@ -11,7 +11,7 @@ import numpy as np
|
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from multiprocessing import Pool
|
|
13
13
|
from tqdm import tqdm
|
|
14
|
-
from . import imwrite
|
|
14
|
+
from . import imwrite, imread
|
|
15
15
|
import pandas as pd
|
|
16
16
|
|
|
17
17
|
|
|
@@ -338,3 +338,99 @@ def tile_image(
|
|
|
338
338
|
df_data.append([save_fp, x, y, tile_size])
|
|
339
339
|
|
|
340
340
|
return pd.DataFrame(df_data, columns=["fp", "x", "y", "tile_size"])
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def tile_image_with_mask(
|
|
344
|
+
img: np.ndarray | str,
|
|
345
|
+
mask: np.ndarray | str,
|
|
346
|
+
save_dir: str,
|
|
347
|
+
tile_size: int,
|
|
348
|
+
stride: int | None = None,
|
|
349
|
+
fill: tuple[int, int, int] = (255, 255, 255),
|
|
350
|
+
mask_pad_value: int = 0,
|
|
351
|
+
prepend_name: str = "",
|
|
352
|
+
) -> pd.DataFrame:
|
|
353
|
+
"""Tile an image and its corresponding mask.
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
img (np.ndarray): The image or filepath to tile.
|
|
357
|
+
mask (np.ndarray): The mask or filepath to mask.
|
|
358
|
+
save_dir (str): The directory to save the tiles. Images are
|
|
359
|
+
saved in a "images" subdirectory and masks in a "masks"
|
|
360
|
+
subdirectory.
|
|
361
|
+
tile_size (int): The size of the tiles.
|
|
362
|
+
stride (int, optional): The stride of the tiles. Defaults to
|
|
363
|
+
None which sets the stride to the tile size
|
|
364
|
+
(no overlap between tiles).
|
|
365
|
+
fill (tuple[int, int, int], optional): The fill value for the
|
|
366
|
+
tiles that go over the edge of image. Defaults to (255,
|
|
367
|
+
255, 255).
|
|
368
|
+
mask_pad_value (int, optional): The value to pad the mask with.
|
|
369
|
+
Defaults to 0.
|
|
370
|
+
prepend_name (str, optional): A string to prepend to the tile
|
|
371
|
+
filenames. Default to "". Naming of tiles is:
|
|
372
|
+
{prepend_name}x{x}y{y}.png.
|
|
373
|
+
|
|
374
|
+
Returns:
|
|
375
|
+
pandas.DataFrame: A pandas dataframe containing the filepath of
|
|
376
|
+
the image and mask and x, y coordinate.
|
|
377
|
+
|
|
378
|
+
"""
|
|
379
|
+
if isinstance(img, str):
|
|
380
|
+
img = imread(img)
|
|
381
|
+
|
|
382
|
+
if isinstance(mask, str):
|
|
383
|
+
mask = imread(mask, grayscale=True)
|
|
384
|
+
|
|
385
|
+
h, w = img.shape[:2]
|
|
386
|
+
|
|
387
|
+
# Pad the mask to avoid tiles going over the image boundary.
|
|
388
|
+
mask = cv.copyMakeBorder(
|
|
389
|
+
mask.copy(),
|
|
390
|
+
0,
|
|
391
|
+
h + tile_size,
|
|
392
|
+
0,
|
|
393
|
+
w + tile_size,
|
|
394
|
+
cv.BORDER_CONSTANT,
|
|
395
|
+
value=mask_pad_value,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
# Same for the image.
|
|
399
|
+
img = cv.copyMakeBorder(
|
|
400
|
+
img.copy(),
|
|
401
|
+
0,
|
|
402
|
+
h + tile_size,
|
|
403
|
+
0,
|
|
404
|
+
w + tile_size,
|
|
405
|
+
cv.BORDER_CONSTANT,
|
|
406
|
+
value=fill,
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
# Make subdirectories to save images to.
|
|
410
|
+
img_dir = Path(save_dir).joinpath("images")
|
|
411
|
+
mask_dir = Path(save_dir).joinpath("masks")
|
|
412
|
+
img_dir.mkdir(parents=True, exist_ok=True)
|
|
413
|
+
mask_dir.mkdir(exist_ok=True)
|
|
414
|
+
|
|
415
|
+
if stride is None:
|
|
416
|
+
stride = tile_size
|
|
417
|
+
|
|
418
|
+
xys = [(x, y) for x in range(0, w, stride) for y in range(0, h, stride)]
|
|
419
|
+
|
|
420
|
+
tile_data = []
|
|
421
|
+
|
|
422
|
+
for xy in xys:
|
|
423
|
+
x, y = xy
|
|
424
|
+
|
|
425
|
+
tile_img = img[y : y + tile_size, x : x + tile_size]
|
|
426
|
+
tile_img_fp = img_dir / f"{prepend_name}x{x}y{y}.png"
|
|
427
|
+
|
|
428
|
+
tile_mask = mask[y : y + tile_size, x : x + tile_size]
|
|
429
|
+
tile_mask_fp = mask_dir / f"{prepend_name}x{x}y{y}.png"
|
|
430
|
+
|
|
431
|
+
imwrite(tile_img_fp, tile_img)
|
|
432
|
+
imwrite(tile_mask_fp, tile_mask, grayscale=True)
|
|
433
|
+
|
|
434
|
+
tile_data.append([str(tile_img_fp), str(tile_mask_fp), x, y])
|
|
435
|
+
|
|
436
|
+
return pd.DataFrame(tile_data, columns=["fp", "mask_fp", "x", "y"])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: dsa_helpers
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
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>
|
|
@@ -39,15 +39,4 @@ This Python PyPI package is found [here](https://pypi.org/project/dsa-helpers/).
|
|
|
39
39
|
## Extra dependencies
|
|
40
40
|
If you are getting a large image error, then install large image using the instructions provided in their [GitHub page](https://github.com/girder/large_image#:~:text=pip%20install%20large%2Dimage%5Ball%5D%20%2D%2Dfind%2Dlinks%20https%3A//girder.github.io/large_image_wheels).
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
1. Install requirements for building and distributing package:
|
|
44
|
-
```
|
|
45
|
-
$ python3 -m pip install --upgrade build # for building package
|
|
46
|
-
$ python3 -m pip install --upgrade twine # for uploading to PyPI
|
|
47
|
-
```
|
|
48
|
-
2. When ready to build:
|
|
49
|
-
- Modify "pyproject.toml" file, change the "version" key to a different value than a version already pushed.
|
|
50
|
-
- Run ```$ python3 -m build```. This will create a dist directory and put your new wheel and tar distribution files there.
|
|
51
|
-
3. To install locally for development: ```$ pip3 install dist/dsa_helpers-*.whl```, choosing the wheel version you want to test.
|
|
52
|
-
4. Upload to PyPI using twine: ```python3 -m twine upload --repository pypi dist/*```
|
|
53
|
-
* You can specify specific files to upload, the line above pushes everything in dist directory.
|
|
42
|
+
A readthedocs for this library can be found [here](https://david-andrew-gutman-dsa-helpers.readthedocs-hosted.com/en/latest/index.html).
|
dsa_helpers-1.0.2.dev0/README.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Digital Slide Archive (DSA) Helpers
|
|
2
|
-
Digital Slide Archive Python utility library.
|
|
3
|
-
|
|
4
|
-
This library is available for installation through [Python Package Index (PyPI)](https://pypi.org/).
|
|
5
|
-
|
|
6
|
-
This library was tested using Python version 3.11.8 and uses the dependencies described in requirements.txt.
|
|
7
|
-
|
|
8
|
-
This Python PyPI package is found [here](https://pypi.org/project/dsa-helpers/).
|
|
9
|
-
|
|
10
|
-
## Extra dependencies
|
|
11
|
-
If you are getting a large image error, then install large image using the instructions provided in their [GitHub page](https://github.com/girder/large_image#:~:text=pip%20install%20large%2Dimage%5Ball%5D%20%2D%2Dfind%2Dlinks%20https%3A//girder.github.io/large_image_wheels).
|
|
12
|
-
|
|
13
|
-
## Instructions for Development
|
|
14
|
-
1. Install requirements for building and distributing package:
|
|
15
|
-
```
|
|
16
|
-
$ python3 -m pip install --upgrade build # for building package
|
|
17
|
-
$ python3 -m pip install --upgrade twine # for uploading to PyPI
|
|
18
|
-
```
|
|
19
|
-
2. When ready to build:
|
|
20
|
-
- Modify "pyproject.toml" file, change the "version" key to a different value than a version already pushed.
|
|
21
|
-
- Run ```$ python3 -m build```. This will create a dist directory and put your new wheel and tar distribution files there.
|
|
22
|
-
3. To install locally for development: ```$ pip3 install dist/dsa_helpers-*.whl```, choosing the wheel version you want to test.
|
|
23
|
-
4. Upload to PyPI using twine: ```python3 -m twine upload --repository pypi dist/*```
|
|
24
|
-
* You can specify specific files to upload, the line above pushes everything in dist directory.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Shadow imports.
|
|
2
|
-
from .imread import imread
|
|
3
|
-
from .imwrite import imwrite
|
|
4
|
-
|
|
5
|
-
# Make modules available.
|
|
6
|
-
from . import girder_utils
|
|
7
|
-
from . import dash
|
|
8
|
-
from . import ml
|
|
9
|
-
from . import mongo_utils
|
|
10
|
-
from . import tiling
|
|
11
|
-
from . import utils
|
|
12
|
-
from . import tile_utils
|
|
13
|
-
|
|
14
|
-
# Modules that should be available.
|
|
15
|
-
__all__ = [
|
|
16
|
-
"girder_utils",
|
|
17
|
-
"dash",
|
|
18
|
-
"ml",
|
|
19
|
-
"mongo_utils",
|
|
20
|
-
"tiling",
|
|
21
|
-
"utils",
|
|
22
|
-
"tile_utils",
|
|
23
|
-
]
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Allow modules to be imported.
|
|
2
|
-
from . import (
|
|
3
|
-
object_detection,
|
|
4
|
-
datasets,
|
|
5
|
-
transforms,
|
|
6
|
-
segformer_semantic_segmentation,
|
|
7
|
-
callbacks,
|
|
8
|
-
evaluate,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
# Modules that are imported from * notation.
|
|
12
|
-
__all__ = [
|
|
13
|
-
"object_detection",
|
|
14
|
-
"datasets",
|
|
15
|
-
"metrics",
|
|
16
|
-
"transforms",
|
|
17
|
-
"segformer_semantic_segmentation",
|
|
18
|
-
"callbacks",
|
|
19
|
-
"evaluate",
|
|
20
|
-
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__all__ = ["segformer_transforms"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/datasets/SegFormerSegmentationDataset.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dsa_helpers-1.0.2.dev0 → dsa_helpers-1.0.3}/dsa_helpers/ml/transforms/segformer_transforms.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|