patchkori 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,153 @@
1
+ Metadata-Version: 2.5
2
+ Name: patchkori
3
+ Version: 0.1.0
4
+ Summary: Modular open-source bioinformatics platform for large-scale pyramidal biological imaging
5
+ Author: Jubayer
6
+ License: MIT
7
+ Keywords: bioinformatics,gradio,ome-tiff,pathology,qptiff,whole-slide-imaging,zarr
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: gradio<6.0.0,>=5.0.0
10
+ Requires-Dist: imagecodecs>=2024.6.1
11
+ Requires-Dist: numpy>=1.26.0
12
+ Requires-Dist: pillow>=10.3.0
13
+ Requires-Dist: pydantic>=2.7.0
14
+ Requires-Dist: tifffile>=2024.5.22
15
+ Requires-Dist: typer>=0.12.0
16
+ Requires-Dist: zarr>=2.18.0
17
+ Provides-Extra: dev
18
+ Requires-Dist: mkdocs-material>=9.5.0; extra == 'dev'
19
+ Requires-Dist: pytest>=8.2.0; extra == 'dev'
20
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
21
+ Description-Content-Type: text/markdown
22
+
23
+ <div align="center">
24
+ <img src="assets/logo.svg" alt="PatchKori Logo" width="96" height="96" />
25
+ <h1>PatchKori</h1>
26
+ <p><strong>Bioinformatics Patch Kits Hub for Gigapixel Biological Image Datasets</strong></p>
27
+ <p><em>Out-of-core, memory-safe pyramidal tile extraction & analysis platform (OME-TIFF, QPTIFF, Pyramidal TIFF)</em></p>
28
+ </div>
29
+
30
+ ---
31
+
32
+ ## ๐Ÿ”ฌ What is PatchKori?
33
+
34
+ Whole-slide biological and multiplexed fluorescence images (**OME-TIFF, QPTIFF, Pyramidal TIFF, SVS, OME-Zarr**) frequently exceed **10 GB to 100+ GB per image**. Standard web tools and image viewers crash trying to load gigapixel planes into memory.
35
+
36
+ **PatchKori** solves this with a **zero-copy, out-of-core streaming architecture**:
37
+ - **Instant Header Inspection (<50ms):** Reads multi-resolution pyramid levels ($L_0 \dots L_N$) and channels without reading image pixels into RAM.
38
+ - **Interactive Low-Res Preview Canvas:** Displays an eye-soothing, colorblind-safe thumbnail preview. Draw an ROI box with your cursor or enter exact coordinates.
39
+ - **Direct-to-Disk Chunk Slicing:** Uses Zarr-backed `tifffile` tile streaming to extract only the compressed tiles you need directly to your local drive without memory spikes.
40
+ - **Extensible Hub Architecture:** Easily drop in future bioinformatics tools (e.g. segmentation, stain normalization) as self-contained plugins.
41
+
42
+ ---
43
+
44
+ ## ๐Ÿš€ Quickstart: How to Use PatchKori
45
+
46
+ ### 1. Installation
47
+
48
+ Clone and install PatchKori locally (Python 3.10+):
49
+
50
+ ```bash
51
+ git clone git@github.com:jubayer98/PatchKori.git
52
+ cd PatchKori
53
+ pip install -e ".[dev]"
54
+ ```
55
+
56
+ ### 2. Launch the Web Interface
57
+
58
+ Start the local web application with one command:
59
+
60
+ ```bash
61
+ patchkori launch
62
+ ```
63
+
64
+ Your default browser will open automatically to **`http://127.0.0.1:7860`**.
65
+
66
+ ---
67
+
68
+ ## ๐Ÿ–ฅ๏ธ How to Use the Web Interface (Step-by-Step)
69
+
70
+ ```
71
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
72
+ โ”‚ 1. Configuration & Tiling โ”‚ 2. Interactive Canvas โ”‚ 3. Execution & Gallery โ”‚
73
+ โ”‚ โ€ข Local File Path โ”‚ โ€ข [๐Ÿ“ Full Level ROI] โ”‚ โ€ข Output Directory โ”‚
74
+ โ”‚ โ€ข Optional markerlist.txt โ”‚ โ€ข [โœ๏ธ Apply Hand-Drawn Box] โ”‚ โ€ข Format (ome.tif / png / zarr) โ”‚
75
+ โ”‚ โ€ข [๐Ÿงช Load Sample Dataset] โ”‚ โ€ข Thumbnail Preview โ”‚ โ€ข [โœ‚๏ธ Run Out-of-Core Crop] โ”‚
76
+ โ”‚ โ€ข Crop / Grid Tile Parameters โ”‚ โ€ข Pyramid Level Table (L0..LN) โ”‚ โ€ข Live Progress Feedback โ”‚
77
+ โ”‚ โ€ข Target Level & Channels โ”‚ โ€ข Full Channel Name Badges โ”‚ โ€ข Instant Preview Gallery โ”‚
78
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
79
+ ```
80
+
81
+ 1. **Load Your Image:**
82
+ - Enter your **Local File Path** (e.g. `/path/to/my_slide.qptiff` or `.ome.tif`).
83
+ - *(Optional)* Provide a **`markerlist.txt`** file (one channel name per line) to automatically name multiplex channels. If omitted, channel names are read from OME-XML or fallback to index numbers `[0] Channel 0`, `[1] Channel 1`...
84
+ - Click **๐Ÿ” Inspect Pyramid** (or click **๐Ÿงช Load Sample Dataset** to test with the built-in 4-level pyramidal image).
85
+ 2. **Select Region of Interest (ROI):**
86
+ - **Hand-Drawn Box:** Select the brush on the preview canvas, draw over your desired region, and click **โœ๏ธ Apply Hand-Drawn Box**.
87
+ - **Full Slide:** Click **๐Ÿ“ Full Level ROI** to select the entire slide.
88
+ - **Numeric Tuning:** Fine-tune `X`, `Y`, `Width`, and `Height` on the left.
89
+ 3. **Choose Target Level & Channels:**
90
+ - **Target Level:** Choose from $L_0$ (highest resolution, 1.0ร—) down to $L_N$ (lowest resolution).
91
+ - **Channels Dropdown:** Pick any subset of markers (e.g. `[0] DAPI`, `[2] PanCK`). Leaving it empty extracts all channels.
92
+ 4. **Choose Crop Mode:**
93
+ - **Single Bounding-Box ROI:** Extracts a single cropped patch of the chosen region.
94
+ - **Sliding-Window Tile Grid:** Slices the ROI into regular tiles (e.g. $256 \times 256$ or $512 \times 512$ with customizable overlap) for deep learning training datasets.
95
+ 5. **Run Crop:**
96
+ - Click **โœ‚๏ธ Run Out-of-Core Crop**.
97
+ - Crops are written directly to your chosen local folder (`outputs/crops`) with instant visual previews in the gallery.
98
+
99
+ ---
100
+
101
+ ## โšก Headless CLI Usage (For HPC, Clusters & Pipelines)
102
+
103
+ You can run PatchKori headless without opening the browser:
104
+
105
+ ```bash
106
+ # Slicing an ROI directly from the terminal
107
+ patchkori crop /data/wsi/sample.qptiff \
108
+ --level 0 \
109
+ --x 1024 --y 2048 --width 512 --height 512 \
110
+ --format ome.tif \
111
+ --output-dir ./results
112
+
113
+ # Sliding-window tiling for ML datasets
114
+ patchkori crop /data/wsi/sample.qptiff \
115
+ --level 1 \
116
+ --x 0 --y 0 --width 4096 --height 4096 \
117
+ --mode tile_grid --tile-size 512 --overlap 64 \
118
+ --format png \
119
+ --output-dir ./training_tiles
120
+ ```
121
+
122
+ ---
123
+
124
+ ## ๐Ÿ”Œ Adding Future Bioinformatics Tools
125
+
126
+ Adding a 2nd or 3rd bioinformatics tool requires **zero modifications** to existing core code:
127
+
128
+ 1. Add pure algorithmic logic to `src/patchkori/core/<my_tool>/`.
129
+ 2. Create `src/patchkori/ui/tools/<my_tool>.py`:
130
+
131
+ ```python
132
+ import gradio as gr
133
+ from patchkori.ui.registry import BaseBioTool, ToolRegistry
134
+
135
+ @ToolRegistry.register
136
+ class MyBioTool(BaseBioTool):
137
+ tool_id = "my-tool"
138
+ title = "My Bio Tool"
139
+ icon = "๐Ÿ”ฌ"
140
+ description = "Self-contained bioinformatics tool plugin."
141
+ order = 20
142
+
143
+ def build_ui(self, is_demo_mode: bool = False) -> None:
144
+ gr.Markdown("### Custom Tool Workspace")
145
+ ```
146
+
147
+ 3. Import it in `src/patchkori/ui/tools/__init__.py`. It automatically appears as a new tab in the Hub!
148
+
149
+ ---
150
+
151
+ ## ๐Ÿ›ก๏ธ License
152
+
153
+ MIT License. Developed for open-source biological imaging and computational pathology research.
@@ -0,0 +1,19 @@
1
+ patchkori/__init__.py,sha256=3JquC_xkrr2fJ_v8tF3PYWHvv7B5sTgrb-uuLp357kU,119
2
+ patchkori/cli.py,sha256=D0zlmxDwqEx904EtKVrYXbx_ZGV2UPze2tNvec9LEzs,4348
3
+ patchkori/config.py,sha256=AWJohSTrXMl13KuzPkgqwaVtdG-cKUSarN8ScgAVYZM,1076
4
+ patchkori/core/__init__.py,sha256=sA1pnTa217R7bL6KUrVM9B0v6sBuo-92zSpMyPdl0kI,330
5
+ patchkori/core/models.py,sha256=HTK4dcpNbYRUTTBGq46l8wrhMbrqgSnxpGpVRnyRZyg,3280
6
+ patchkori/core/sample_generator.py,sha256=2FHaI_qWJnbdnUlXFKjedejgAZjZ3YuM9j7rBTKUK7U,2665
7
+ patchkori/core/pyramidal_cropper/__init__.py,sha256=_G_LdtZ6FattUliHAj4dMWYjw9B3DCQuWsbN3HY8qrI,155
8
+ patchkori/core/pyramidal_cropper/adapter.py,sha256=L_aisNeuL2U6VScOZB9QnFd7EgBZHeLoWGzbEZdUOUA,18430
9
+ patchkori/ui/__init__.py,sha256=LSRMwLkG2nf57w3obOOXu09AYLhpbacBxvg2y4LQ_yo,174
10
+ patchkori/ui/app.py,sha256=dsCAw3fZwuxUTaQgUsudCYxuhXteaHK5tcm-Sg75Bg4,1547
11
+ patchkori/ui/icons.py,sha256=h1pUqgEr9187LVfT7TQOCGExcRTo0gSgwP8NLFFD63I,6119
12
+ patchkori/ui/registry.py,sha256=l2oavy7iv-F00T8M4jKPgraQQ2XxuoDoBOjeE0cGezI,1354
13
+ patchkori/ui/theme.py,sha256=2RECafR0c6K49wLgrMnx6X_ToR4d5NXClrv7xea48s8,6830
14
+ patchkori/ui/tools/__init__.py,sha256=3koo_5C2A0OQUzIYAXaHRiIs47VsaP3RXsVTUe9VsQE,166
15
+ patchkori/ui/tools/pyramidal_cropper.py,sha256=gmfyGVGjIIpO4rsD2QE7NcQSz8GbW0d370atQfuGFxw,25197
16
+ patchkori-0.1.0.dist-info/METADATA,sha256=6ln5hQRyiHl0HS_dPJL5nrsKqGe6uM9pt7CAXddOARQ,6946
17
+ patchkori-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ patchkori-0.1.0.dist-info/entry_points.txt,sha256=7IHs9wr44qAMNX0l6IhUUJgsyP_ADUrtdlXUO47ZP5g,48
19
+ patchkori-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ patchkori = patchkori.cli:app