docs(README): add HAADF npy workshop flow + acquisition params table
Browse files
README.md
CHANGED
|
@@ -15,11 +15,11 @@ Reference electron-microscopy datasets for browsing and learning. Open them in y
|
|
| 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.
|
| 19 |
|
| 20 |
-
##
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
```python
|
| 25 |
!pip install -q --pre --extra-index-url https://test.pypi.org/simple/ quantem.widget huggingface_hub
|
|
@@ -28,50 +28,85 @@ import os, json, numpy as np, torch
|
|
| 28 |
from huggingface_hub import snapshot_download
|
| 29 |
from quantem.widget import Show4DSTEM
|
| 30 |
|
| 31 |
-
# Pre-binned NumPy bundle — fast download, no decompression needed.
|
| 32 |
folder = snapshot_download(
|
| 33 |
"bobleesj/quantem-data",
|
| 34 |
repo_type="dataset",
|
| 35 |
allow_patterns=["4dstem/gold_512_npy_bin8/*"],
|
| 36 |
)
|
| 37 |
asset = os.path.join(folder, "4dstem", "gold_512_npy_bin8")
|
| 38 |
-
data = np.load(os.path.join(asset, "data.npy"))
|
| 39 |
-
meta = json.load(open(os.path.join(asset, "meta.json")))
|
| 40 |
|
| 41 |
Show4DSTEM(torch.from_numpy(data), sampling=meta["sampling"], units=meta["units"])
|
| 42 |
```
|
| 43 |
|
| 44 |
Drag the scan cursor in the real-space image; the CBED updates in real time. Chrome works best (WebGPU).
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
| name | kind | shape | dtype | size | use |
|
| 51 |
|---|---|---|---|---|---|
|
| 52 |
| `4dstem/gold_512_npy_bin8/` | NumPy bundle | (512, 512, 24, 24) | uint16 | ~302 MB | workshop / Colab demo |
|
| 53 |
-
| `4dstem/gold_512_npy_bin4/` | NumPy bundle | (512, 512, 48, 48) | uint16 | ~1.2 GB | sharper version |
|
| 54 |
-
| `4dstem/gold_512/` | Arina h5 (full) | (512, 512, 192, 192) | uint16 | ~5 GB | power user
|
| 55 |
-
| `4dstem/gold_30mrad1.3mx04` …`09` | Arina h5 (full) |
|
| 56 |
-
| `haadf/
|
|
|
|
| 57 |
|
| 58 |
-
Each `
|
| 59 |
|
| 60 |
## Power-user path (full data, GPU decompression)
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
```python
|
| 65 |
from quantem.live import io
|
| 66 |
-
from quantem.widget import Show4DSTEM
|
| 67 |
import torch
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
Show4DSTEM(torch.from_dlpack(result.data))
|
| 72 |
-
```
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
## Memory (VRAM) for the full h5
|
| 77 |
|
|
|
|
| 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
|
|
|
|
| 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"])
|
| 64 |
+
```
|
| 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 |
|
| 81 |
| name | kind | shape | dtype | size | use |
|
| 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 |
|