srikarym commited on
Commit
8271f31
·
verified ·
1 Parent(s): 9535b7c

Add files using upload-large-folder tool

Browse files
Files changed (39) hide show
  1. README.md +134 -0
  2. data/ptrc_hgsoc/part-00000-of-00036.parquet +3 -0
  3. data/ptrc_hgsoc/part-00001-of-00036.parquet +3 -0
  4. data/ptrc_hgsoc/part-00002-of-00036.parquet +3 -0
  5. data/ptrc_hgsoc/part-00003-of-00036.parquet +3 -0
  6. data/ptrc_hgsoc/part-00004-of-00036.parquet +3 -0
  7. data/ptrc_hgsoc/part-00005-of-00036.parquet +3 -0
  8. data/ptrc_hgsoc/part-00006-of-00036.parquet +3 -0
  9. data/ptrc_hgsoc/part-00007-of-00036.parquet +3 -0
  10. data/ptrc_hgsoc/part-00008-of-00036.parquet +3 -0
  11. data/ptrc_hgsoc/part-00009-of-00036.parquet +3 -0
  12. data/ptrc_hgsoc/part-00010-of-00036.parquet +3 -0
  13. data/ptrc_hgsoc/part-00011-of-00036.parquet +3 -0
  14. data/ptrc_hgsoc/part-00012-of-00036.parquet +3 -0
  15. data/ptrc_hgsoc/part-00013-of-00036.parquet +3 -0
  16. data/ptrc_hgsoc/part-00014-of-00036.parquet +3 -0
  17. data/ptrc_hgsoc/part-00015-of-00036.parquet +3 -0
  18. data/ptrc_hgsoc/part-00016-of-00036.parquet +3 -0
  19. data/ptrc_hgsoc/part-00017-of-00036.parquet +3 -0
  20. data/ptrc_hgsoc/part-00018-of-00036.parquet +3 -0
  21. data/ptrc_hgsoc/part-00019-of-00036.parquet +3 -0
  22. data/ptrc_hgsoc/part-00020-of-00036.parquet +3 -0
  23. data/ptrc_hgsoc/part-00021-of-00036.parquet +3 -0
  24. data/ptrc_hgsoc/part-00022-of-00036.parquet +3 -0
  25. data/ptrc_hgsoc/part-00023-of-00036.parquet +3 -0
  26. data/ptrc_hgsoc/part-00024-of-00036.parquet +3 -0
  27. data/ptrc_hgsoc/part-00025-of-00036.parquet +3 -0
  28. data/ptrc_hgsoc/part-00026-of-00036.parquet +3 -0
  29. data/ptrc_hgsoc/part-00027-of-00036.parquet +3 -0
  30. data/ptrc_hgsoc/part-00028-of-00036.parquet +3 -0
  31. data/ptrc_hgsoc/part-00029-of-00036.parquet +3 -0
  32. data/ptrc_hgsoc/part-00030-of-00036.parquet +3 -0
  33. data/ptrc_hgsoc/part-00031-of-00036.parquet +3 -0
  34. data/ptrc_hgsoc/part-00032-of-00036.parquet +3 -0
  35. data/ptrc_hgsoc/part-00033-of-00036.parquet +3 -0
  36. data/ptrc_hgsoc/part-00034-of-00036.parquet +3 -0
  37. data/ptrc_hgsoc/part-00035-of-00036.parquet +3 -0
  38. metadata/slides.parquet +3 -0
  39. scripts/to_pixcell_layout.py +41 -0
README.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - unconditional-image-generation
5
+ - image-feature-extraction
6
+ tags:
7
+ - histopathology
8
+ - pathology
9
+ - digital-pathology
10
+ - whole-slide-images
11
+ - pixcell
12
+ - diffusion
13
+ pretty_name: PixCell Training Data
14
+ size_categories:
15
+ - 10M<n<100M
16
+ configs:
17
+ - config_name: all
18
+ default: true
19
+ data_files:
20
+ - split: train
21
+ path: data/*/*.parquet
22
+ - config_name: tcga_diagnostic
23
+ data_files:
24
+ - split: train
25
+ path: data/tcga_diagnostic/*.parquet
26
+ - config_name: tcga_fresh_frozen
27
+ data_files:
28
+ - split: train
29
+ path: data/tcga_fresh_frozen/*.parquet
30
+ - config_name: cptac
31
+ data_files:
32
+ - split: train
33
+ path: data/cptac/*.parquet
34
+ - config_name: gtex
35
+ data_files:
36
+ - split: train
37
+ path: data/gtex/*.parquet
38
+ - config_name: ptrc_hgsoc
39
+ data_files:
40
+ - split: train
41
+ path: data/ptrc_hgsoc/*.parquet
42
+ ---
43
+
44
+ # PixCell — Training Data
45
+
46
+ The 1024×1024 H&E patches used to train [PixCell](https://github.com/cvlab-stonybrook/PixCell), a generative foundation model for digital histopathology, from the publicly available sources.
47
+
48
+ **23,071,877 patches from 61,319 whole-slide images (~5.2 TB)**, extracted at 20× magnification. Images are the original JPEG files (quality 70) stored byte-for-byte, not re-encoded.
49
+
50
+ | config | source | slides | patches |
51
+ |---|---|---:|---:|
52
+ | `tcga_diagnostic` | [TCGA](https://portal.gdc.cancer.gov/) FFPE diagnostic slides, 32 cancer types | 11,713 | 9,180,591 |
53
+ | `tcga_fresh_frozen` | [TCGA](https://portal.gdc.cancer.gov/) fresh-frozen tissue slides, 32 cancer types | 18,192 | 3,680,187 |
54
+ | `cptac` | [CPTAC](https://www.cancerimagingarchive.net/browse-collections/) (TCIA), 11 cancer types | 5,802 | 2,196,291 |
55
+ | `gtex` | [GTEx](https://gtexportal.org/home/histologyPage) normal tissue, 40 tissue types | 25,266 | 7,870,674 |
56
+ | `ptrc_hgsoc` | [PTRC-HGSOC](https://www.cancerimagingarchive.net/collection/ptrc-hgsoc/) (TCIA), ovarian cancer | 346 | 144,134 |
57
+
58
+ The PixCell paper's full training set also includes NLST slides and an in-house Stony Brook University (SBU) cohort; those are not part of this release.
59
+
60
+ ## Usage
61
+
62
+ ```python
63
+ from datasets import load_dataset
64
+
65
+ # stream everything, or pick one config: "tcga_diagnostic", "gtex", ...
66
+ ds = load_dataset("srikarym/PixCell-training-data", "tcga_diagnostic", split="train", streaming=True)
67
+ ex = next(iter(ds))
68
+ ex["image"] # PIL.Image, 1024x1024 RGB
69
+ ```
70
+
71
+ To download a single source without `datasets`:
72
+
73
+ ```bash
74
+ hf download srikarym/PixCell-training-data --repo-type dataset --include "data/cptac/*" --local-dir PixCell-training-data
75
+ ```
76
+
77
+ Rows are grouped by subtype and slide. Shuffle (`ds.shuffle(buffer_size=...)`) before training.
78
+
79
+ ## Fields
80
+
81
+ | field | type | description |
82
+ |---|---|---|
83
+ | `image` | Image | JPEG patch; `image.path` is the original relative path `<src>/<subtype>/single_1024/<slide_id>/<col>_<row>.jpeg` |
84
+ | `source` | string | config name |
85
+ | `subtype` | string | cancer type (TCGA/CPTAC) or tissue type (GTEx) |
86
+ | `slide_id` | string | slide identifier (WSI filename up to the first `.`) |
87
+ | `col`, `row` | int32 | DeepZoom tile address at 20× |
88
+ | `x`, `y`, `w`, `h` | int32 | patch region in **level-0 pixels** of the WSI; the patch is this region resized to 1024×1024 |
89
+ | `objective_power` | float32 | scanner objective power from the WSI metadata (null if absent; such slides were tiled as 20×) |
90
+ | `mpp_x` | float32 | microns per pixel at level 0, from the WSI metadata |
91
+ | `in_test_set` | bool | patch belongs to the subset used for FID evaluation in the paper (it is also part of the training data) |
92
+
93
+ `metadata/slides.parquet` has one row per slide: `source, subtype, slide_id, wsi_file, num_patches, objective_power, mpp_x, width, height`. Use `wsi_file` to locate the original slide in its source archive.
94
+
95
+ ## Extraction
96
+
97
+ Patches were tiled with the DeepZoom tiler from [DSMIL](https://github.com/binli123/dsmil-wsi) (`deepzoom_tiler.py --tile_size 1024`: 20× base magnification, no overlap, background edge-threshold 15). To re-crop a patch from the original WSI:
98
+
99
+ ```python
100
+ import openslide
101
+ slide = openslide.OpenSlide(wsi_path)
102
+ patch = slide.read_region((x, y), 0, (w, h)).convert("RGB").resize((1024, 1024))
103
+ ```
104
+
105
+ ### Using with the PixCell training code
106
+
107
+ The PixCell code expects JPEG folders plus a `patch_names_all.hdf5` index. `scripts/to_pixcell_layout.py` rebuilds that layout from the downloaded shards:
108
+
109
+ ```bash
110
+ python scripts/to_pixcell_layout.py --hf_dir PixCell-training-data --out /path/to/pixcell_data
111
+ ```
112
+
113
+ The VAE latents and UNI-2h embeddings used for training are not included. They can be re-extracted from the images.
114
+
115
+ ## License and attribution
116
+
117
+ This dataset is released under CC-BY-4.0. The images are derived from public data, and use is also subject to each source's terms. Please cite and acknowledge the original sources:
118
+
119
+ - **TCGA**: The results here are in whole or part based upon data generated by the TCGA Research Network: https://www.cancer.gov/tcga.
120
+ - **CPTAC**: National Cancer Institute Clinical Proteomic Tumor Analysis Consortium (CPTAC); cite the individual CPTAC pathology collections on [TCIA](https://www.cancerimagingarchive.net/).
121
+ - **GTEx**: The Genotype-Tissue Expression (GTEx) Project was supported by the Common Fund of the Office of the Director of the National Institutes of Health, and by NCI, NHGRI, NHLBI, NIDA, NIMH, and NINDS.
122
+ - **PTRC-HGSOC**: cite the collection as listed on its [TCIA page](https://www.cancerimagingarchive.net/collection/ptrc-hgsoc/) (CC BY 4.0).
123
+ - **TCIA**: Clark K, et al. The Cancer Imaging Archive (TCIA): Maintaining and Operating a Public Information Repository. J Digit Imaging. 2013;26(6):1045–1057.
124
+
125
+ ## Citation
126
+
127
+ ```bibtex
128
+ @article{yellapragada2025pixcell,
129
+ title={PixCell: A generative foundation model for digital histopathology images},
130
+ author={Yellapragada, Srikar and Graikos, Alexandros and Li, Zilinghan and Triaridis, Kostas and Belagali, Varun and Kapse, Saarthak and Nandi, Tarak Nath and Madduri, Ravi K and Prasanna, Prateek and Kurc, Tahsin and others},
131
+ journal={arXiv preprint arXiv:2506.05127},
132
+ year={2025}
133
+ }
134
+ ```
data/ptrc_hgsoc/part-00000-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08fbdb8433f7811f74dea651a17e0e145c94cbe56757aa8aa3d71b8cf70f65d9
3
+ size 877276805
data/ptrc_hgsoc/part-00001-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07450d09b18adbeb0d0ef5e766a1f4a56b1178a1ebf28ff59d909cb2455e2326
3
+ size 847895162
data/ptrc_hgsoc/part-00002-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4aac0e0cea90fc59b5a388eb886b19742b55ee91314b47e58a311ca22aa0e483
3
+ size 852877684
data/ptrc_hgsoc/part-00003-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48a7bc96fe3f004ce281498b5033766b652870b2de3c327dc65a4f16cd54acb0
3
+ size 863242099
data/ptrc_hgsoc/part-00004-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02e9d364e8679dc5e670dc97638bed8d4ba564d1a143dadbd87c61f632f99374
3
+ size 899414068
data/ptrc_hgsoc/part-00005-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85fd65d8d84905108bb51f6ae010a63c6a52dca00f2f8229c1392d4c76a562b5
3
+ size 896922515
data/ptrc_hgsoc/part-00006-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88a7f1ad032daa9a6d34262f7f39c93f38e766271bf2e538d8be3b55220b4c3e
3
+ size 857662715
data/ptrc_hgsoc/part-00007-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:886cc850ff5e27f390c68255536b1ff726c48a3657f35d9903cc3e5c2733585f
3
+ size 926118962
data/ptrc_hgsoc/part-00008-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1760a4fbe7084d5cc518f4eff349003250da9fc2bb1aac9402873cc152a4bea0
3
+ size 907212457
data/ptrc_hgsoc/part-00009-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99f4dac851905830a2f582b408c4bdf91203a325ec950b1e06118fb3709e8633
3
+ size 947141383
data/ptrc_hgsoc/part-00010-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e953f56a3add0888c3975c2281abaa4696798041f51846e18d87d16f691da55
3
+ size 933938810
data/ptrc_hgsoc/part-00011-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9efdadec959ef69148b2aa3cbcdc34242dc83f440fbda6a16c94466e8f601a34
3
+ size 899620089
data/ptrc_hgsoc/part-00012-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1047401464a16b26882fd0e0a682df869f631630e664008afa59c6b84ab4c45d
3
+ size 874305659
data/ptrc_hgsoc/part-00013-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e89798d275663ec6d535a3b045563fbf55aa49570aaf6daa91bc00b518f22955
3
+ size 909144989
data/ptrc_hgsoc/part-00014-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ea2467529934a5cf8f7f92c188cd60f864820acf1d362324ac3054621b57e6b
3
+ size 893984721
data/ptrc_hgsoc/part-00015-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a93d9f1d0ed7ba9a1647b2669924d99e8d07820b7e63bacdc9f0e7c834e9cf6
3
+ size 903394399
data/ptrc_hgsoc/part-00016-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c74119fc3a3a5cd46567c73763411d5d22d035a35da71743ac3b95e494cbb68
3
+ size 849270886
data/ptrc_hgsoc/part-00017-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfb9d3f562cfc96d6b9a63289b36afcea09e5a47ca8b85d8edbddb67cd94dc16
3
+ size 886981853
data/ptrc_hgsoc/part-00018-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:551696be8077d459e59ded46aa722b927a5662e4d49b24bfe6c8148716918e00
3
+ size 873140960
data/ptrc_hgsoc/part-00019-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa1f6ba4c92920cbe21fcb1674dc7f8117ab300d4db2eed7102a27a5962accf3
3
+ size 850102763
data/ptrc_hgsoc/part-00020-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26402ea8ee7534de26bcf4c731f22853ae4d549b8fcb5277bbc69c6ef98d8e7e
3
+ size 888573586
data/ptrc_hgsoc/part-00021-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97b573a7d7ceb1f073ec6767d3d3294880ad8f0463978e8195bf0d3c2c7bf390
3
+ size 913750385
data/ptrc_hgsoc/part-00022-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14eceb90ed620fec6341ec1e4eaa1b67fe03d36eb261e4dbc7d7eced19acd85d
3
+ size 867324801
data/ptrc_hgsoc/part-00023-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:826126e4c34a1e32d193a1f3bd10a819e6074a186ec63945f4e1075d85e771e1
3
+ size 828638967
data/ptrc_hgsoc/part-00024-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ca35445d66edad2e532140842fc6e576368ef5073d9dd9812d381a6474e1bae
3
+ size 839666673
data/ptrc_hgsoc/part-00025-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18062b1a8881c8c1d76d847394395cc3cae0c8115633d62b588361047416a7e5
3
+ size 861461329
data/ptrc_hgsoc/part-00026-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f14bcc8b057ef63ad8e4df39bf13659d665dfb95ae9f493a1d7833cb42d45bc9
3
+ size 877960115
data/ptrc_hgsoc/part-00027-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d81a80b8b64fbd8f1eaf9c6b3caa2525315c8c936e07fb2d4d657c41400b2a6
3
+ size 920715901
data/ptrc_hgsoc/part-00028-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cb2d04555ea58932c4ce0462dd2f5ededcbefa4df073561e9bb8719c3df6166
3
+ size 852638644
data/ptrc_hgsoc/part-00029-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3aaf50d515e02cec832908043b417c9f42cfb5cb96195311c2cea5206220be82
3
+ size 848618111
data/ptrc_hgsoc/part-00030-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb4a409b4071a6162c5ec9aa3af0536ffe54dc335c9017bcf26ed87ea2e2b390
3
+ size 955911371
data/ptrc_hgsoc/part-00031-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f67703ecf92d1e1cf1aa5340dcf374780167fa73e33f1c7726ddd11f8574f2d4
3
+ size 885541796
data/ptrc_hgsoc/part-00032-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4879c70363d9b4204590f5b6e36be63e2dd44402d1c5d1b4f790ba4e213b5ee
3
+ size 899473556
data/ptrc_hgsoc/part-00033-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0395644351ff1cd0d418c8204ac4a63e1849909c8d20ce4b6da9ffd87b14bb9e
3
+ size 865612154
data/ptrc_hgsoc/part-00034-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7da3f976a0daf425bde02b63226ce62a9dd8ab2d5273173d7bc94ea2012246b9
3
+ size 894340655
data/ptrc_hgsoc/part-00035-of-00036.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18df9594e5123feb55d2f54d75cf6e20c11653d3b83c54444a07b71f4df1d7c9
3
+ size 172325351
metadata/slides.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:038e71139b1cbe6825da0095051098f24371e837eb12b85273560f707600f7ab
3
+ size 2677885
scripts/to_pixcell_layout.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Unpack PixCell-training-data Parquet shards into the folder layout used by the PixCell training code.
2
+
3
+ python to_pixcell_layout.py --hf_dir <snapshot dir> --out <root> [--sources tcga_diagnostic gtex ...]
4
+
5
+ Writes <root>/patches/<src>/<subtype>/single_1024/<slide_id>/<col>_<row>.jpeg (original JPEG bytes)
6
+ and <root>/patches/metadata/patch_names_all.hdf5 with one key per source (e.g. "tcga_diagnostic_1024").
7
+ Note: PTRC-HGSOC lives under "others/" (key "others_1024"), matching the original layout.
8
+ """
9
+ import argparse
10
+ from collections import defaultdict
11
+ from pathlib import Path
12
+
13
+ import h5py
14
+ import pyarrow.parquet as pq
15
+ from tqdm import tqdm
16
+
17
+ p = argparse.ArgumentParser()
18
+ p.add_argument("--hf_dir", type=Path, required=True)
19
+ p.add_argument("--out", type=Path, required=True)
20
+ p.add_argument("--sources", nargs="*", default=None)
21
+ args = p.parse_args()
22
+
23
+ patches = args.out / "patches"
24
+ names = defaultdict(list)
25
+ sources = args.sources or sorted(d.name for d in (args.hf_dir / "data").iterdir())
26
+ for source in sources:
27
+ for f in tqdm(sorted((args.hf_dir / "data" / source).glob("*.parquet")), desc=source):
28
+ for batch in pq.ParquetFile(f).iter_batches(columns=["image"], batch_size=256):
29
+ for img in batch.column("image").to_pylist():
30
+ dst = patches / img["path"]
31
+ dst.parent.mkdir(parents=True, exist_ok=True)
32
+ dst.write_bytes(img["bytes"])
33
+ names[img["path"].split("/")[0] + "_1024"].append(img["path"])
34
+
35
+ (patches / "metadata").mkdir(parents=True, exist_ok=True)
36
+ with h5py.File(patches / "metadata/patch_names_all.hdf5", "a") as h5:
37
+ for key, paths in names.items():
38
+ if key in h5:
39
+ del h5[key]
40
+ h5.create_dataset(key, data=paths, dtype=h5py.string_dtype())
41
+ print({k: len(v) for k, v in names.items()})