{ "cells": [ { "cell_type": "markdown", "id": "9974e82c-795b-4f44-9ed0-1d539b1a71de", "metadata": {}, "source": [ "# Exploring slices of stacks by plotting corresponding data\n", "In this notebook we will explore a stack of images using an interactive scatterplot of measurements that were done on the individual slices of the stack. For demonstration purposes, we explore a stack of teaching slides an embedding generated using large language models." ] }, { "cell_type": "code", "execution_count": 1, "id": "24a3041b-56b1-4f44-ad18-9b06c5eb62b6", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import stackview\n", "import os\n", "import numpy as np\n", "from skimage.io import imread\n", "import yaml\n", "import requests\n", "import zipfile\n" ] }, { "cell_type": "markdown", "id": "e0e5c014-8e9d-47cf-a23e-668d80c9a7d7", "metadata": {}, "source": [ "First, we download [the dataset](https://zenodo.org/records/14030307), which is licensed [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/) by Robert Haase." ] }, { "cell_type": "code", "execution_count": 2, "id": "3ae7e89b-79cb-43a0-948d-49a7b5bfb32a", "metadata": {}, "outputs": [], "source": [ "# URL of the zip file\n", "url = \"https://zenodo.org/records/14030307/files/png_umap.zip?download=1\"\n", "# Save the zip file locally\n", "zip_path = \"png_umap.zip\"\n", "\n", "if not os.path.exists(zip_path):\n", " # Download the zip file\n", " response = requests.get(url)\n", " with open(zip_path, \"wb\") as f:\n", " f.write(response.content)\n", " \n", " # Extract the contents\n", " with zipfile.ZipFile(zip_path, 'r') as zip_ref:\n", " zip_ref.extractall()\n", "\n", "# Optionally, remove the zip file after extraction\n", "#os.remove(zip_path)" ] }, { "cell_type": "code", "execution_count": 3, "id": "dd5f83a7-f774-4d3e-871a-429775be7c55", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | UMAP0 | \n", "UMAP1 | \n", "filename | \n", "page_index | \n", "png_filename | \n", "text | \n", "url | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "2.785299 | \n", "5.125338 | \n", "12623730_14_Summary.pdf | \n", "0 | \n", "12623730_14_Summary_0.png | \n", "Robert Haase\\n@haesleinhuepf\\nBIDS Lecture 14/... | \n", "https://zenodo.org/api/records/12623730/files/... | \n", "
| 1 | \n", "1.759109 | \n", "5.196022 | \n", "12623730_14_Summary.pdf | \n", "1 | \n", "12623730_14_Summary_1.png | \n", "Robert Haase\\n@haesleinhuepf\\nBIDS Lecture 14/... | \n", "https://zenodo.org/api/records/12623730/files/... | \n", "
| 2 | \n", "1.605859 | \n", "6.084491 | \n", "12623730_14_Summary.pdf | \n", "2 | \n", "12623730_14_Summary_2.png | \n", "Robert Haase\\n@haesleinhuepf\\nBIDS Lecture 14/... | \n", "https://zenodo.org/api/records/12623730/files/... | \n", "
| 3 | \n", "1.581907 | \n", "6.084695 | \n", "12623730_14_Summary.pdf | \n", "3 | \n", "12623730_14_Summary_3.png | \n", "Robert Haase\\n@haesleinhuepf\\nBIDS Lecture 14/... | \n", "https://zenodo.org/api/records/12623730/files/... | \n", "
| 4 | \n", "2.163119 | \n", "7.161102 | \n", "12623730_14_Summary.pdf | \n", "4 | \n", "12623730_14_Summary_4.png | \n", "Robert Haase\\n@haesleinhuepf\\nBIDS Lecture 14/... | \n", "https://zenodo.org/api/records/12623730/files/... | \n", "