Update README.md
Browse files
README.md
CHANGED
|
@@ -33,11 +33,11 @@ It takes 256Γ256 px patches as input and outputs per-cell contours, centroids,
|
|
| 33 |
The full pipeline consists of three steps:
|
| 34 |
|
| 35 |
```
|
| 36 |
-
βββββββββββββββββ
|
| 37 |
-
β 1. Normalize
|
| 38 |
-
β
|
| 39 |
-
βββββββββββββββββ
|
| 40 |
-
SVS / TIF
|
| 41 |
```
|
| 42 |
|
| 43 |
### Magnification
|
|
@@ -100,6 +100,81 @@ python inference.py \
|
|
| 100 |
|
| 101 |
---
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
## Input / Output Details
|
| 104 |
|
| 105 |
### Input
|
|
@@ -141,7 +216,9 @@ y_global = y + y_offset
|
|
| 141 |
|
| 142 |
## Normalization Reference Image
|
| 143 |
|
| 144 |
-
The pipeline uses Reinhard color normalization in LAB color space. You need a reference image
|
|
|
|
|
|
|
| 145 |
|
| 146 |
---
|
| 147 |
|
|
@@ -149,13 +226,15 @@ The pipeline uses Reinhard color normalization in LAB color space. You need a re
|
|
| 149 |
|
| 150 |
```
|
| 151 |
HNE2Cell/
|
| 152 |
-
βββ README.md
|
| 153 |
-
βββ HNE2cell_all_patch73_jit.pt
|
| 154 |
-
βββ
|
| 155 |
-
βββ
|
| 156 |
-
βββ
|
| 157 |
-
βββ
|
| 158 |
-
|
|
|
|
|
|
|
| 159 |
```
|
| 160 |
|
| 161 |
---
|
|
@@ -172,3 +251,5 @@ If you use HNE2Cell in your research, please cite:
|
|
| 172 |
}
|
| 173 |
```
|
| 174 |
|
|
|
|
|
|
|
|
|
| 33 |
The full pipeline consists of three steps:
|
| 34 |
|
| 35 |
```
|
| 36 |
+
βββββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββ
|
| 37 |
+
β 1. Normalize β βββ β 2. Patchify β βββ β 3. Inference β
|
| 38 |
+
β (Reinhard) β β (256px, 64ov) β β (Cell Detection)β
|
| 39 |
+
βββββββββββββββββ ββββββββββββββββββ βββββββββββββββββββββ
|
| 40 |
+
SVS / TIF PNG patches Masks + Centroids
|
| 41 |
```
|
| 42 |
|
| 43 |
### Magnification
|
|
|
|
| 100 |
|
| 101 |
---
|
| 102 |
|
| 103 |
+
## Example: Reproducible Walkthrough
|
| 104 |
+
|
| 105 |
+
To verify your installation, run the pipeline on the example slide included in this repository
|
| 106 |
+
(`TCGA-56-8628-01Z-00-DX1`, LUSC, ~36 MB).
|
| 107 |
+
|
| 108 |
+
### Download the model, example slide, and reference image
|
| 109 |
+
|
| 110 |
+
```python
|
| 111 |
+
from huggingface_hub import hf_hub_download
|
| 112 |
+
|
| 113 |
+
REPO_ID = "roobee79/HNE2Cell"
|
| 114 |
+
|
| 115 |
+
model_path = hf_hub_download(
|
| 116 |
+
repo_id=REPO_ID,
|
| 117 |
+
filename="HNE2cell_all_patch73_jit.pt"
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
slide_path = hf_hub_download(
|
| 121 |
+
repo_id=REPO_ID,
|
| 122 |
+
filename="TCGA-56-8628-01Z-00-DX1.AAC57164-E0F9-4DF0-87EA-5C50FB201895.svs"
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
ref_path = hf_hub_download(
|
| 126 |
+
repo_id=REPO_ID,
|
| 127 |
+
filename="standard-ilc.tif"
|
| 128 |
+
)
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### Run the pipeline
|
| 132 |
+
|
| 133 |
+
```bash
|
| 134 |
+
# Place the downloaded slide in a working directory
|
| 135 |
+
mkdir -p example/slides
|
| 136 |
+
cp <slide_path> example/slides/
|
| 137 |
+
|
| 138 |
+
# Step 1: Normalize
|
| 139 |
+
python normalize.py \
|
| 140 |
+
--input_dir ./example/slides \
|
| 141 |
+
--target ./standard-ilc.tif
|
| 142 |
+
|
| 143 |
+
# Step 2: Patchify at 40x
|
| 144 |
+
python patchify.py \
|
| 145 |
+
--input_dir ./example/slides \
|
| 146 |
+
--magnification 40 \
|
| 147 |
+
--patch_size 256 \
|
| 148 |
+
--overlap 64 \
|
| 149 |
+
--workers 8
|
| 150 |
+
|
| 151 |
+
# Step 3: Inference
|
| 152 |
+
python inference.py \
|
| 153 |
+
--input_dir ./example/slides/TCGA-56-8628-01Z-00-DX1.../patches \
|
| 154 |
+
--output_dir ./example/results \
|
| 155 |
+
--model_path ./HNE2cell_all_patch73_jit.pt \
|
| 156 |
+
--magnification 40 \
|
| 157 |
+
--batch_size 32
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
### Expected output
|
| 161 |
+
|
| 162 |
+
```
|
| 163 |
+
example/results/
|
| 164 |
+
βββ Aligned-hne.tif # Normalized full-resolution H&E
|
| 165 |
+
βββ Aligned-hne.jpg # 4Γ preview
|
| 166 |
+
βββ patch_*_mask.png # Per-patch cell type masks
|
| 167 |
+
βββ patch_*_centroid.csv # Cell centroids with type labels
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
Approximate runtime on a single NVIDIA A100: **~20 min** for the full slide
|
| 171 |
+
(~XXX,XXX cells detected across 16 classes).
|
| 172 |
+
|
| 173 |
+
> The example slide is from **TCGA-LUSC** and is redistributed under the
|
| 174 |
+
> [NIH Genomic Data Sharing Policy](https://sharing.nih.gov/genomic-data-sharing-policy).
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
## Input / Output Details
|
| 179 |
|
| 180 |
### Input
|
|
|
|
| 216 |
|
| 217 |
## Normalization Reference Image
|
| 218 |
|
| 219 |
+
The pipeline uses Reinhard color normalization in LAB color space. You need a reference image
|
| 220 |
+
(`standard-ilc.tif`) that represents your target stain appearance. The reference image is
|
| 221 |
+
included in this repository, or you can supply your own.
|
| 222 |
|
| 223 |
---
|
| 224 |
|
|
|
|
| 226 |
|
| 227 |
```
|
| 228 |
HNE2Cell/
|
| 229 |
+
βββ README.md # This file
|
| 230 |
+
βββ HNE2cell_all_patch73_jit.pt # TorchScript model
|
| 231 |
+
βββ normalize.py # Step 1: Reinhard normalization
|
| 232 |
+
βββ patchify.py # Step 2: Patch extraction
|
| 233 |
+
βββ inference.py # Step 3: Model inference
|
| 234 |
+
βββ post_processing.py # Cell post-processing module
|
| 235 |
+
βββ tools.py # Utility functions
|
| 236 |
+
βββ standard-ilc.tif # Reference image for normalization
|
| 237 |
+
βββ TCGA-56-8628-01Z-00-DX1.AAC57164-E0F9-4DF0-87EA-5C50FB201895.svs # Example slide (TCGA-LUSC)
|
| 238 |
```
|
| 239 |
|
| 240 |
---
|
|
|
|
| 251 |
}
|
| 252 |
```
|
| 253 |
|
| 254 |
+
The example slide is derived from data generated by the TCGA Research Network:
|
| 255 |
+
<https://www.cancer.gov/tcga>.
|