bobleesj commited on
Commit
8baf809
·
verified ·
1 Parent(s): a47ca22

docs(README): one-click Colab link, EMD-confirmed optics, sampling caveat

Browse files
Files changed (1) hide show
  1. README.md +38 -42
README.md CHANGED
@@ -10,54 +10,54 @@ pretty_name: quantem-data
10
 
11
  # quantem-data
12
 
13
- Reference electron-microscopy datasets for browsing and learning. Open them in your browser via [quantem.widget](https://github.com/bobleesj/quantem.widget) — **no quantem.live install needed**.
14
 
15
- Two buckets, that's it:
16
 
17
  - **`4dstem/`** — 4D-STEM acquisitions. `_npy_bin*` variants are pre-binned NumPy files for fast workshop / Colab demos; the originals are full Arina h5 bundles.
18
  - **`haadf/`** — HAADF survey images. `_npy` variants are pre-cooked NumPy + a `meta.json` sidecar carrying sampling + optics; the originals are full Velox EMD files.
19
 
20
- ## Workshop quick start Show4DSTEM (Google Colab or any Jupyter)
21
 
22
- Just `quantem.widget` from TestPyPI + `huggingface_hub`. No CUDA, no h5, no quantem.live.
 
 
 
 
 
 
23
 
24
  ```python
25
  !pip install -q --pre --extra-index-url https://test.pypi.org/simple/ quantem.widget huggingface_hub
 
26
 
27
  import os, json, numpy as np, torch
28
  from huggingface_hub import snapshot_download
 
29
  from quantem.widget import Show4DSTEM
30
 
31
- folder = snapshot_download(
32
- "bobleesj/quantem-data",
33
- repo_type="dataset",
34
- allow_patterns=["4dstem/gold_512_npy_bin8/*"],
35
- )
36
  asset = os.path.join(folder, "4dstem", "gold_512_npy_bin8")
37
- data = np.load(os.path.join(asset, "data.npy")) # (512, 512, 24, 24) uint16, ~300 MB
38
  meta = json.load(open(os.path.join(asset, "meta.json")))
39
 
40
- Show4DSTEM(torch.from_numpy(data), sampling=meta["sampling"], units=meta["units"])
 
 
41
  ```
42
 
43
- Drag the scan cursor in the real-space image; the CBED updates in real time. Chrome works best (WebGPU).
44
-
45
  ## Workshop quick start — Show2D for HAADF
46
 
47
- Same pattern; no Velox parser needed (the EMD has been pre-decoded to NumPy + a sampling sidecar).
48
-
49
  ```python
50
  import os, json, numpy as np, torch
51
  from huggingface_hub import snapshot_download
52
  from quantem.widget import Show2D
53
 
54
- folder = snapshot_download(
55
- "bobleesj/quantem-data",
56
- repo_type="dataset",
57
- allow_patterns=["haadf/gold_haadf_npy/*"],
58
- )
59
  asset = os.path.join(folder, "haadf", "gold_haadf_npy")
60
- img = np.load(os.path.join(asset, "data.npy")) # (4096, 4096) uint16
61
  meta = json.load(open(os.path.join(asset, "meta.json")))
62
 
63
  Show2D(torch.from_numpy(img), sampling=meta["sampling"], units=meta["units"])
@@ -65,16 +65,18 @@ Show2D(torch.from_numpy(img), sampling=meta["sampling"], units=meta["units"])
65
 
66
  ## Acquisition parameters
67
 
68
- | dataset | voltage | probe | scan | scan sampling | det pitch | mag | format |
 
 
69
  |---|---|---|---|---|---|---|---|
70
- | `haadf/gold_haadf_npy` | 300 kV | 30 mrad | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm | Velox EMD → NumPy |
71
- | `4dstem/gold_512_npy_bin8` | 200 kV | 30 mrad (op) | 512² | 0.5 Å (op) | 3.68 mrad/px | (unknown) | NumPy bundle |
72
- | `4dstem/gold_512_npy_bin4` | 200 kV | 30 mrad (op) | 512² | 0.5 Å (op) | 1.84 mrad/px | (unknown) | NumPy bundle |
73
- | `4dstem/gold_512` | 200 kV | 30 mrad (op) | 512² | 0.5 Å (op) | 0.46 mrad/px | (unknown) | Arina h5 |
74
- | `4dstem/gold_30mrad1.3mx04` `09` | 200 kV | 30 mrad | smaller | (session yaml) | 0.46 mrad/px | 1.3 Mx | Arina h5 |
75
- | `haadf/gold_haadf.emd` | 300 kV | 30 mrad | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm | Velox EMD |
76
 
77
- `(op)` = operator-supplied, not stored in the file. Arina h5 records detector + scan count but no optics; the optics live in the operator's session yaml. EMD carries full optics (BeamConvergence, CameraLength, AccelerationVoltage, pixel sizes).
78
 
79
  ## Datasets at a glance
80
 
@@ -82,44 +84,38 @@ Show2D(torch.from_numpy(img), sampling=meta["sampling"], units=meta["units"])
82
  |---|---|---|---|---|---|
83
  | `4dstem/gold_512_npy_bin8/` | NumPy bundle | (512, 512, 24, 24) | uint16 | ~302 MB | workshop / Colab demo |
84
  | `4dstem/gold_512_npy_bin4/` | NumPy bundle | (512, 512, 48, 48) | uint16 | ~1.2 GB | sharper workshop version |
85
- | `4dstem/gold_512/` | Arina h5 (full) | (512, 512, 192, 192) | uint16 | ~5 GB | power user |
86
- | `4dstem/gold_30mrad1.3mx04` … `09` | Arina h5 (full) | varies | uint16 | ~5 GB each | series demo |
87
  | `haadf/gold_haadf_npy/` | NumPy bundle | (4096, 4096) | uint16 | ~34 MB | workshop / Colab Show2D |
88
  | `haadf/gold_haadf.emd` | Velox EMD | (4096, 4096) | uint16 | a few MB | full optics carrier |
89
 
90
- Each `_npy*` bundle ships a `meta.json` next to `data.npy`: shape, dtype, sampling, units, plus voltage / probe / camera length / FOV when known.
91
 
92
  ## Power-user path (full data, GPU decompression)
93
 
94
- Have an NVIDIA GPU and want the full uncooked h5 / EMD? Install [`quantem.live`](https://github.com/bobleesj/quantem.live) — it carries a sampling-aware loader (`io.read_image` → `Dataset2d` → `Show2D` for HAADF; `io.load` for 4D-STEM):
95
 
96
  ```python
97
  from quantem.live import io
98
  from quantem.widget import Show4DSTEM, Show2D
99
  import torch
100
 
101
- # 4D-STEM, full Arina h5 → GPU
102
  folder = io.download("gold_512")
103
  result = io.load(io.discover_masters(folder)[0], det_bin=2)
104
  Show4DSTEM(torch.from_dlpack(result.data))
105
 
106
- # HAADF, full Velox EMD with sampling carried through
107
- ds = io.read_image(io.download("gold_haadf")) # → Dataset2d
108
- Show2D(ds) # sampling auto-picked
109
  ```
110
 
111
  ## Memory (VRAM) for the full h5
112
 
113
- The Arina h5 sets are 512×512×192×192. Peak VRAM is about 1.4× the loaded array; control with `det_bin`:
114
-
115
  | `det_bin` | detector | loaded | peak VRAM | fits 16 GB? |
116
  |---|---|---|---|---|
117
  | 1 | 192×192 | 18 GB | ~25 GB | no |
118
  | **2** | 96×96 | 4.5 GB | **~6.9 GB** | **yes** |
119
  | 4 | 48×48 | 1.1 GB | ~2.2 GB | yes |
120
- | 8 | 24×24 | 0.3 GB | ~0.5 GB | yes (good for flipping through many) |
121
-
122
- Show4DSTEM keeps the data on the GPU; cursor interaction is ~0.03 ms/frame.
123
 
124
  ## Licence
125
 
 
10
 
11
  # quantem-data
12
 
13
+ Reference electron-microscopy datasets for browsing and learning. Open in your browser via [quantem.widget](https://github.com/bobleesj/quantem.widget) — **no quantem.live install needed**.
14
 
15
+ Two buckets:
16
 
17
  - **`4dstem/`** — 4D-STEM acquisitions. `_npy_bin*` variants are pre-binned NumPy files for fast workshop / Colab demos; the originals are full Arina h5 bundles.
18
  - **`haadf/`** — HAADF survey images. `_npy` variants are pre-cooked NumPy + a `meta.json` sidecar carrying sampling + optics; the originals are full Velox EMD files.
19
 
20
+ A ready-to-run notebook sits at `notebooks/show4dstem_colab.ipynb` in this repo.
21
 
22
+ ## One-click workshop notebook (Google Colab)
23
+
24
+ [**▶ Open `show4dstem_colab.ipynb` in Colab**](https://colab.research.google.com/?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Fbobleesj%2Fquantem-data%2Fresolve%2Fmain%2Fnotebooks%2Fshow4dstem_colab.ipynb)
25
+
26
+ It does the full pipeline in 7 cells: install `quantem.widget` (TestPyPI rc) + `quantem` (dev fork branch), download the pre-binned NumPy bundle from this dataset, wrap it as `Dataset4dstem.from_tensor`, render with `Show4DSTEM` in your browser via WebGPU. No CUDA on Colab. No quantem.live.
27
+
28
+ ## Workshop quick start — Show4DSTEM (any Jupyter)
29
 
30
  ```python
31
  !pip install -q --pre --extra-index-url https://test.pypi.org/simple/ quantem.widget huggingface_hub
32
+ !pip install -q git+https://github.com/bobleesj/quantem.git@dataset-support-torch
33
 
34
  import os, json, numpy as np, torch
35
  from huggingface_hub import snapshot_download
36
+ from quantem.core.datastructures import Dataset4dstem
37
  from quantem.widget import Show4DSTEM
38
 
39
+ folder = snapshot_download("bobleesj/quantem-data", repo_type="dataset",
40
+ allow_patterns=["4dstem/gold_512_npy_bin8/*"])
 
 
 
41
  asset = os.path.join(folder, "4dstem", "gold_512_npy_bin8")
42
+ data = np.load(os.path.join(asset, "data.npy"))
43
  meta = json.load(open(os.path.join(asset, "meta.json")))
44
 
45
+ dset = Dataset4dstem.from_tensor(torch.from_numpy(data),
46
+ sampling=meta["sampling"], units=meta["units"])
47
+ Show4DSTEM(dset)
48
  ```
49
 
 
 
50
  ## Workshop quick start — Show2D for HAADF
51
 
 
 
52
  ```python
53
  import os, json, numpy as np, torch
54
  from huggingface_hub import snapshot_download
55
  from quantem.widget import Show2D
56
 
57
+ folder = snapshot_download("bobleesj/quantem-data", repo_type="dataset",
58
+ allow_patterns=["haadf/gold_haadf_npy/*"])
 
 
 
59
  asset = os.path.join(folder, "haadf", "gold_haadf_npy")
60
+ img = np.load(os.path.join(asset, "data.npy"))
61
  meta = json.load(open(os.path.join(asset, "meta.json")))
62
 
63
  Show2D(torch.from_numpy(img), sampling=meta["sampling"], units=meta["units"])
 
65
 
66
  ## Acquisition parameters
67
 
68
+ The 20260423 drift session's optics are **confirmed via the session's own HAADF EMD** (`AccelerationVoltage`, `BeamConvergence`, `CameraLength`). 4D-STEM `scan_sampling` is an **operator pattern from a sibling SSB session** — the drift acquisition itself was never per-file calibrated.
69
+
70
+ | dataset | voltage | probe | CL | scan | scan sampling | det pitch | mag |
71
  |---|---|---|---|---|---|---|---|
72
+ | `haadf/gold_haadf_npy` | 300 kV | 30 mrad | 91 mm ✓ | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm |
73
+ | `4dstem/gold_512_npy_bin8` | 300 kV | 30 mrad | 91 mm ✓ | 512² | 0.5 Å (op) | 3.68 mrad/px | unknown |
74
+ | `4dstem/gold_512_npy_bin4` | 300 kV | 30 mrad | 91 mm ✓ | 512² | 0.5 Å (op) | 1.84 mrad/px | unknown |
75
+ | `4dstem/gold_512` | 300 kV | 30 mrad | 91 mm ✓ | 512² | 0.5 Å (op) | 0.46 mrad/px | unknown |
76
+ | `4dstem/gold_30mrad1.3mx04`…`09` | 300 kV | 30 mrad | 91 mm | smaller | (session yaml) | 0.46 mrad/px | 1.3 Mx |
77
+ | `haadf/gold_haadf.emd` | 300 kV | 30 mrad | 91 mm ✓ | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm |
78
 
79
+ ✓ = confirmed via EMD/yaml. `(op)` = operator pattern, not file-certified.
80
 
81
  ## Datasets at a glance
82
 
 
84
  |---|---|---|---|---|---|
85
  | `4dstem/gold_512_npy_bin8/` | NumPy bundle | (512, 512, 24, 24) | uint16 | ~302 MB | workshop / Colab demo |
86
  | `4dstem/gold_512_npy_bin4/` | NumPy bundle | (512, 512, 48, 48) | uint16 | ~1.2 GB | sharper workshop version |
87
+ | `4dstem/gold_512/` | Arina h5 | (512, 512, 192, 192) | uint16 | ~5 GB | power user |
88
+ | `4dstem/gold_30mrad1.3mx04` … `09` | Arina h5 | varies | uint16 | ~5 GB each | series demo |
89
  | `haadf/gold_haadf_npy/` | NumPy bundle | (4096, 4096) | uint16 | ~34 MB | workshop / Colab Show2D |
90
  | `haadf/gold_haadf.emd` | Velox EMD | (4096, 4096) | uint16 | a few MB | full optics carrier |
91
 
92
+ Each `_npy*` bundle ships a `meta.json` next to `data.npy`: shape, dtype, sampling, units, voltage / probe / CL (with provenance flags) when known.
93
 
94
  ## Power-user path (full data, GPU decompression)
95
 
96
+ Got an NVIDIA GPU and want the full Arina h5 / Velox EMD path? Install [`quantem.live`](https://github.com/bobleesj/quantem.live):
97
 
98
  ```python
99
  from quantem.live import io
100
  from quantem.widget import Show4DSTEM, Show2D
101
  import torch
102
 
 
103
  folder = io.download("gold_512")
104
  result = io.load(io.discover_masters(folder)[0], det_bin=2)
105
  Show4DSTEM(torch.from_dlpack(result.data))
106
 
107
+ ds = io.read_image(io.download("gold_haadf"))
108
+ Show2D(ds)
 
109
  ```
110
 
111
  ## Memory (VRAM) for the full h5
112
 
 
 
113
  | `det_bin` | detector | loaded | peak VRAM | fits 16 GB? |
114
  |---|---|---|---|---|
115
  | 1 | 192×192 | 18 GB | ~25 GB | no |
116
  | **2** | 96×96 | 4.5 GB | **~6.9 GB** | **yes** |
117
  | 4 | 48×48 | 1.1 GB | ~2.2 GB | yes |
118
+ | 8 | 24×24 | 0.3 GB | ~0.5 GB | yes |
 
 
119
 
120
  ## Licence
121