tmapslide 0.2.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,142 @@
1
+ Metadata-Version: 2.5
2
+ Name: tmapslide
3
+ Version: 0.2.0
4
+ Summary: Pure Python UNIC TMAP whole-slide image reader with OpenSlide-compatible API
5
+ Project-URL: Homepage, https://github.com/yifanfeng97/tmapslide
6
+ Project-URL: Documentation, https://github.com/yifanfeng97/tmapslide#readme
7
+ Project-URL: Repository, https://github.com/yifanfeng97/tmapslide
8
+ Project-URL: Issues, https://github.com/yifanfeng97/tmapslide/issues
9
+ Author-email: Yifan Feng <evanfeng97@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: digital-pathology,openslide,pathology,tmap,tmapslide,unic,whole-slide-image,wsi
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
22
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: pillow>=9.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy; extra == 'dev'
27
+ Requires-Dist: pytest-cov; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0; extra == 'dev'
29
+ Requires-Dist: ruff; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # TmapSlide
33
+
34
+ ![tmapslide — TMAP whole-slide images in pure Python](docs/hero.jpg)
35
+
36
+ Pure Python reader for **UNIC TMAP** whole-slide images (WSI) with an
37
+ [OpenSlide](https://openslide.org/)-compatible API — the companion library to
38
+ [kfbslide](https://github.com/yifanfeng97/kfbslide) (KFB format).
39
+
40
+ ```python
41
+ import tmapslide
42
+
43
+ slide = tmapslide.OpenSlide("sample.TMAP")
44
+
45
+ print(slide.dimensions) # (71424, 72704)
46
+ print(slide.level_count) # 10
47
+ print(slide.level_downsamples) # (1.0, 2.0, 4.0, ...)
48
+
49
+ region = slide.read_region((512, 512), 0, (1024, 1024)) # RGBA PIL image
50
+ thumb = slide.get_thumbnail((512, 512))
51
+ macro = slide.associated_images["macro"]
52
+ ```
53
+
54
+ ## Features
55
+
56
+ - **Pure Python** — no vendor SDK, no native dependencies; only Pillow.
57
+ - **OpenSlide-compatible API** — drop-in for code written against
58
+ `openslide`/`kfbslide`: `read_region`, `get_thumbnail`, `dimensions`,
59
+ `level_count`, `level_dimensions`, `level_downsamples`, `properties`,
60
+ `associated_images`.
61
+ - **Both known TMAP variants**: `TMAP06` (single pixel level, 612x512
62
+ overlapping tiles) and `TMAP07` (full pyramid, up to 10 levels, 256x256
63
+ tiles).
64
+ - **Fork-safe file handles** — safe to use from PyTorch `DataLoader` workers.
65
+ - LRU tile cache for fast repeated reads.
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install tmapslide
71
+ # or from source
72
+ pip install git+https://github.com/yifanfeng97/tmapslide.git
73
+ ```
74
+
75
+ ## Supported formats
76
+
77
+ | Format | Extension | Vendor | Backend |
78
+ | ------- | --------- | ------------------ | ----------- |
79
+ | TMAP 06 | `.TMAP` | UNIC (United Imaging) | Pure Python |
80
+ | TMAP 07 | `.TMAP` | UNIC (United Imaging) | Pure Python |
81
+
82
+ ## API
83
+
84
+ ### `tmapslide.OpenSlide(filename)`
85
+
86
+ | Member | Description |
87
+ | --------------------- | -------------------------------------------------- |
88
+ | `dimensions` | `(width, height)` at level 0 |
89
+ | `level_count` | number of pyramid levels |
90
+ | `level_dimensions` | `(w, h)` per level |
91
+ | `level_downsamples` | downsample factor per level |
92
+ | `properties` | read-only metadata mapping (`openslide.vendor=unic`, `tmap.*`) |
93
+ | `associated_images` | lazy mapping, typically `macro` / `label` |
94
+ | `read_region(loc, level, size)` | `PIL.Image` (RGBA) of the region |
95
+ | `get_thumbnail(size)` | thumbnail from the lowest resolution level |
96
+ | `get_best_level_for_downsample(ds)` | best level for a downsample factor |
97
+ | `close()` / context manager | release resources |
98
+
99
+ ### `tmapslide.open_slide(filename)`
100
+
101
+ Alias of `OpenSlide(filename)`.
102
+
103
+ ## Format notes (reverse-engineered)
104
+
105
+ TMAP is an undocumented proprietary format. This reader is built from
106
+ binary analysis of real scanner output, cross-validated against
107
+ [ASlide](https://github.com/MrPeterJin/ASlide). In short: both variants
108
+ store plain JPEG tiles with a small binary header and index tables; there
109
+ is no encryption.
110
+
111
+ - TMAP06 stores 3 pyramid levels (40x / 10x / 2.5x); TMAP07 stores up to
112
+ 10 levels (40x down to 0.078x, halving each level).
113
+ - TMAP06 level-2 previews come from pre-rendered `ShrinkTile` entries and
114
+ are JPEG-compressed at that scale (slightly softer than downsampling
115
+ level 0 yourself).
116
+ - `iter_tiles()` exposes the stored tile grid directly, useful for
117
+ tile-based ML pipelines.
118
+
119
+ ## Testing
120
+
121
+ Tests run against real TMAP samples when the `scce_external_center` data
122
+ directory (or `TAPSLIDE_TEST_DATA`) is present next to the repo, and are
123
+ skipped otherwise.
124
+
125
+ ```bash
126
+ pip install -e .[dev]
127
+ pytest
128
+ ```
129
+
130
+ ## License
131
+
132
+ MIT — see [LICENSE](LICENSE).
133
+
134
+ ## Acknowledgments
135
+
136
+ - [kfbslide](https://github.com/yifanfeng97/kfbslide) — the KFB reader this
137
+ project is modelled after.
138
+ - [OpenSlide](https://openslide.org/) — the API this library mimics.
139
+ - [ASlide](https://github.com/MrPeterJin/ASlide) — its independent
140
+ reverse-engineering of the TMAP06 layer/block structures (from decompiled
141
+ vendor SDK) was used to cross-validate this implementation. tmapslide is
142
+ an independent MIT-licensed implementation and ships no ASlide code.
@@ -0,0 +1,9 @@
1
+ tmapslide/__init__.py,sha256=YYm2ZcYk9pIthxeIV3De_ZrUOYV93tm8HJPeTramXEo,1595
2
+ tmapslide/_cache.py,sha256=8Hsupz7GFrQCwjiumHZN2xtFbNC1xvpPto4unYty6A4,1013
3
+ tmapslide/_exceptions.py,sha256=nRZ9KrdokjhP-VU2GjO3uhzbYSf3lBt7vmabiLrKVoE,414
4
+ tmapslide/_slide.py,sha256=dc_m7JWERN92ZyTR9zESDEXNyKJLFLo5UCHqeoYu2c0,19442
5
+ tmapslide/_tmapformat.py,sha256=8Qj0TiRrtxEUexXWZhUL47qATNZAHKct92lPD1ZaU5U,24862
6
+ tmapslide-0.2.0.dist-info/METADATA,sha256=eiT_lqKZihf8clADNIagvor1pPeMurRTJCeyxSUBPJg,5628
7
+ tmapslide-0.2.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
8
+ tmapslide-0.2.0.dist-info/licenses/LICENSE,sha256=giFRf5C_bgy4wEImlaDjXCYbghg5UFRkchQey2z_l_U,1067
9
+ tmapslide-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yifan Feng
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.