{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "introduction",
   "metadata": {},
   "source": [
    "# Open and navigate an export\n",
    "\n",
    "This notebook downloads a small synthetic v2 export so you can run every cell immediately. When you are ready to analyze your own data, change `PROJECT_FILE` to the path of your NeuroQP ZIP."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "imports-and-sample",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "from urllib.request import urlretrieve\n",
    "\n",
    "from neuroqp import open_export\n",
    "\n",
    "PROJECT_FILE = Path(\"neuroqp-example-v2.zip\")  # Change this to your own project export.\n",
    "EXAMPLE_URL = (\n",
    "    \"https://raw.githubusercontent.com/neuroqp/neuroqp-python/\"\n",
    "    \"bc913cd/docs/assets/downloads/neuroqp-example-v2.zip\"\n",
    ")\n",
    "if not PROJECT_FILE.is_file():\n",
    "    urlretrieve(EXAMPLE_URL, PROJECT_FILE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "object-navigation",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open_export(PROJECT_FILE) as export:\n",
    "    project_summary = export\n",
    "    animal = export.animals[0]\n",
    "    slice_ = animal.slices[0]\n",
    "    image = slice_.images[0]\n",
    "\n",
    "project_summary, animal, slice_, image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "tabular-summary",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open_export(PROJECT_FILE) as export:\n",
    "    rows = [\n",
    "        (slice_.name, image.staining.name, image.metadata.original_filename)\n",
    "        for slice_ in export.slices\n",
    "        for image in slice_.images\n",
    "    ]\n",
    "\n",
    "rows"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
