lavlab-shell 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.
- lavlab_shell-0.1.0.dist-info/METADATA +264 -0
- lavlab_shell-0.1.0.dist-info/RECORD +16 -0
- lavlab_shell-0.1.0.dist-info/WHEEL +4 -0
- lavlab_shell-0.1.0.dist-info/entry_points.txt +3 -0
- lavlab_shell-0.1.0.dist-info/licenses/LICENSE.txt +21 -0
- shell/__about__.py +6 -0
- shell/__init__.py +14 -0
- shell/benchmark.py +634 -0
- shell/cli.py +323 -0
- shell/infer_omero_wsi.py +1664 -0
- shell/infer_wsi.py +150 -0
- shell/inference.py +126 -0
- shell/model.py +160 -0
- shell/preprocessing.py +337 -0
- shell/py.typed +0 -0
- shell/weights/model_v1.pth +0 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lavlab-shell
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SHELL Highlights Epithelium and Lumen Locations — whole-slide H&E segmentation
|
|
5
|
+
Project-URL: Documentation, https://github.com/laviolette-lab/shell#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/laviolette-lab/shell/issues
|
|
7
|
+
Project-URL: Source, https://github.com/laviolette-lab/shell
|
|
8
|
+
Author-email: barrettMCW <mjbarrett@mcw.edu>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: H&E,deep-learning,histopathology,segmentation,whole-slide-image
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Requires-Python: <3.13,>=3.10
|
|
19
|
+
Requires-Dist: macenko-pca
|
|
20
|
+
Requires-Dist: monai
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: openslide-python
|
|
23
|
+
Requires-Dist: pyvips
|
|
24
|
+
Requires-Dist: scipy
|
|
25
|
+
Requires-Dist: torch
|
|
26
|
+
Provides-Extra: omero
|
|
27
|
+
Requires-Dist: omero-py; extra == 'omero'
|
|
28
|
+
Requires-Dist: zeroc-ice; extra == 'omero'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# SHELL — SHELL Highlights Epithelium and Lumen Locations
|
|
32
|
+
|
|
33
|
+
[](https://github.com/laviolette-lab/shell/actions/workflows/build.yml)
|
|
34
|
+
[](https://github.com/laviolette-lab/shell/actions/workflows/pytest.yml)
|
|
35
|
+
[](https://github.com/laviolette-lab/shell/actions/workflows/lint.yml)
|
|
36
|
+
[](https://pypi.org/project/lavlab-shell)
|
|
37
|
+
[](https://pypi.org/project/lavlab-shell)
|
|
38
|
+
|
|
39
|
+
-----
|
|
40
|
+
|
|
41
|
+
A whole-slide image segmentation pipeline for H&E-stained histopathology.
|
|
42
|
+
SHELL uses Macenko colour deconvolution and a SegResNetVAE to segment
|
|
43
|
+
epithelium and lumen/stroma regions.
|
|
44
|
+
|
|
45
|
+
Model weights are **bundled with the package** — no separate download required.
|
|
46
|
+
|
|
47
|
+
## Label Map
|
|
48
|
+
|
|
49
|
+
| Value | Label |
|
|
50
|
+
|-------|-------|
|
|
51
|
+
| 0 | Background / White |
|
|
52
|
+
| 1 | Epithelium |
|
|
53
|
+
| 2 | Stroma |
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
### Installation
|
|
58
|
+
|
|
59
|
+
```console
|
|
60
|
+
pip install shell
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **Python 3.10 – 3.12** is required (constrained by the OMERO dependency).
|
|
64
|
+
|
|
65
|
+
To use OMERO support (fetching images from an OMERO server):
|
|
66
|
+
|
|
67
|
+
```console
|
|
68
|
+
pip install shell[omero]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### CLI — Local WSI Inference
|
|
72
|
+
|
|
73
|
+
The bundled model is used automatically — no `--model-path` needed:
|
|
74
|
+
|
|
75
|
+
```console
|
|
76
|
+
shell infer --input slide.tiff --output prediction.tiff
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
To use a specific bundled model version:
|
|
80
|
+
|
|
81
|
+
```console
|
|
82
|
+
shell infer --input slide.tiff --output prediction.tiff --model-version v1
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
To use your own weights instead:
|
|
86
|
+
|
|
87
|
+
```console
|
|
88
|
+
shell infer --input slide.tiff --output prediction.tiff --model-path /path/to/custom.pth
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### CLI — OMERO Inference
|
|
92
|
+
|
|
93
|
+
```console
|
|
94
|
+
shell infer-omero \
|
|
95
|
+
--host $OMERO_SERVER --port $OMERO_PORT \
|
|
96
|
+
--username $OMERO_USERNAME --password $OMERO_PASSWORD \
|
|
97
|
+
--image-id 12345 \
|
|
98
|
+
--output pred_12345.tiff
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### As a Library
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from shell.infer_wsi import infer_wsi
|
|
105
|
+
|
|
106
|
+
# Uses the bundled latest model automatically
|
|
107
|
+
label_map = infer_wsi(
|
|
108
|
+
input_path="slide.tiff",
|
|
109
|
+
output_path="prediction.tiff",
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
You can also load the model directly:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from shell.model import build_model
|
|
117
|
+
|
|
118
|
+
# Bundled latest
|
|
119
|
+
model = build_model(device="cuda")
|
|
120
|
+
|
|
121
|
+
# Specific bundled version
|
|
122
|
+
model = build_model(model_version="v1", device="cuda")
|
|
123
|
+
|
|
124
|
+
# Custom weights file
|
|
125
|
+
model = build_model("/path/to/custom.pth", device="cuda")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Model Versioning
|
|
129
|
+
|
|
130
|
+
Model weights live in `src/shell/weights/` and are registered in
|
|
131
|
+
`shell.model.MODEL_REGISTRY`. The `LATEST_MODEL` constant controls which
|
|
132
|
+
version is loaded by default.
|
|
133
|
+
|
|
134
|
+
| Version | File | Notes |
|
|
135
|
+
|---------|------|-------|
|
|
136
|
+
| `v1` | `model_v1.pth` | Initial release — SegResNetVAE trained on H&E |
|
|
137
|
+
|
|
138
|
+
### Adding a New Model
|
|
139
|
+
|
|
140
|
+
1. Place the new `.pth` file in `src/shell/weights/`.
|
|
141
|
+
2. Add an entry to `MODEL_REGISTRY` in `src/shell/model.py`:
|
|
142
|
+
```python
|
|
143
|
+
MODEL_REGISTRY: dict[str, str] = {
|
|
144
|
+
"v1": "model_v1.pth",
|
|
145
|
+
"v2": "model_v2.pth", # new
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
3. Update `LATEST_MODEL`:
|
|
149
|
+
```python
|
|
150
|
+
LATEST_MODEL: str = "v2"
|
|
151
|
+
```
|
|
152
|
+
4. Bump the package version and release.
|
|
153
|
+
|
|
154
|
+
## Development Setup
|
|
155
|
+
|
|
156
|
+
**Prerequisites:** Python 3.10–3.12 and [Hatch](https://hatch.pypa.io/latest/install/).
|
|
157
|
+
|
|
158
|
+
```console
|
|
159
|
+
git clone https://github.com/laviolette-lab/shell.git
|
|
160
|
+
cd shell
|
|
161
|
+
pip install hatch
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Optionally install pre-commit hooks:
|
|
165
|
+
|
|
166
|
+
```console
|
|
167
|
+
pip install pre-commit
|
|
168
|
+
pre-commit install
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Common Commands
|
|
172
|
+
|
|
173
|
+
| Task | Command |
|
|
174
|
+
|------|---------|
|
|
175
|
+
| Run tests | `hatch run test:test` |
|
|
176
|
+
| Tests + coverage | `hatch run test:cov` |
|
|
177
|
+
| Lint | `hatch run lint:check` |
|
|
178
|
+
| Format | `hatch run lint:format` |
|
|
179
|
+
| Auto-fix lint | `hatch run lint:fix` |
|
|
180
|
+
| Format + fix + lint | `hatch run lint:all` |
|
|
181
|
+
| Type check | `hatch run types:check` |
|
|
182
|
+
| Build docs | `hatch run docs:build-docs` |
|
|
183
|
+
| Serve docs | `hatch run docs:serve-docs` |
|
|
184
|
+
| Build wheel | `hatch build` |
|
|
185
|
+
| Clean artifacts | `make clean` |
|
|
186
|
+
|
|
187
|
+
## Publishing
|
|
188
|
+
|
|
189
|
+
Releases are fully automated. Creating a GitHub Release triggers the
|
|
190
|
+
`publish.yml` workflow, which:
|
|
191
|
+
|
|
192
|
+
1. Builds a wheel and sdist and publishes them to **PyPI** via trusted
|
|
193
|
+
publishing (OIDC — no API tokens needed).
|
|
194
|
+
2. Builds **standalone binaries** for Linux (x86_64) and macOS (x86_64 +
|
|
195
|
+
arm64) using [Nuitka](https://nuitka.net/) with Python 3.12.
|
|
196
|
+
3. Uploads the binaries as **release assets** on the GitHub Release.
|
|
197
|
+
|
|
198
|
+
### How to Release
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# 1. Bump the version in src/shell/__about__.py
|
|
202
|
+
# 2. Commit and tag
|
|
203
|
+
git add -A
|
|
204
|
+
git commit -m "release: v0.2.0"
|
|
205
|
+
git tag v0.2.0
|
|
206
|
+
git push && git push --tags
|
|
207
|
+
|
|
208
|
+
# 3. Create a GitHub Release from the tag
|
|
209
|
+
gh release create v0.2.0 --generate-notes
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### One-Time Setup (PyPI)
|
|
213
|
+
|
|
214
|
+
1. Go to <https://pypi.org/manage/account/publishing/>.
|
|
215
|
+
2. Add a pending publisher:
|
|
216
|
+
- **PyPI project name:** `shell`
|
|
217
|
+
- **Owner:** `laviolette-lab`
|
|
218
|
+
- **Repository:** `shell`
|
|
219
|
+
- **Workflow name:** `publish.yml`
|
|
220
|
+
- **Environment name:** `pypi`
|
|
221
|
+
|
|
222
|
+
### One-Time Setup (GitHub)
|
|
223
|
+
|
|
224
|
+
1. In repository **Settings → Environments**, create an environment named
|
|
225
|
+
**`pypi`** (optionally with manual approval protection).
|
|
226
|
+
|
|
227
|
+
## Project Structure
|
|
228
|
+
|
|
229
|
+
```text
|
|
230
|
+
shell/
|
|
231
|
+
├── src/
|
|
232
|
+
│ └── shell/ # Package source
|
|
233
|
+
│ ├── __init__.py # Public API & version export
|
|
234
|
+
│ ├── __about__.py # Version string
|
|
235
|
+
│ ├── cli.py # CLI entry point
|
|
236
|
+
│ ├── model.py # SegResNetVAE model helpers & registry
|
|
237
|
+
│ ├── preprocessing.py # Macenko deconvolution & EHO transform
|
|
238
|
+
│ ├── inference.py # Sliding-window inference
|
|
239
|
+
│ ├── infer_wsi.py # Local WSI pipeline
|
|
240
|
+
│ ├── infer_omero_wsi.py # OMERO WSI pipeline (tiled, pipelined)
|
|
241
|
+
│ ├── weights/ # Bundled model weight files
|
|
242
|
+
│ │ └── model_v1.pth
|
|
243
|
+
│ └── py.typed # PEP 561 marker
|
|
244
|
+
├── tests/ # pytest test suite
|
|
245
|
+
├── docs/ # MkDocs source files
|
|
246
|
+
├── .github/
|
|
247
|
+
│ └── workflows/
|
|
248
|
+
│ ├── build.yml # CI: build wheel on push/PR
|
|
249
|
+
│ ├── pytest.yml # CI: run tests
|
|
250
|
+
│ ├── lint.yml # CI: ruff lint + format check
|
|
251
|
+
│ └── publish.yml # CD: PyPI publish + Nuitka binaries
|
|
252
|
+
├── pyproject.toml # All project & tool configuration
|
|
253
|
+
├── Dockerfile # Multi-stage build (hatch / dev / prod)
|
|
254
|
+
├── Makefile # Dev shortcuts
|
|
255
|
+
└── README.md
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Contributing
|
|
259
|
+
|
|
260
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
`shell` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
shell/__about__.py,sha256=n29Swst-tL4nfeKmSrjWNKW_vV_Kcurd8u_KKexRpQA,163
|
|
2
|
+
shell/__init__.py,sha256=wrtI_LagEdmE_4R6tDwS9Mk8AzKK8NoHZkT9HhJQjl8,504
|
|
3
|
+
shell/benchmark.py,sha256=SJfTEBi2GzI8aAOzH-6Bj6EBXhWY1SP32dDlbVDgXG8,21994
|
|
4
|
+
shell/cli.py,sha256=2JI2bMZoqK6rLDP2Qe-lF0SB6FmGR6bhOz8TDcNeH8g,9812
|
|
5
|
+
shell/infer_omero_wsi.py,sha256=IZ69rcpcezNJ9kLQrCyugJ4JM1kymsPRDzGVknoyLY0,52614
|
|
6
|
+
shell/infer_wsi.py,sha256=a34Tplq4Bb2xiPoRV8E7qfqJb_ef82h91MizJJNfIno,4812
|
|
7
|
+
shell/inference.py,sha256=o6kSzJ8L-qIkDRiYtNHAeUO9D0OCQ3K8v6CU1A7x-gg,4139
|
|
8
|
+
shell/model.py,sha256=wal_xPLcyMYV3MLbwrqIXEEKrMoW64CwG05XDzwfYYc,5742
|
|
9
|
+
shell/preprocessing.py,sha256=HNkBLHAp5ea5_Y8YeUL75yfP9jSzdL5L3mCWXAcSP38,11051
|
|
10
|
+
shell/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
shell/weights/model_v1.pth,sha256=G48itNrQSJtMjaCB6AK8ko34LaTVe7tpiujC668lcCU,34782896
|
|
12
|
+
lavlab_shell-0.1.0.dist-info/METADATA,sha256=m4M0fOJfAf1OW2QLWFsw3VksZHrhOvHySzSUOT2zUcg,8141
|
|
13
|
+
lavlab_shell-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
14
|
+
lavlab_shell-0.1.0.dist-info/entry_points.txt,sha256=P1hg5cvlt0UiFr5tsJAaImiG1lNn1QnRvqQnXTyk89o,71
|
|
15
|
+
lavlab_shell-0.1.0.dist-info/licenses/LICENSE.txt,sha256=2BgeVyUFxFsqToAU-Zo__T90HDKwl7v55Muioy23OwA,1075
|
|
16
|
+
lavlab_shell-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present barrettMCW
|
|
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.
|
shell/__about__.py
ADDED
shell/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024-present barrettMCW <mjbarrett@mcw.edu>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""SHELL — SHELL Highlights Epithelium and Lumen Locations.
|
|
5
|
+
|
|
6
|
+
This module intentionally keeps the top-level package import lightweight.
|
|
7
|
+
Only the package version is exported here so importing ``shell`` in tests
|
|
8
|
+
or simple checks does not eagerly import heavy runtime dependencies
|
|
9
|
+
(like ``torch``, ``monai``, ``pyvips``, or ``omero``).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .__about__ import __version__
|
|
13
|
+
|
|
14
|
+
__all__ = ["__version__"]
|