{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Draw 2D heatmaps as density isolines.\n", "\n", "This notebook does not actually use `histoquant` and relies only on [brainglobe-heatmap](https://brainglobe.info/documentation/brainglobe-heatmap/index.html) to extract brain structures outlines.\n", "\n", "Only the detections measurements with atlas coordinates exported from QuPath are used.\n", "\n", "You need to select the range of data to be used, the regions outlines will be extracted at the centroid of that range. Therefore, a range that is too large will be misleading and irrelevant." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import brainglobe_heatmap as bgh\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# path to the exported measurements from QuPath\n", "filename = \"../../resources/cells_measurements_detections.tsv\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Settings" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# atlas to use\n", "atlas_name = \"allen_mouse_10um\"\n", "# brain regions whose outlines will be plotted\n", "regions = [\"root\", \"CB\", \"MY\", \"GRN\", \"IRN\"]\n", "# range to include, in Allen coordinates, in microns\n", "ap_lims = [9800, 10000] # lims : [0, 13200] for coronal\n", "ml_lims = [5600, 5800] # lims : [0, 11400] for sagittal\n", "dv_lims = [3900, 4100] # lims : [0, 8000] for top\n", "# number of isolines\n", "nlevels = 5\n", "# color mapping between classification and matplotlib color\n", "palette = {\"Cells: marker-\": \"#d8782f\", \"Cells: marker+\": \"#8ccb73\"}" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", " | Image | \n", "Object ID | \n", "Object type | \n", "Name | \n", "Classification | \n", "Parent | \n", "ROI | \n", "Atlas_X | \n", "Atlas_Y | \n", "Atlas_Z | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "animalid0_030.ome.tiff | \n", "5ff386a8-5abd-46d1-8e0d-f5c5365457c1 | \n", "Detection | \n", "NaN | \n", "Cells: marker- | \n", "VeCB | \n", "Polygon | \n", "11.5230 | \n", "4.2724 | \n", "4.2767 | \n", "
1 | \n", "animalid0_030.ome.tiff | \n", "9a2a9a8c-acbe-4308-bc5e-f3c9fd1754c0 | \n", "Detection | \n", "NaN | \n", "Cells: marker- | \n", "VeCB | \n", "Polygon | \n", "11.5202 | \n", "4.2784 | \n", "4.4186 | \n", "
2 | \n", "animalid0_030.ome.tiff | \n", "481a519b-8b40-4450-9ec6-725181807d72 | \n", "Detection | \n", "NaN | \n", "Cells: marker- | \n", "VeCB | \n", "Polygon | \n", "11.5060 | \n", "4.3172 | \n", "4.3563 | \n", "
3 | \n", "animalid0_030.ome.tiff | \n", "fd28e09c-2c64-4750-b026-cd99e3526a57 | \n", "Detection | \n", "NaN | \n", "Cells: marker- | \n", "VeCB | \n", "Polygon | \n", "11.5284 | \n", "4.2574 | \n", "4.3364 | \n", "
4 | \n", "animalid0_030.ome.tiff | \n", "3d9ce034-f2ed-4c73-99be-f782363cf323 | \n", "Detection | \n", "NaN | \n", "Cells: marker- | \n", "VeCB | \n", "Polygon | \n", "11.5487 | \n", "4.2033 | \n", "4.2943 | \n", "