Skip to content

Commit 3179dcb

Browse files
committed
Add sample function
1 parent fcb99a5 commit 3179dcb

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

wsidata/_sample.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from zipfile import ZipFile
2+
3+
from platformdirs import user_cache_path
4+
5+
from wsidata import open_wsi
6+
7+
CACHE_PATH = user_cache_path("wsidata", ensure_exists=True)
8+
9+
10+
def sample():
11+
# Download the sample data
12+
from urllib.request import urlretrieve
13+
14+
root = "https://github.com/rendeirolab/wsidata/blob/main/tests/data"
15+
16+
svs_url = f"{root}/sample.svs?raw=true"
17+
zarr_url = f"{root}/sample.zarr.zip?raw=true"
18+
19+
urlretrieve(svs_url, CACHE_PATH / "sample.svs")
20+
urlretrieve(zarr_url, CACHE_PATH / "sample.zarr.zip")
21+
22+
with ZipFile(CACHE_PATH / "sample.zarr.zip", "r") as zip_ref:
23+
zip_ref.extractall(CACHE_PATH / "sample.zarr")
24+
25+
return open_wsi(CACHE_PATH / "sample.svs", store=str(CACHE_PATH / "sample.zarr"))

0 commit comments

Comments
 (0)