{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "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", "[![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", "\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 }