bobleesj commited on
Commit
b617ca2
·
verified ·
1 Parent(s): 476c1a7

docs: document widget-tutorials layout; retarget notebooks to it

Browse files
README.md CHANGED
@@ -25,10 +25,18 @@ from quantem.widget.datasets import show4dstem_gold
25
  Show4DSTEM(show4dstem_gold())
26
  ```
27
 
28
- Layout: `4dstem/` holds Arina h5 originals plus pre-binned `_npy_bin*` NumPy
29
- bundles; `haadf/` holds Velox EMD originals plus `_npy` bundles. Every `_npy*`
30
- bundle ships a `meta.json` (shape, dtype, sampling, units, optics) next to
31
- `data.npy`.
 
 
 
 
 
 
 
 
32
 
33
  Workshop notebooks (Google Colab, no local install):
34
  [Show4DSTEM demo](https://colab.research.google.com/gist/bobleesj/54864ce5b2a6f0a4fd5ae1e5d5719b45/show4dstem_colab.ipynb)
 
25
  Show4DSTEM(show4dstem_gold())
26
  ```
27
 
28
+ Layout two trees:
29
+
30
+ - **`widget-tutorials/<widget>/<dataset>/<size>/`** baseline tutorial
31
+ bundles for the core widgets (`show1d/`, `show4dstem/`, `showfolder/`;
32
+ data shared by Show2D and Show3D lives under `shared/`). These back the
33
+ one-call loaders in `quantem.widget.datasets` and the Colab workshops.
34
+ Baseline tutorials only — real work uses your own data.
35
+ - **`4dstem/`, `haadf/`** — full-size originals (Arina h5, Velox EMD) for
36
+ power users.
37
+
38
+ Every NumPy bundle ships a `meta.json` (shape, dtype, sampling, units,
39
+ optics) next to `data.npy`.
40
 
41
  Workshop notebooks (Google Colab, no local install):
42
  [Show4DSTEM demo](https://colab.research.google.com/gist/bobleesj/54864ce5b2a6f0a4fd5ae1e5d5719b45/show4dstem_colab.ipynb)
notebooks/show4dstem_colab.ipynb CHANGED
@@ -2,65 +2,107 @@
2
  "cells": [
3
  {
4
  "cell_type": "markdown",
5
- "metadata": {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  "source": [
7
  "# Show4DSTEM in Google Colab\n",
8
  "\n",
9
  "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Fbobleesj%2Fquantem-data%2Fresolve%2Fmain%2Fnotebooks%2Fshow4dstem_colab.ipynb)\n",
10
  "\n",
11
  "Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. Runs on Colab's\n",
12
- "Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. On Colab's free **Tesla T4**, Show4DSTEM runs on the **GPU via PyTorch (CUDA)** - NumPy is only the input format; it is uploaded to the GPU. (On a CPU-only runtime it falls back to CPU.)\n",
13
  "any runtime (CPU or GPU).\n"
14
- ]
 
15
  },
16
  {
17
  "cell_type": "markdown",
18
- "metadata": {},
 
 
19
  "source": [
20
  "## 1. Install (one cell)\n"
21
- ]
 
22
  },
23
  {
24
  "cell_type": "code",
25
  "execution_count": null,
26
- "metadata": {},
 
 
27
  "outputs": [],
28
  "source": [
29
  "!pip install -U -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \"quantem.widget>=0.0.1rc0\" huggingface_hub\n"
30
- ]
 
31
  },
32
  {
33
  "cell_type": "markdown",
34
- "metadata": {},
 
 
35
  "source": [
36
  "## 2. Download a sample + open it\n"
37
- ]
 
38
  },
39
  {
40
  "cell_type": "code",
41
  "execution_count": null,
42
- "metadata": {},
 
 
43
  "outputs": [],
44
  "source": [
45
  "import numpy as np\n",
46
  "from quantem.widget import Show4DSTEM\n",
47
- "from quantem.widget.io import download\n",
48
  "\n",
49
- "path = download('gold_512_npy_bin4') # ~25 MB from Hugging Face\n",
50
- "data = np.load(f'{path}/data.npy') # (512, 512, 48, 48) 4D-STEM\n",
 
 
51
  "Show4DSTEM(data)\n"
52
- ]
 
53
  },
54
  {
55
  "cell_type": "markdown",
56
- "metadata": {},
 
 
57
  "source": [
58
  "**Interact:** drag the detector ROI (left) -> the virtual image (right) updates live.\n",
59
  "Drag the scan cursor on the virtual image -> the diffraction pattern follows your finger.\n",
60
  "\n",
61
  "To use your own data, upload an Arina `*_master.h5` and run\n",
62
  "`Show4DSTEM(load('your_master.h5', det_bin=2))` (`from quantem.widget import load`).\n"
63
- ]
 
64
  }
65
  ],
66
  "metadata": {
@@ -75,7 +117,8 @@
75
  "accelerator": "GPU",
76
  "colab": {
77
  "provenance": [],
78
- "gpuType": "T4"
 
79
  }
80
  },
81
  "nbformat": 4,
 
2
  "cells": [
3
  {
4
  "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "view-in-github",
7
+ "colab_type": "text"
8
+ },
9
+ "source": [
10
+ "<a href=\"https://colab.research.google.com/gist/bobleesj/54864ce5b2a6f0a4fd5ae1e5d5719b45/show4dstem_colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "source": [
16
+ "\n"
17
+ ],
18
+ "metadata": {
19
+ "id": "9v3stk4rtjWV"
20
+ },
21
+ "id": "9v3stk4rtjWV",
22
+ "execution_count": null,
23
+ "outputs": []
24
+ },
25
+ {
26
+ "cell_type": "markdown",
27
+ "metadata": {
28
+ "id": "UFA9PcrTth-d"
29
+ },
30
  "source": [
31
  "# Show4DSTEM in Google Colab\n",
32
  "\n",
33
  "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Fbobleesj%2Fquantem-data%2Fresolve%2Fmain%2Fnotebooks%2Fshow4dstem_colab.ipynb)\n",
34
  "\n",
35
  "Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. Runs on Colab's\n",
36
+ "free runtime. Backend auto-detects; this sample uses the CPU/numpy path so it works on\n",
37
  "any runtime (CPU or GPU).\n"
38
+ ],
39
+ "id": "UFA9PcrTth-d"
40
  },
41
  {
42
  "cell_type": "markdown",
43
+ "metadata": {
44
+ "id": "kf5G4BjLth-e"
45
+ },
46
  "source": [
47
  "## 1. Install (one cell)\n"
48
+ ],
49
+ "id": "kf5G4BjLth-e"
50
  },
51
  {
52
  "cell_type": "code",
53
  "execution_count": null,
54
+ "metadata": {
55
+ "id": "IdKh-J1Vth-f"
56
+ },
57
  "outputs": [],
58
  "source": [
59
  "!pip install -U -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \"quantem.widget>=0.0.1rc0\" huggingface_hub\n"
60
+ ],
61
+ "id": "IdKh-J1Vth-f"
62
  },
63
  {
64
  "cell_type": "markdown",
65
+ "metadata": {
66
+ "id": "FWyzquw4th-f"
67
+ },
68
  "source": [
69
  "## 2. Download a sample + open it\n"
70
+ ],
71
+ "id": "FWyzquw4th-f"
72
  },
73
  {
74
  "cell_type": "code",
75
  "execution_count": null,
76
+ "metadata": {
77
+ "id": "nbE-phyvth-f"
78
+ },
79
  "outputs": [],
80
  "source": [
81
  "import numpy as np\n",
82
  "from quantem.widget import Show4DSTEM\n",
83
+ "from huggingface_hub import snapshot_download\n",
84
  "\n",
85
+ "root = snapshot_download(\"bobleesj/quantem-data\", repo_type=\"dataset\",\n",
86
+ " allow_patterns=[\"widget-tutorials/show4dstem/gold-512-bin4/full/*\"])\n",
87
+ "path = f\"{root}/widget-tutorials/show4dstem/gold-512-bin4/full\"\n",
88
+ "data = np.load(f\"{path}/data.npy\") # (512, 512, 48, 48) uint16, ~1.2 GB\n",
89
  "Show4DSTEM(data)\n"
90
+ ],
91
+ "id": "nbE-phyvth-f"
92
  },
93
  {
94
  "cell_type": "markdown",
95
+ "metadata": {
96
+ "id": "dBHvEtxJth-f"
97
+ },
98
  "source": [
99
  "**Interact:** drag the detector ROI (left) -> the virtual image (right) updates live.\n",
100
  "Drag the scan cursor on the virtual image -> the diffraction pattern follows your finger.\n",
101
  "\n",
102
  "To use your own data, upload an Arina `*_master.h5` and run\n",
103
  "`Show4DSTEM(load('your_master.h5', det_bin=2))` (`from quantem.widget import load`).\n"
104
+ ],
105
+ "id": "dBHvEtxJth-f"
106
  }
107
  ],
108
  "metadata": {
 
117
  "accelerator": "GPU",
118
  "colab": {
119
  "provenance": [],
120
+ "gpuType": "T4",
121
+ "include_colab_link": true
122
  }
123
  },
124
  "nbformat": 4,
notebooks/widget_4dstem_demo.ipynb CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fab32053ffb7a128c450b55ad2a0f72832092fe86f9c0402acd92c3698422b5c
3
- size 14104741
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2adc9b05447b74492c68b2fddf1d908771479c1bc6b625d9eb7267a60c4f1cf2
3
+ size 14104794