docs(README): one-click Colab link, EMD-confirmed optics, sampling caveat
Browse files
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
|
| 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 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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"))
|
| 38 |
meta = json.load(open(os.path.join(asset, "meta.json")))
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 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"))
|
| 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 |
-
|
|
|
|
|
|
|
| 69 |
|---|---|---|---|---|---|---|---|
|
| 70 |
-
| `haadf/gold_haadf_npy` | 300 kV | 30 mrad | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm |
|
| 71 |
-
| `4dstem/gold_512_npy_bin8` |
|
| 72 |
-
| `4dstem/gold_512_npy_bin4` |
|
| 73 |
-
| `4dstem/gold_512` |
|
| 74 |
-
| `4dstem/gold_30mrad1.3mx04`
|
| 75 |
-
| `haadf/gold_haadf.emd` | 300 kV | 30 mrad | 4096² image | 0.0186 nm/px | n/a | FOV 76.2 nm |
|
| 76 |
|
| 77 |
-
`(op)` = operator
|
| 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
|
| 86 |
-
| `4dstem/gold_30mrad1.3mx04` … `09` | Arina h5
|
| 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,
|
| 91 |
|
| 92 |
## Power-user path (full data, GPU decompression)
|
| 93 |
|
| 94 |
-
|
| 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 |
-
|
| 107 |
-
|
| 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
|
| 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 |
|