uermel commited on
Commit
2cba399
·
1 Parent(s): 01dd63f

add demo file

Browse files
Files changed (2) hide show
  1. README.md +196 -20
  2. demos.ipynb +274 -0
README.md CHANGED
@@ -25,6 +25,8 @@ configs:
25
  data_files: bacterial/Croissant/runs.csv
26
  - config_name: yeast
27
  data_files: yeast/Croissant/runs.csv
 
 
28
  ---
29
 
30
  # Dataset Card for POPSICLE
@@ -58,7 +60,7 @@ protocol) so models can be trained and compared under one roof.
58
  | **Phantom** | Localization | Lysate / synthetic | 7 | 485 | ✅ released |
59
  | **Yeast** | Segmentation | *S. pombe* | 16 | 4 | ✅ released |
60
  | **Bacterial** | Segmentation | Prokaryote (8 genera) | 68 | 12 | ✅ released |
61
- | MotorBench | Localization | *V. cholerae* | 1,288 | 844 | 🚧 pending |
62
 
63
  - **Curated by:** Authors of the POPSICLE benchmark paper (NeurIPS 2026, under review).
64
  - **Shared by:** Biohub Dynamic Structural Biology / CryoET Data Portal community.
@@ -128,7 +130,7 @@ popsicle/
128
  objects.csv # name, url
129
  bacterial/ # ✅ released — segmentation across 8 bacterial genera
130
  yeast/ # ✅ released — segmentation in *S. pombe*
131
- motorbench/ # 🚧 pending
132
  ```
133
 
134
  `copick:baseUrl` is set to `s3://cryoet-data-portal-public/` so the CSV
@@ -169,18 +171,40 @@ excluded so the benchmark scores against the canonical reference labels.
169
 
170
  ```python
171
  import copick
 
 
172
 
173
  root = copick.from_croissant(
174
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/phantom/Croissant/metadata.json",
175
  static_fs_args={"anon": True}, # public portal bucket
176
  )
177
 
178
- print(root.splits) # {'train': [...], 'val': [...], 'test': [...]}
 
 
 
 
 
179
 
180
- train_runs = root.get_runs_in_split("train")
181
- run = train_runs[0]
 
 
 
 
 
 
 
182
  for pick_set in run.picks:
183
- print(pick_set.pickable_object_name, len(pick_set.points))
 
 
 
 
 
 
 
 
184
  ```
185
 
186
  ### Bacterial — multi-class compartment segmentation
@@ -228,17 +252,43 @@ leak into the benchmark.
228
 
229
  ```python
230
  import copick
 
 
231
 
232
  root = copick.from_croissant(
233
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/bacterial/Croissant/metadata.json",
234
  static_fs_args={"anon": True}, # public portal bucket
235
  )
236
 
237
- print(root.splits) # {'train': [68 names], 'test': [12 names]}
 
 
 
 
 
238
 
 
239
  run = root.get_runs_in_split("train")[0]
240
- for seg in run.segmentations:
241
- print(seg.name, seg.voxel_size)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  ```
243
 
244
  ### Yeast — multi-class organelle segmentation
@@ -291,17 +341,118 @@ the better-sampled bacterial benchmark (paper §4, §6, Table 2).
291
 
292
  ```python
293
  import copick
 
 
294
 
295
  root = copick.from_croissant(
296
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/yeast/Croissant/metadata.json",
297
  static_fs_args={"anon": True}, # public portal bucket
298
  )
299
 
300
- print(root.splits) # {'train': [16 names], 'test': [4 names]}
 
 
 
 
 
301
 
 
302
  run = root.get_runs_in_split("train")[0]
303
- for seg in run.segmentations:
304
- print(seg.name, seg.voxel_size)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  ```
306
 
307
  ## Dataset Creation
@@ -370,13 +521,16 @@ the underlying tomograms are re-acquired by this project.
370
  inclusion, intermembrane-space, membrane) on 80 cellular tomograms
371
  from 8 bacterial genera, deposited as
372
  [CZCDP-10350](https://cryoetdataportal.czscience.com/depositions/10350).
373
- - **Yeast** *(pending)*: organelle segmentations originally produced by
374
  de Teresa-Trueba et al. 2023; curated and standardized by Biohub DSB
375
  for inclusion in POPSICLE.
376
- - **MotorBench** *(pending)*: bacterial flagellar motor centers picked
377
- by the BYU Kaggle competition contributors (training corpus expanded
378
- by the first-place team and MIC-DKFZ); the held-out test set was
379
- authored by Owens et al. 2025.
 
 
 
380
 
381
  #### Who are the annotators?
382
 
@@ -385,9 +539,9 @@ the underlying tomograms are re-acquired by this project.
385
  to exclude community Kaggle submissions hosted on the same datasets).
386
  - **Bacterial**: POPSICLE author team (CZCDP-10350 contributors —
387
  Peck, Ermel, Schwartz, Owens, Carragher, Kimanius, and others).
388
- - **Yeast** *(pending)*: de Teresa-Trueba et al. 2023, with curatorial
389
  refinement by Biohub DSB.
390
- - **MotorBench** *(pending)*: BYU competition + first-place team
391
  (Brenden Artley) + MIC-DKFZ (Fabian Isensee et al.) for the training
392
  corpus; Owens et al. 2025 (V. cholerae) for the held-out test set.
393
 
@@ -500,6 +654,29 @@ copick toolkit:
500
  macromolecule within a tomogram.
501
  - **Segmentation** — a voxel-wise label volume assigning each voxel to
502
  one of a fixed set of classes (membrane, organelle, cytoplasm, …).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  - **Missing wedge** — the cone of unmeasured Fourier-space data caused
504
  by the limited tilt range during cryoET acquisition; produces
505
  anisotropic resolution and characteristic elongation artifacts.
@@ -512,7 +689,6 @@ copick toolkit:
512
 
513
  - copick documentation: https://github.com/copick/copick
514
  - CryoET Data Portal: https://cryoetdataportal.czscience.com
515
- - mlcroissant spec: https://docs.mlcommons.org/croissant/docs/croissant-spec.html
516
 
517
  ## Dataset Card Authors
518
 
 
25
  data_files: bacterial/Croissant/runs.csv
26
  - config_name: yeast
27
  data_files: yeast/Croissant/runs.csv
28
+ - config_name: motorbench
29
+ data_files: motorbench/Croissant/runs.csv
30
  ---
31
 
32
  # Dataset Card for POPSICLE
 
60
  | **Phantom** | Localization | Lysate / synthetic | 7 | 485 | ✅ released |
61
  | **Yeast** | Segmentation | *S. pombe* | 16 | 4 | ✅ released |
62
  | **Bacterial** | Segmentation | Prokaryote (8 genera) | 68 | 12 | ✅ released |
63
+ | **MotorBench**| Localization | *V. cholerae* (test) + multi-genus prokaryotes (train) | 1,559 | 843 | released |
64
 
65
  - **Curated by:** Authors of the POPSICLE benchmark paper (NeurIPS 2026, under review).
66
  - **Shared by:** Biohub Dynamic Structural Biology / CryoET Data Portal community.
 
130
  objects.csv # name, url
131
  bacterial/ # ✅ released — segmentation across 8 bacterial genera
132
  yeast/ # ✅ released — segmentation in *S. pombe*
133
+ motorbench/ # released — flagellar-motor localization
134
  ```
135
 
136
  `copick:baseUrl` is set to `s3://cryoet-data-portal-public/` so the CSV
 
171
 
172
  ```python
173
  import copick
174
+ import numpy as np
175
+ import matplotlib.pyplot as plt
176
 
177
  root = copick.from_croissant(
178
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/phantom/Croissant/metadata.json",
179
  static_fs_args={"anon": True}, # public portal bucket
180
  )
181
 
182
+ # Loop over every split and every run
183
+ for split, run_names in root.splits.items():
184
+ print(f"{split}: {len(run_names)} runs")
185
+ for run in root.get_runs_in_split(split):
186
+ for pick_set in run.picks:
187
+ print(f" {run.name} {pick_set.pickable_object_name}: {len(pick_set.points)} pts")
188
 
189
+ # Visualize: midplane slice of one tomogram with picks overlaid as scatter
190
+ run = root.get_runs_in_split("train")[0]
191
+ vs = run.voxel_spacings[0] # 10 Å for Phantom
192
+ tomo = vs.tomograms[0] # any tomo_type at this voxel spacing
193
+ arr = tomo.numpy() # (Z, Y, X) — streams from portal S3
194
+
195
+ z_mid = arr.shape[0] // 2
196
+ fig, ax = plt.subplots(figsize=(8, 8))
197
+ ax.imshow(arr[z_mid], cmap="gray")
198
  for pick_set in run.picks:
199
+ # CopickPoint locations are in physical units (Å); convert to voxel indices.
200
+ pts = np.array(
201
+ [(p.location.x, p.location.y, p.location.z) for p in pick_set.points]
202
+ ) / vs.voxel_size
203
+ near = pts[np.abs(pts[:, 2] - z_mid) < 5] # within ±5 voxels of the slice
204
+ ax.scatter(near[:, 0], near[:, 1], s=24, label=pick_set.pickable_object_name)
205
+ ax.legend(loc="upper right", fontsize=8)
206
+ ax.set_title(f"{run.name} z={z_mid}")
207
+ plt.show()
208
  ```
209
 
210
  ### Bacterial — multi-class compartment segmentation
 
252
 
253
  ```python
254
  import copick
255
+ import numpy as np
256
+ import matplotlib.pyplot as plt
257
 
258
  root = copick.from_croissant(
259
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/bacterial/Croissant/metadata.json",
260
  static_fs_args={"anon": True}, # public portal bucket
261
  )
262
 
263
+ # Loop over every split and every run
264
+ for split, run_names in root.splits.items():
265
+ print(f"{split}: {len(run_names)} runs")
266
+ for run in root.get_runs_in_split(split):
267
+ seg_names = sorted({s.name for s in run.segmentations})
268
+ print(f" {run.name}: {seg_names}")
269
 
270
+ # Visualize: midplane slice of one tomogram with segmentation masks overlaid
271
  run = root.get_runs_in_split("train")[0]
272
+ vs = run.voxel_spacings[0]
273
+ tomo = vs.tomograms[0]
274
+ arr = tomo.numpy() # (Z, Y, X) — streams from portal S3
275
+ z_mid = arr.shape[0] // 2
276
+
277
+ fig, ax = plt.subplots(figsize=(8, 8))
278
+ ax.imshow(arr[z_mid], cmap="gray")
279
+ cmap = plt.get_cmap("tab10")
280
+ for i, seg in enumerate(run.segmentations):
281
+ mask = seg.numpy()[z_mid] # (Y, X) — same shape as the tomo slice
282
+ ax.imshow(
283
+ np.ma.masked_where(mask == 0, mask),
284
+ cmap=cmap, vmin=0, vmax=10, alpha=0.4,
285
+ interpolation="none",
286
+ )
287
+ # one-line legend hack: scatter a single point off-image with the class color
288
+ ax.scatter([], [], color=cmap(i), label=seg.name)
289
+ ax.legend(loc="upper right", fontsize=8)
290
+ ax.set_title(f"{run.name} z={z_mid}")
291
+ plt.show()
292
  ```
293
 
294
  ### Yeast — multi-class organelle segmentation
 
341
 
342
  ```python
343
  import copick
344
+ import numpy as np
345
+ import matplotlib.pyplot as plt
346
 
347
  root = copick.from_croissant(
348
  "https://huggingface.co/datasets/uermel/popsicle/resolve/main/yeast/Croissant/metadata.json",
349
  static_fs_args={"anon": True}, # public portal bucket
350
  )
351
 
352
+ # Loop over every split and every run
353
+ for split, run_names in root.splits.items():
354
+ print(f"{split}: {len(run_names)} runs")
355
+ for run in root.get_runs_in_split(split):
356
+ seg_names = sorted({s.name for s in run.segmentations})
357
+ print(f" {run.name}: {seg_names}")
358
 
359
+ # Visualize: midplane slice of one tomogram with organelle segmentations overlaid
360
  run = root.get_runs_in_split("train")[0]
361
+ vs = run.voxel_spacings[0]
362
+ tomo = vs.tomograms[0]
363
+ arr = tomo.numpy() # (Z, Y, X) — streams from portal S3
364
+ z_mid = arr.shape[0] // 2
365
+
366
+ fig, ax = plt.subplots(figsize=(8, 8))
367
+ ax.imshow(arr[z_mid], cmap="gray")
368
+ cmap = plt.get_cmap("tab10")
369
+ for i, seg in enumerate(run.segmentations):
370
+ mask = seg.numpy()[z_mid]
371
+ ax.imshow(
372
+ np.ma.masked_where(mask == 0, mask),
373
+ cmap=cmap, vmin=0, vmax=10, alpha=0.4,
374
+ interpolation="none",
375
+ )
376
+ ax.scatter([], [], color=cmap(i), label=seg.name)
377
+ ax.legend(loc="upper right", fontsize=8)
378
+ ax.set_title(f"{run.name} z={z_mid}")
379
+ plt.show()
380
+ ```
381
+
382
+ ### MotorBench — single-class flagellar motor localization
383
+
384
+ Sparse 3D point localization of bacterial flagellar motors in whole-cell
385
+ cryoET tomograms. The benchmark is derived from the BYU 2025 Kaggle
386
+ challenge ([CZCDP-10332](https://cryoetdataportal.czscience.com/depositions/10332)
387
+ train, [CZCDP-10347](https://cryoetdataportal.czscience.com/depositions/10347)
388
+ test). The training side is **annotation-only** on the portal — its
389
+ 1,559 motor picks are scattered across **92 host datasets** spanning
390
+ many bacterial and archaeal genera, contributed by the BYU competition
391
+ authors plus the first-place (Brenden Artley) and MIC-DKFZ (Isensee
392
+ et al.) follow-up releases. The held-out test side is a complete
393
+ deposition: 5 *Vibrio cholerae* datasets (DS-10485…10489) authored by
394
+ Owens et al. 2025.
395
+
396
+ | Class | Portal `object_name` |
397
+ |-------------------|----------------------------------|
398
+ | `flagellar-motor` | `bacterial-type-flagellum-motor` |
399
+
400
+ #### Splits
401
+
402
+ | Split | CDP source(s) | # tomograms | # motor picks | Notes |
403
+ |---------|-------------------------------------|------------:|--------------:|-------------------------------------------|
404
+ | `train` | CZCDP-10332 → 92 host datasets | 1,559 | 1,559 | One motor pick per training run |
405
+ | `test` | CZCDP-10347 (DS-10485…10489) | 843 | 275 | Includes pickless negative samples |
406
+
407
+ The train slice was filtered down from the 3,528 host-dataset runs to
408
+ only those that carry a CZCDP-10332 motor annotation — runs without
409
+ a motor pick belong to unrelated experiments and are not part of the
410
+ benchmark. The test slice keeps all 843 *V. cholerae* runs (motor and
411
+ no-motor) because negative samples are an explicit part of the held-out
412
+ evaluation per Owens et al. 2025.
413
+
414
+ Picks are scoped to deposition_id so the train and test slices stay
415
+ disjoint even where the same host datasets appear in both depositions'
416
+ neighborhoods — this is implemented via the
417
+ `picks_portal_meta={"deposition_id": ...}` filter on each export pass.
418
+
419
+ #### Loading with copick
420
+
421
+ ```python
422
+ import copick
423
+ import numpy as np
424
+ import matplotlib.pyplot as plt
425
+
426
+ root = copick.from_croissant(
427
+ "https://huggingface.co/datasets/uermel/popsicle/resolve/main/motorbench/Croissant/metadata.json",
428
+ static_fs_args={"anon": True}, # public portal bucket
429
+ )
430
+
431
+ # Loop over every split and every run; report runs that carry motor picks
432
+ for split, run_names in root.splits.items():
433
+ runs_with = [r for r in root.get_runs_in_split(split) if r.picks]
434
+ print(f"{split}: {len(run_names)} runs ({len(runs_with)} with motor picks)")
435
+
436
+ # Visualize: midplane slice of one *V. cholerae* test tomogram with motor
437
+ # centers overlaid as crosses
438
+ run = next(r for r in root.get_runs_in_split("test") if r.picks)
439
+ vs = run.voxel_spacings[0]
440
+ tomo = vs.tomograms[0]
441
+ arr = tomo.numpy() # (Z, Y, X) — streams from portal S3
442
+ z_mid = arr.shape[0] // 2
443
+
444
+ fig, ax = plt.subplots(figsize=(8, 8))
445
+ ax.imshow(arr[z_mid], cmap="gray")
446
+ for pick_set in run.picks:
447
+ pts = np.array(
448
+ [(p.location.x, p.location.y, p.location.z) for p in pick_set.points]
449
+ ) / vs.voxel_size
450
+ near = pts[np.abs(pts[:, 2] - z_mid) < 5]
451
+ ax.scatter(near[:, 0], near[:, 1], marker="x", s=80, c="red",
452
+ label=pick_set.pickable_object_name)
453
+ ax.legend(loc="upper right", fontsize=8)
454
+ ax.set_title(f"{run.name} z={z_mid}")
455
+ plt.show()
456
  ```
457
 
458
  ## Dataset Creation
 
521
  inclusion, intermembrane-space, membrane) on 80 cellular tomograms
522
  from 8 bacterial genera, deposited as
523
  [CZCDP-10350](https://cryoetdataportal.czscience.com/depositions/10350).
524
+ - **Yeast**: organelle segmentations originally produced by
525
  de Teresa-Trueba et al. 2023; curated and standardized by Biohub DSB
526
  for inclusion in POPSICLE.
527
+ - **MotorBench**: bacterial flagellar motor centers picked
528
+ by the BYU Kaggle competition contributors (training corpus
529
+ CZCDP-10332, expanded by the first-place team and MIC-DKFZ); the
530
+ held-out test set (CZCDP-10347, V. cholerae) was authored by Owens
531
+ et al. 2025. Picks are filtered by deposition_id so the train and
532
+ test slices stay disjoint even though the train deposition reuses
533
+ tomograms from many host datasets.
534
 
535
  #### Who are the annotators?
536
 
 
539
  to exclude community Kaggle submissions hosted on the same datasets).
540
  - **Bacterial**: POPSICLE author team (CZCDP-10350 contributors —
541
  Peck, Ermel, Schwartz, Owens, Carragher, Kimanius, and others).
542
+ - **Yeast**: de Teresa-Trueba et al. 2023, with curatorial
543
  refinement by Biohub DSB.
544
+ - **MotorBench**: BYU competition + first-place team
545
  (Brenden Artley) + MIC-DKFZ (Fabian Isensee et al.) for the training
546
  corpus; Owens et al. 2025 (V. cholerae) for the held-out test set.
547
 
 
654
  macromolecule within a tomogram.
655
  - **Segmentation** — a voxel-wise label volume assigning each voxel to
656
  one of a fixed set of classes (membrane, organelle, cytoplasm, …).
657
+ - **Run** *(CryoET Data Portal)* — all data acquired and derived from
658
+ imaging a single location in a sample: the original tilt series,
659
+ motion-corrected frames, one or more reconstructed tomograms (often at
660
+ multiple voxel spacings), and any annotations attached to those
661
+ tomograms. A run belongs to exactly one dataset and is identified by
662
+ a unique numeric Run ID. Copick exposes this as `run.name` (a string
663
+ cast of the Run ID for portal-backed projects).
664
+ - **Dataset** *(CryoET Data Portal, "DS-XXXXX")* — a collection of runs
665
+ that share a common sample and acquisition context (organism, strain,
666
+ preparation, microscope session). Datasets carry their own metadata
667
+ (sample type, growth conditions, instrument, contributing lab) and
668
+ belong to exactly one deposition. The CDP "DS-10440" notation refers
669
+ to a Dataset row.
670
+ - **Deposition** *(CryoET Data Portal, "CZCDP-XXXXX")* — a higher-level
671
+ grouping under which one or more datasets and/or annotations are
672
+ contributed to the portal as a single submission, typically tied to
673
+ a publication or a community release (e.g. CZCDP-10350 for the
674
+ POPSICLE Bacterial deposition). A deposition can be **full** (it
675
+ carries new datasets + their tomograms + annotations) or
676
+ **annotation-only** (it carries new annotations attached to runs that
677
+ already exist in datasets contributed earlier under different
678
+ depositions — used by POPSICLE for the Bacterial annotations and by
679
+ the BYU MotorBench train deposition).
680
  - **Missing wedge** — the cone of unmeasured Fourier-space data caused
681
  by the limited tilt range during cryoET acquisition; produces
682
  anisotropic resolution and characteristic elongation artifacts.
 
689
 
690
  - copick documentation: https://github.com/copick/copick
691
  - CryoET Data Portal: https://cryoetdataportal.czscience.com
 
692
 
693
  ## Dataset Card Authors
694
 
demos.ipynb ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# POPSICLE \u2014 copick demos\n",
8
+ "\n",
9
+ "Minimal load-and-visualize examples for each released POPSICLE\n",
10
+ "sub-benchmark. Every demo:\n",
11
+ "\n",
12
+ "1. Opens the Croissant manifest from this Hugging Face repo.\n",
13
+ "2. Loops over each split and prints per-run annotation summaries.\n",
14
+ "3. Streams one tomogram from the CryoET Data Portal and overlays\n",
15
+ " that run's picks (Phantom) or segmentation masks (Bacterial,\n",
16
+ " Yeast) on a midplane slice.\n",
17
+ "\n",
18
+ "All data is read on demand from `s3://cryoet-data-portal-public/`\n",
19
+ "\u2014 nothing large lands on disk. The `metadata.json` itself is fetched\n",
20
+ "from this dataset repo on Hugging Face.\n"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "markdown",
25
+ "metadata": {},
26
+ "source": [
27
+ "## Setup\n",
28
+ "\n",
29
+ "Install the runtime dependencies. `copick` provides the\n",
30
+ "`from_croissant` reader and the `run.picks`, `run.segmentations`,\n",
31
+ "and `tomo.numpy()` helpers used below; `s3fs` lets `copick`\n",
32
+ "stream from the portal's public bucket anonymously.\n"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": null,
38
+ "metadata": {},
39
+ "outputs": [],
40
+ "source": [
41
+ "%pip install --quiet copick s3fs matplotlib\n"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "markdown",
46
+ "metadata": {},
47
+ "source": [
48
+ "## Phantom \u2014 multi-class macromolecular localization\n",
49
+ "\n",
50
+ "Six particle classes (apo-ferritin, beta-amylase, beta-galactosidase,\n",
51
+ "ribosome, thyroglobulin, virus-like-particle) on 492 lysate\n",
52
+ "tomograms split into `train` / `val` / `test`. Picks are restricted\n",
53
+ "to the original ground-truth author (Ariana Peck).\n"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": null,
59
+ "metadata": {},
60
+ "outputs": [],
61
+ "source": [
62
+ "import copick\n",
63
+ "import numpy as np\n",
64
+ "import matplotlib.pyplot as plt\n",
65
+ "\n",
66
+ "PHANTOM_URL = (\n",
67
+ " \"https://huggingface.co/datasets/uermel/popsicle/resolve/main/\"\n",
68
+ " \"phantom/Croissant/metadata.json\"\n",
69
+ ")\n",
70
+ "\n",
71
+ "root = copick.from_croissant(PHANTOM_URL, static_fs_args={\"anon\": True})\n",
72
+ "\n",
73
+ "for split, run_names in root.splits.items():\n",
74
+ " print(f\"{split}: {len(run_names)} runs\")\n",
75
+ " for run in root.get_runs_in_split(split)[:3]: # head sample\n",
76
+ " for pick_set in run.picks:\n",
77
+ " print(\n",
78
+ " f\" {run.name} {pick_set.pickable_object_name}: \"\n",
79
+ " f\"{len(pick_set.points)} pts\"\n",
80
+ " )\n"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": null,
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "# Visualize: midplane slice of one Phantom tomogram with picks overlaid.\n",
90
+ "run = root.get_runs_in_split(\"train\")[0]\n",
91
+ "vs = run.voxel_spacings[0] # 10 \u00c5 for Phantom\n",
92
+ "tomo = vs.tomograms[0] # any tomo_type at this voxel spacing\n",
93
+ "arr = tomo.numpy() # (Z, Y, X) \u2014 streams from portal S3\n",
94
+ "z_mid = arr.shape[0] // 2\n",
95
+ "\n",
96
+ "fig, ax = plt.subplots(figsize=(8, 8))\n",
97
+ "ax.imshow(arr[z_mid], cmap=\"gray\")\n",
98
+ "for pick_set in run.picks:\n",
99
+ " # CopickPoint locations are in physical units (\u00c5); convert to voxel indices.\n",
100
+ " pts = np.array(\n",
101
+ " [(p.location.x, p.location.y, p.location.z) for p in pick_set.points]\n",
102
+ " ) / vs.voxel_size\n",
103
+ " near = pts[np.abs(pts[:, 2] - z_mid) < 5] # within \u00b15 voxels of the slice\n",
104
+ " ax.scatter(near[:, 0], near[:, 1], s=24, label=pick_set.pickable_object_name)\n",
105
+ "ax.legend(loc=\"upper right\", fontsize=8)\n",
106
+ "ax.set_title(f\"{run.name} z={z_mid}\")\n",
107
+ "plt.show()\n"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "markdown",
112
+ "metadata": {},
113
+ "source": [
114
+ "## Bacterial \u2014 multi-class compartment segmentation\n",
115
+ "\n",
116
+ "Five compartment classes (cytosole, flagellum, inclusion,\n",
117
+ "intermembrane-space, membrane) on 80 cellular tomograms across 8\n",
118
+ "bacterial genera, split 68/12 train/test. Annotations sourced from\n",
119
+ "deposition CZCDP-10350 only.\n"
120
+ ]
121
+ },
122
+ {
123
+ "cell_type": "code",
124
+ "execution_count": null,
125
+ "metadata": {},
126
+ "outputs": [],
127
+ "source": [
128
+ "import copick\n",
129
+ "import numpy as np\n",
130
+ "import matplotlib.pyplot as plt\n",
131
+ "\n",
132
+ "BACTERIAL_URL = (\n",
133
+ " \"https://huggingface.co/datasets/uermel/popsicle/resolve/main/\"\n",
134
+ " \"bacterial/Croissant/metadata.json\"\n",
135
+ ")\n",
136
+ "\n",
137
+ "root = copick.from_croissant(BACTERIAL_URL, static_fs_args={\"anon\": True})\n",
138
+ "\n",
139
+ "for split, run_names in root.splits.items():\n",
140
+ " print(f\"{split}: {len(run_names)} runs\")\n",
141
+ " for run in root.get_runs_in_split(split)[:3]:\n",
142
+ " seg_names = sorted({s.name for s in run.segmentations})\n",
143
+ " print(f\" {run.name}: {seg_names}\")\n"
144
+ ]
145
+ },
146
+ {
147
+ "cell_type": "code",
148
+ "execution_count": null,
149
+ "metadata": {},
150
+ "outputs": [],
151
+ "source": [
152
+ "# Visualize: midplane slice of one bacterial tomogram with seg overlays.\n",
153
+ "run = root.get_runs_in_split(\"train\")[0]\n",
154
+ "vs = run.voxel_spacings[0]\n",
155
+ "tomo = vs.tomograms[0]\n",
156
+ "arr = tomo.numpy()\n",
157
+ "z_mid = arr.shape[0] // 2\n",
158
+ "\n",
159
+ "fig, ax = plt.subplots(figsize=(8, 8))\n",
160
+ "ax.imshow(arr[z_mid], cmap=\"gray\")\n",
161
+ "cmap = plt.get_cmap(\"tab10\")\n",
162
+ "for i, seg in enumerate(run.segmentations):\n",
163
+ " mask = seg.numpy()[z_mid] # (Y, X) \u2014 same shape as the tomo slice\n",
164
+ " ax.imshow(\n",
165
+ " np.ma.masked_where(mask == 0, mask),\n",
166
+ " cmap=cmap, vmin=0, vmax=10, alpha=0.4, interpolation=\"none\",\n",
167
+ " )\n",
168
+ " ax.scatter([], [], color=cmap(i), label=seg.name)\n",
169
+ "ax.legend(loc=\"upper right\", fontsize=8)\n",
170
+ "ax.set_title(f\"{run.name} z={z_mid}\")\n",
171
+ "plt.show()\n"
172
+ ]
173
+ },
174
+ {
175
+ "cell_type": "markdown",
176
+ "metadata": {},
177
+ "source": [
178
+ "## Yeast \u2014 multi-class organelle segmentation\n",
179
+ "\n",
180
+ "Six organelle classes (cytoplasm, nucleus, nuclear-envelope,\n",
181
+ "vesicle, endomembrane, mitochondrion) on 20 *S. pombe* tomograms\n",
182
+ "split 16/4 train/test. Low-data, class-imbalanced eukaryotic\n",
183
+ "counterpart to the bacterial benchmark.\n"
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "code",
188
+ "execution_count": null,
189
+ "metadata": {},
190
+ "outputs": [],
191
+ "source": [
192
+ "import copick\n",
193
+ "import numpy as np\n",
194
+ "import matplotlib.pyplot as plt\n",
195
+ "\n",
196
+ "YEAST_URL = (\n",
197
+ " \"https://huggingface.co/datasets/uermel/popsicle/resolve/main/\"\n",
198
+ " \"yeast/Croissant/metadata.json\"\n",
199
+ ")\n",
200
+ "\n",
201
+ "root = copick.from_croissant(YEAST_URL, static_fs_args={\"anon\": True})\n",
202
+ "\n",
203
+ "for split, run_names in root.splits.items():\n",
204
+ " print(f\"{split}: {len(run_names)} runs\")\n",
205
+ " for run in root.get_runs_in_split(split)[:3]:\n",
206
+ " seg_names = sorted({s.name for s in run.segmentations})\n",
207
+ " print(f\" {run.name}: {seg_names}\")\n"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": null,
213
+ "metadata": {},
214
+ "outputs": [],
215
+ "source": [
216
+ "# Visualize: midplane slice of one yeast tomogram with organelle masks overlaid.\n",
217
+ "run = root.get_runs_in_split(\"train\")[0]\n",
218
+ "vs = run.voxel_spacings[0]\n",
219
+ "tomo = vs.tomograms[0]\n",
220
+ "arr = tomo.numpy()\n",
221
+ "z_mid = arr.shape[0] // 2\n",
222
+ "\n",
223
+ "fig, ax = plt.subplots(figsize=(8, 8))\n",
224
+ "ax.imshow(arr[z_mid], cmap=\"gray\")\n",
225
+ "cmap = plt.get_cmap(\"tab10\")\n",
226
+ "for i, seg in enumerate(run.segmentations):\n",
227
+ " mask = seg.numpy()[z_mid]\n",
228
+ " ax.imshow(\n",
229
+ " np.ma.masked_where(mask == 0, mask),\n",
230
+ " cmap=cmap, vmin=0, vmax=10, alpha=0.4, interpolation=\"none\",\n",
231
+ " )\n",
232
+ " ax.scatter([], [], color=cmap(i), label=seg.name)\n",
233
+ "ax.legend(loc=\"upper right\", fontsize=8)\n",
234
+ "ax.set_title(f\"{run.name} z={z_mid}\")\n",
235
+ "plt.show()\n"
236
+ ]
237
+ },
238
+ {
239
+ "cell_type": "markdown",
240
+ "metadata": {},
241
+ "source": [
242
+ "## MotorBench \ud83d\udea7 *(pending release)*\n",
243
+ "\n",
244
+ "The MotorBench Croissant manifest is generated by\n",
245
+ "`scripts/build_motorbench_croissant.py` once the underlying\n",
246
+ "annotation walks finish. Once published it can be loaded with the\n",
247
+ "same pattern \u2014 single class `flagellar-motor`, two splits\n",
248
+ "(`train`, `test`) keyed on deposition_id (CZCDP-10332 vs\n",
249
+ "CZCDP-10347):\n",
250
+ "\n",
251
+ "```python\n",
252
+ "MOTORBENCH_URL = (\n",
253
+ " \"https://huggingface.co/datasets/uermel/popsicle/resolve/main/\"\n",
254
+ " \"motorbench/Croissant/metadata.json\"\n",
255
+ ")\n",
256
+ "root = copick.from_croissant(MOTORBENCH_URL, static_fs_args={\"anon\": True})\n",
257
+ "```\n"
258
+ ]
259
+ }
260
+ ],
261
+ "metadata": {
262
+ "kernelspec": {
263
+ "display_name": "Python 3",
264
+ "language": "python",
265
+ "name": "python3"
266
+ },
267
+ "language_info": {
268
+ "name": "python",
269
+ "version": "3.10"
270
+ }
271
+ },
272
+ "nbformat": 4,
273
+ "nbformat_minor": 5
274
+ }