wsi-toolbox 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: wsi-toolbox
3
+ Version: 0.1.0
4
+ Summary: A comprehensive toolkit for Whole Slide Image processing, feature extraction, and clustering analysis
5
+ Project-URL: Homepage, https://github.com/endaaman/wsi-toolbox
6
+ Project-URL: Repository, https://github.com/endaaman/wsi-toolbox
7
+ Project-URL: Documentation, https://github.com/endaaman/wsi-toolbox/blob/master/README.md
8
+ Author-email: Ken Enda <ken@endaaman.com>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2025 Ken Enda
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: clustering,deep-learning,histopathology,pathology,wsi
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
37
+ Requires-Python: >=3.11
38
+ Requires-Dist: h5py>=3.13.0
39
+ Requires-Dist: hdbscan>=0.8.40
40
+ Requires-Dist: imagecodecs>=2024.12.30
41
+ Requires-Dist: joblib>=1.4.2
42
+ Requires-Dist: leidenalg>=0.10.2
43
+ Requires-Dist: matplotlib>=3.9.4
44
+ Requires-Dist: networkx>=3.3
45
+ Requires-Dist: numpy<2
46
+ Requires-Dist: opencv-python-headless>=4.11.0.86
47
+ Requires-Dist: openpyxl>=3.1.5
48
+ Requires-Dist: openslide-python>=1.4.1
49
+ Requires-Dist: pandas>=2.2.3
50
+ Requires-Dist: pillow>=11.0.0
51
+ Requires-Dist: pydantic-autocli>=0.1.4
52
+ Requires-Dist: pydantic>=2.10.6
53
+ Requires-Dist: pyqt6>=6.8.1
54
+ Requires-Dist: python-igraph>=0.11.8
55
+ Requires-Dist: rich>=14.0.0
56
+ Requires-Dist: scikit-learn>=1.6.1
57
+ Requires-Dist: seaborn>=0.13.2
58
+ Requires-Dist: streamlit-aggrid>=0.3.4.post3
59
+ Requires-Dist: streamlit-antd-components>=0.3.2
60
+ Requires-Dist: streamlit>=1.43.2
61
+ Requires-Dist: taskipy>=1.14.1
62
+ Requires-Dist: tifffile>=2025.2.18
63
+ Requires-Dist: timm>=0.9.16
64
+ Requires-Dist: torch>=2.5.1
65
+ Requires-Dist: torchvision>=0.20.1
66
+ Requires-Dist: umap-learn>=0.5.7
67
+ Requires-Dist: zarr>=3
68
+ Provides-Extra: build
69
+ Requires-Dist: packaging; extra == 'build'
70
+ Requires-Dist: setuptools; extra == 'build'
71
+ Requires-Dist: torch; extra == 'build'
72
+ Requires-Dist: wheel; extra == 'build'
73
+ Provides-Extra: compile
74
+ Requires-Dist: flash-attn; extra == 'compile'
75
+ Description-Content-Type: text/markdown
76
+
77
+ # WSI Toolbox
78
+
79
+ A comprehensive toolkit for Whole Slide Image (WSI) processing, feature extraction, and clustering analysis.
80
+
81
+ ## Installation
82
+
83
+ ### From PyPI
84
+
85
+ ```bash
86
+ pip install wsi-toolbox
87
+ ```
88
+
89
+ ### For development
90
+
91
+ ```bash
92
+ # Clone repository
93
+ git clone https://github.com/endaaman/WSI-toolbox.git
94
+ cd WSI-toolbox
95
+
96
+ # Install dependencies
97
+ uv sync
98
+ ```
99
+
100
+ **Note**: For gigapath slide-level encoder (CLI only), install manually:
101
+ ```bash
102
+ pip install git+https://github.com/prov-gigapath/prov-gigapath.git@5d77be0
103
+ pip install flash-attn einops fairscale
104
+ ```
105
+
106
+ ## Quick Start
107
+
108
+ ### As a Python Library
109
+
110
+ ```python
111
+ import wsi_toolbox as wt
112
+
113
+ # Basic workflow
114
+ wt.set_default_model('uni')
115
+ cmd = wt.Wsi2HDF5Command(patch_size=256)
116
+ result = cmd('input.ndpi', 'output.h5')
117
+ ```
118
+
119
+ **See [README_API.md](README_API.md) for comprehensive API documentation** (detailed examples, command patterns, utilities, etc.)
120
+
121
+ ### As a CLI Tool
122
+
123
+ ```bash
124
+ # Convert WSI to HDF5
125
+ wsi-toolbox wsi2h5 --in input.ndpi --out output.h5 --patch-size 256
126
+
127
+ # Extract features
128
+ wsi-toolbox embed --in output.h5 --model uni
129
+
130
+ # Clustering
131
+ wsi-toolbox cluster --in output.h5 --resolution 1.0
132
+
133
+ # For all commands
134
+ wsi-toolbox --help
135
+ ```
136
+
137
+ ### Streamlit Web Application
138
+
139
+ ```bash
140
+ uv run task app
141
+ ```
142
+
143
+ ## HDF5 File Structure
144
+
145
+ WSI-toolbox stores all data in a single HDF5 file:
146
+
147
+ ```python
148
+ # Core data
149
+ 'patches' # Patch images: [N, H, W, 3], e.g., [3237, 256, 256, 3]
150
+ 'coordinates' # Patch pixel coordinates: [N, 2]
151
+
152
+ # Metadata
153
+ 'metadata/original_mpp' # Original microns per pixel
154
+ 'metadata/original_width' # Original image width (level=0)
155
+ 'metadata/original_height' # Original image height (level=0)
156
+ 'metadata/image_level' # Image level used (typically 0)
157
+ 'metadata/mpp' # Output patch MPP
158
+ 'metadata/scale' # Scale factor
159
+ 'metadata/patch_size' # Patch size (e.g., 256)
160
+ 'metadata/patch_count' # Total patch count
161
+ 'metadata/cols' # Grid columns
162
+ 'metadata/rows' # Grid rows
163
+
164
+ # Model features (per model: uni, gigapath, virchow2)
165
+ '{model}/features' # Patch features: [N, D]
166
+ # uni: [N, 1024]
167
+ # gigapath: [N, 1536]
168
+ # virchow2: [N, 2560]
169
+ '{model}/latent_features' # Latent features (optional): [N, K, K, D]
170
+ '{model}/clusters' # Cluster labels: [N]
171
+
172
+ # Gigapath slide-level (CLI only)
173
+ 'gigapath/slide_feature' # Slide-level features: [768]
174
+ ```
175
+
176
+ ## Features
177
+
178
+ - WSI processing (.ndpi, .svs, .tiff → HDF5)
179
+ - Feature extraction (UNI, Gigapath, Virchow2)
180
+ - Leiden clustering with UMAP visualization
181
+ - Preview generation (cluster overlays, latent PCA)
182
+ - Type-safe command pattern with Pydantic results
183
+ - CLI, Python API, and Streamlit GUI
184
+
185
+ ## Documentation
186
+
187
+ - [API Guide](README_API.md) - Comprehensive Python API documentation (日本語)
188
+ - [CLAUDE.md](CLAUDE.md) - Development guidelines
189
+
190
+ ## Development
191
+
192
+ ### Setup Development Environment
193
+
194
+ ```bash
195
+ # Clone repository
196
+ git clone https://github.com/endaaman/wsi-toolbox.git
197
+ cd wsi-toolbox
198
+
199
+ # Install all dependencies
200
+ uv sync
201
+
202
+ # Install with optional gigapath support
203
+ uv sync --extra gigapath
204
+
205
+ # Install build tools
206
+ uv sync --group build
207
+ ```
208
+
209
+ ### Run Tests and Development Tools
210
+
211
+ ```bash
212
+ # Run CLI
213
+ uv run wsi-toolbox --help
214
+
215
+ # Run Streamlit app
216
+ uv run task app
217
+
218
+ # Run watcher
219
+ uv run task watcher
220
+ ```
221
+
222
+ ### Build and Deploy
223
+
224
+ #### Build Package
225
+
226
+ ```bash
227
+ # Clean previous builds
228
+ uv run task clean
229
+
230
+ # Build package
231
+ uv run task build
232
+ # or
233
+ python -m build
234
+
235
+ # Check package integrity
236
+ uv run task check
237
+ # or
238
+ python -m twine check dist/*
239
+ ```
240
+
241
+ #### Deploy to PyPI
242
+
243
+ **Prerequisites**: Install build tools first
244
+ ```bash
245
+ uv sync --group build
246
+ ```
247
+
248
+ **Deploy**:
249
+ ```bash
250
+ # Using deploy script (recommended)
251
+ ./deploy.sh
252
+
253
+ # Or manually
254
+ python -m build
255
+ python -m twine check dist/*
256
+ python -m twine upload dist/*
257
+ ```
258
+
259
+ **Note**: Configure your PyPI credentials before deploying:
260
+ ```bash
261
+ # Create ~/.pypirc with your API token
262
+ # Or use environment variables
263
+ export TWINE_USERNAME=__token__
264
+ export TWINE_PASSWORD=<your-pypi-token>
265
+ ```
266
+
267
+ ## License
268
+
269
+ MIT
@@ -0,0 +1,25 @@
1
+ wsi_toolbox/__init__.py,sha256=nrMIo_dPhRWatvzBLHqy25_LLK8VaIK2-IEhTRIEZXA,2577
2
+ wsi_toolbox/app.py,sha256=7bjjGzsJ6rkorf5S_TmxAm2nyOsF9Py8qR47SYO_U3U,28400
3
+ wsi_toolbox/cli.py,sha256=6klzq0P839EQnhrO83U3bB-U0VmRqUFsKVKu8zmX5MQ,16820
4
+ wsi_toolbox/exp.py,sha256=D-hz_HWQsCHXyGCrlW2-0QWeWEmaNHd2WI1FIYTmfYs,16892
5
+ wsi_toolbox/models.py,sha256=mgy_L0Kx9txfRR7-Wme4UsDNjVq_2D-WiQ60YX6Qa5g,1177
6
+ wsi_toolbox/watcher.py,sha256=Z9g-WJqSlcgGo--idXJP3zipmv_8DcQrQiCEqNS8EAo,10154
7
+ wsi_toolbox/wsi_files.py,sha256=azM3nuH9Lbgugl_oyhkhEn6mq2J6H5ujCqm79R2JKZk,5752
8
+ wsi_toolbox/commands/__init__.py,sha256=A9d8bSU6yR50NLSVoYU7mxzyBoy-VTbJPl8V5NscjVE,2359
9
+ wsi_toolbox/commands/clustering.py,sha256=xp0soeoYqxvT10iA5usA8KAkaaHmxgPmm9mi67ScUcE,7093
10
+ wsi_toolbox/commands/dzi_export.py,sha256=0GheEu5Yy5oFzOJSJRqISsE3wV1zzy6Z_jKHYrHhDNs,7832
11
+ wsi_toolbox/commands/patch_embedding.py,sha256=UlV7i0myfyB4uSFLCCX_WUD1-Mapi0bZq9t8BkPLTgU,7061
12
+ wsi_toolbox/commands/preview.py,sha256=Mk4UtKxTLbBJsIxSb7IeIqrP3kf1Dk9B1sME2iWUrrs,10331
13
+ wsi_toolbox/commands/wsi.py,sha256=Dne6tj793IGatbOQXuz9IVvGPBVcdMR5bHRMdnYzX4c,6546
14
+ wsi_toolbox/utils/__init__.py,sha256=jg8vc1h1f32ucyqabutp0wWZcGW66uy53VSHa-7ofIY,5057
15
+ wsi_toolbox/utils/analysis.py,sha256=MvB4wxuNC0CQVOY8ISa_uCLi1ZfoYm0gRGYTdIpNrbw,4085
16
+ wsi_toolbox/utils/cli.py,sha256=jdkPhLaY9tJbBbI4ANr8I0_VjevA9gWkonRUa2F2mCw,511
17
+ wsi_toolbox/utils/helpers.py,sha256=vFM_t_my8luq49En5AzdQ9FNqDJT-RmgaWRPPTPF9B0,1462
18
+ wsi_toolbox/utils/progress.py,sha256=pKwD3UjIFdyJWyUI8swXDAtwIpaLhJEqX1jCnaaingM,7291
19
+ wsi_toolbox/utils/seed.py,sha256=_rMav-pcp45XsifILgbXy4h6-ADBDsp4ty9Z5cJYe9o,487
20
+ wsi_toolbox/utils/st.py,sha256=_qXxgfkRXclykhx1KYpcGsFQvaMVxVKVntdAxC_FhaQ,2034
21
+ wsi_toolbox-0.1.0.dist-info/METADATA,sha256=l0ClFknHBO6f6BaGCvcDQ5E1FOtS_W_Men3wdEsxRsw,7497
22
+ wsi_toolbox-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ wsi_toolbox-0.1.0.dist-info/entry_points.txt,sha256=6jtGsjHBtNr8KCf3y5SgpyHhDoHuIWoG8bKLlF4G9TM,53
24
+ wsi_toolbox-0.1.0.dist-info/licenses/LICENSE,sha256=YEzz8a8Kd5ZhRNItsiPJYFMfgXN1JDVZ9UG7UzTYvNU,1065
25
+ wsi_toolbox-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ wsi-toolbox = wsi_toolbox.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ken Enda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.