File size: 3,378 Bytes
a47ca22 b617ca2 a47ca22 12c36b8 a47ca22 12c36b8 a47ca22 12c36b8 b617ca2 12c36b8 b617ca2 a47ca22 12c36b8 b617ca2 a47ca22 12c36b8 b617ca2 a47ca22 b617ca2 a47ca22 a320d81 b617ca2 a47ca22 12c36b8 b617ca2 a47ca22 12c36b8 b617ca2 a47ca22 b617ca2 a47ca22 12c36b8 a47ca22 b617ca2 a47ca22 b617ca2 12c36b8 b617ca2 a47ca22 b617ca2 a47ca22 12c36b8 a47ca22 12c36b8 b617ca2 a47ca22 12c36b8 a47ca22 12c36b8 96edd0a b617ca2 a47ca22 12c36b8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | {
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<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>"
]
},
{
"cell_type": "code",
"source": [
"\n"
],
"metadata": {
"id": "9v3stk4rtjWV"
},
"id": "9v3stk4rtjWV",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "UFA9PcrTth-d"
},
"source": [
"# Show4DSTEM in Google Colab\n",
"\n",
"[](https://colab.research.google.com/?url=https%3A%2F%2Fhuggingface.co%2Fdatasets%2Fbobleesj%2Fquantem-data%2Fresolve%2Fmain%2Fnotebooks%2Fshow4dstem_colab.ipynb)\n",
"\n",
"Open a 4D-STEM dataset in your browser - **no install, no GPU setup**. Runs on Colab's\n",
"free runtime. Backend auto-detects; this sample uses the CPU/numpy path so it works on\n",
"any runtime (CPU or GPU).\n"
],
"id": "UFA9PcrTth-d"
},
{
"cell_type": "markdown",
"metadata": {
"id": "kf5G4BjLth-e"
},
"source": [
"## 1. Install (one cell)\n"
],
"id": "kf5G4BjLth-e"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "IdKh-J1Vth-f"
},
"outputs": [],
"source": [
"!pip install -U -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple \"quantem.widget>=0.0.1rc0\" huggingface_hub\n"
],
"id": "IdKh-J1Vth-f"
},
{
"cell_type": "markdown",
"metadata": {
"id": "FWyzquw4th-f"
},
"source": [
"## 2. Download a sample + open it\n"
],
"id": "FWyzquw4th-f"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nbE-phyvth-f"
},
"outputs": [],
"source": [
"import numpy as np\n",
"from quantem.widget import Show4DSTEM\n",
"from huggingface_hub import snapshot_download\n",
"\n",
"root = snapshot_download(\"bobleesj/quantem-data\", repo_type=\"dataset\",\n",
" allow_patterns=[\"widget-tutorials/show4dstem/gold-512-bin4/full/*\"])\n",
"path = f\"{root}/widget-tutorials/show4dstem/gold-512-bin4/full\"\n",
"data = np.load(f\"{path}/data.npy\") # (512, 512, 48, 48) uint16, ~1.2 GB\n",
"Show4DSTEM(data)\n"
],
"id": "nbE-phyvth-f"
},
{
"cell_type": "markdown",
"metadata": {
"id": "dBHvEtxJth-f"
},
"source": [
"**Interact:** drag the detector ROI (left) -> the virtual image (right) updates live.\n",
"Drag the scan cursor on the virtual image -> the diffraction pattern follows your finger.\n",
"\n",
"To use your own data, upload an Arina `*_master.h5` and run\n",
"`Show4DSTEM(load('your_master.h5', det_bin=2))` (`from quantem.widget import load`).\n"
],
"id": "dBHvEtxJth-f"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"colab": {
"provenance": [],
"gpuType": "T4",
"include_colab_link": true
}
},
"nbformat": 4,
"nbformat_minor": 5
} |