Skip to content

Commit daed9d8

Browse files
committed
Update
1 parent ed7f2b2 commit daed9d8

File tree

6 files changed

+82
-45
lines changed

6 files changed

+82
-45
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
enable-cache: true
3636
cache-dependency-glob: "uv.lock"
3737
- name: Install project
38-
run: uv sync --all-extras --dev
38+
run: uv sync --dev
3939
- name: Tests
4040
run: uv run task test
4141

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ instance/
6969
.scrapy
7070

7171
# Sphinx documentation
72-
docs/_build/
72+
docs/build/
73+
docs/.jupyter_cache/
74+
docs/jupyter_execute
7375

7476
# PyBuilder
7577
.pybuilder/
@@ -169,3 +171,4 @@ work/
169171
# pixi environments
170172
.pixi
171173
*.egg-info
174+

pyproject.toml

+26-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "wsidata"
7-
authors = []
7+
description = "Data structures and I/O functions for whole-slide images (WSIs)."
88
readme = "README.md"
9+
requires-python = ">=3.10"
10+
license = "MIT"
11+
authors = [
12+
{name = "Yimin Zheng", email = "yzheng@cemm.at"},
13+
{name = "Ernesto Abila", email = "eabila@cemm.at"},
14+
{name = "André F. Rendeiro", email = "arendeiro@cemm.at"},
15+
]
16+
keywords = ["histopathology", "whole slide image", "image analysis", "data structure"]
917
classifiers = [
18+
"Development Status :: 3 - Alpha",
19+
"Intended Audience :: Science/Research",
1020
"License :: OSI Approved :: MIT License",
21+
"Natural Language :: English",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python :: 3",
24+
"Topic :: File Formats",
25+
"Topic :: Scientific/Engineering :: Bio-Informatics",
1126
]
12-
requires-python = ">=3.10"
13-
dynamic = ["version", "description"]
14-
27+
Documentation = "https://wsidata.readthedocs.io"
28+
repository = "https://github.com/rendeirolab/wsidata"
29+
dynamic = ["version"]
1530
dependencies = [
1631
"spatialdata>=0.3.0",
1732
"opencv-python-headless",
@@ -20,7 +35,7 @@ dependencies = [
2035
"tiffslide",
2136
"rich",
2237
"numba>=0.61.0",
23-
"torch>=2.6.0",
38+
"torch>=2.0.0",
2439
]
2540

2641
[project.optional-dependencies]
@@ -50,6 +65,9 @@ include = [
5065
"wsidata",
5166
]
5267

68+
[tool.hatch.build.targets.wheel]
69+
packages = ["wsidata", "README.md", "LICENSE", "pyproject.toml"]
70+
5371
[tool.ruff]
5472
lint.ignore = ["F401"]
5573
line-length = 88
@@ -58,7 +76,8 @@ line-length = 88
5876
hello = "echo Hello, World!"
5977
test = "pytest tests"
6078
doc-build = "sphinx-build -b html docs/source docs/build"
61-
doc-serve = "python -m http.server -d docs/build/html"
79+
doc-clean-build = "python docs/clean_up.py && sphinx-build -b html docs/source docs/build"
80+
doc-serve = "python -m http.server -d docs/build"
6281
fmt = "ruff format docs/source wsidata tests"
6382

6483
[tool.uv]
@@ -82,4 +101,5 @@ dev = [
82101
"torchstain>=1.4.1",
83102
"matplotlib>=3.10.0",
84103
"legendkit>=0.3.4",
104+
"pyright>=1.1.393",
85105
]

uv.lock

+25-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wsidata/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
IterAccessor,
1212
DatasetAccessor,
1313
)
14-
from .reader import get_reader
14+
from .reader import get_reader, SlideProperties

wsidata/io/_wsi.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from __future__ import annotations
2+
13
from concurrent.futures import ThreadPoolExecutor
24
from pathlib import Path
5+
from typing import Literal
36

47
import numpy as np
8+
import pandas as pd
59
from anndata import AnnData
610
from rich.progress import track
711
from spatialdata import read_zarr, SpatialData
@@ -13,25 +17,24 @@
1317

1418

1519
def open_wsi(
16-
wsi,
17-
store=None,
18-
reader=None,
19-
attach_images=False,
20-
image_key="wsi",
21-
save_images=False,
22-
attach_thumbnail=True,
23-
thumbnail_key="wsi_thumbnail",
24-
thumbnail_size=2000,
25-
save_thumbnail=True,
20+
wsi: str | Path,
21+
store: str = None,
22+
reader: Literal["openslide", "tiffslide", "bioformats"] = None,
23+
attach_images: bool = False,
24+
image_key: str = "wsi",
25+
save_images: bool = False,
26+
attach_thumbnail: bool = True,
27+
thumbnail_key: str = "wsi_thumbnail",
28+
thumbnail_size: int = 2000,
29+
save_thumbnail: bool = True,
2630
**kwargs,
2731
):
2832
"""Open a whole slide image.
2933
30-
You can open a whole slide image from a URL or a local file.
31-
If load from remote URL, the image will be downloaded and cached (default to current the working directory).
32-
You can also attach images and thumbnail to the SpatialData object. By default, only the thumbnail is attached,
33-
the thumbnail is a downsampled version of the whole slide image, the original image is not attached to save disk space
34-
when you save the WSIData object on disk.
34+
You can attach images and thumbnail to the SpatialData object. By default, only the thumbnail is attached,
35+
the thumbnail is a downsampled version of the whole slide image,
36+
the original image is not attached as it will make unnecessary copies of the data on disk
37+
when saving the SpatialData object.
3538
3639
Parameters
3740
----------
@@ -45,8 +48,6 @@ def open_wsi(
4548
This is useful when you want to store all zarr files in a specific location.
4649
reader : str, optional
4750
Reader to use, by default "auto", choosing available reader, first openslide, then tifffile.
48-
name : str, optional
49-
The name of the slide.
5051
attach_images : bool, optional, default: False
5152
Whether to attach whole slide image to image slot in the spatial data object.
5253
image_key : str, optional
@@ -147,13 +148,13 @@ def open_wsi(
147148

148149

149150
def agg_wsi(
150-
slides_table,
151-
feature_key,
152-
tile_key="tiles",
153-
agg_key="agg",
154-
wsi_col=None,
155-
store_col=None,
156-
error="raise",
151+
slides_table: pd.DataFrame,
152+
feature_key: str,
153+
tile_key: str = "tiles",
154+
agg_key: str = "agg",
155+
wsi_col: str = None,
156+
store_col: str = None,
157+
error: Literal["raise", "skip"] = "raise",
157158
):
158159
"""
159160
Aggregate feature from a whole slide image.
@@ -212,7 +213,6 @@ def agg_wsi(
212213
mask = np.asarray([r is not None for r in results])
213214
X = np.vstack(np.asarray(results, dtype=object)[mask])
214215
slides_table = slides_table[mask]
215-
216216
else:
217217
X = np.vstack(results)
218218

0 commit comments

Comments
 (0)