{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "32653374-08ba-4390-8830-4d6c9413b6fe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:20.527941Z",
     "iopub.status.busy": "2024-11-18T21:26:20.527163Z",
     "iopub.status.idle": "2024-11-18T21:26:20.553961Z",
     "shell.execute_reply": "2024-11-18T21:26:20.551578Z",
     "shell.execute_reply.started": "2024-11-18T21:26:20.527868Z"
    }
   },
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c8930546-1827-496d-98a8-264f4c97a2cc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:20.555450Z",
     "iopub.status.busy": "2024-11-18T21:26:20.555137Z",
     "iopub.status.idle": "2024-11-18T21:26:26.663946Z",
     "shell.execute_reply": "2024-11-18T21:26:26.662988Z",
     "shell.execute_reply.started": "2024-11-18T21:26:20.555420Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/santiago/Software/bat_detectors/batdetect2/.venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "from pathlib import Path\n",
    "from typing import List\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pytest\n",
    "from batdetect2.compat.data import load_annotation_project\n",
    "from batdetect2.compat.params import get_training_preprocessing_config\n",
    "from batdetect2.train.preprocess import generate_train_example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5af8d5fd-58a8-4034-b92d-0514cd987eaf",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:26.665630Z",
     "iopub.status.busy": "2024-11-18T21:26:26.664900Z",
     "iopub.status.idle": "2024-11-18T21:26:26.735198Z",
     "shell.execute_reply": "2024-11-18T21:26:26.734346Z",
     "shell.execute_reply.started": "2024-11-18T21:26:26.665601Z"
    }
   },
   "outputs": [],
   "source": [
    "regression_dir = Path(\"../tests/data/regression/\")\n",
    "example_audio_dir = Path(\"../example_data/audio/\")\n",
    "example_audio_files = list(example_audio_dir.glob(\"*.wav\"))\n",
    "example_anns_dir = Path(\"../example_data/anns/\")\n",
    "\n",
    "audio_file = example_audio_files[0]\n",
    "example_file = regression_dir / f\"{audio_file.name}.npz\"\n",
    "\n",
    "dataset = np.load(example_file)\n",
    "\n",
    "spec = dataset[\"spec\"][0]\n",
    "detection_mask = dataset[\"detection_mask\"][0]\n",
    "size_mask = dataset[\"size_mask\"]\n",
    "class_mask = dataset[\"class_mask\"]\n",
    "\n",
    "project = load_annotation_project(\n",
    "    example_anns_dir,\n",
    "    audio_dir=example_audio_dir,\n",
    ")\n",
    "\n",
    "clip_annotation = next(\n",
    "    ann for ann in project.clip_annotations if ann.clip.recording.path == audio_file\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b7b069a3-995f-4e73-8886-d1ce2202f5a5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:26.736224Z",
     "iopub.status.busy": "2024-11-18T21:26:26.735953Z",
     "iopub.status.idle": "2024-11-18T21:26:26.767802Z",
     "shell.execute_reply": "2024-11-18T21:26:26.766909Z",
     "shell.execute_reply.started": "2024-11-18T21:26:26.736200Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clip_annotation.clip.duration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "62c23365-8660-4ffb-b987-9131d6af6718",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:26.769444Z",
     "iopub.status.busy": "2024-11-18T21:26:26.768777Z",
     "iopub.status.idle": "2024-11-18T21:26:26.806659Z",
     "shell.execute_reply": "2024-11-18T21:26:26.805641Z",
     "shell.execute_reply.started": "2024-11-18T21:26:26.769415Z"
    }
   },
   "outputs": [],
   "source": [
    "old_parameters = json.loads((regression_dir / \"params.json\").read_text())\n",
    "config = get_training_preprocessing_config(old_parameters)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2f244732-fa11-4042-8043-c8f9268a55a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:26.810985Z",
     "iopub.status.busy": "2024-11-18T21:26:26.810570Z",
     "iopub.status.idle": "2024-11-18T21:26:26.846914Z",
     "shell.execute_reply": "2024-11-18T21:26:26.845654Z",
     "shell.execute_reply.started": "2024-11-18T21:26:26.810945Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SpecSizeConfig(height=256, resize_factor=0.5, divide_factor=32)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "config.preprocessing.spectrogram.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "641433fb-3d19-44df-8902-b0e0208b2013",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:26.849480Z",
     "iopub.status.busy": "2024-11-18T21:26:26.848511Z",
     "iopub.status.idle": "2024-11-18T21:26:27.390760Z",
     "shell.execute_reply": "2024-11-18T21:26:27.389986Z",
     "shell.execute_reply.started": "2024-11-18T21:26:26.849438Z"
    }
   },
   "outputs": [],
   "source": [
    "new_dataset = generate_train_example(clip_annotation, config)\n",
    "new_spec = new_dataset[\"spectrogram\"].values\n",
    "new_detection_mask = new_dataset[\"detection\"].values\n",
    "new_size_mask = new_dataset[\"size\"].values\n",
    "new_class_mask = new_dataset[\"class\"].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "502d25c1-0924-4a9f-8676-5a68cbd6c3af",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:27.391967Z",
     "iopub.status.busy": "2024-11-18T21:26:27.391628Z",
     "iopub.status.idle": "2024-11-18T21:26:27.426737Z",
     "shell.execute_reply": "2024-11-18T21:26:27.426148Z",
     "shell.execute_reply.started": "2024-11-18T21:26:27.391935Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(128, 512)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_spec.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "185f8b4e-bfcb-447f-9097-845fbd69ba6f",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:27.428183Z",
     "iopub.status.busy": "2024-11-18T21:26:27.427611Z",
     "iopub.status.idle": "2024-11-18T21:26:27.468561Z",
     "shell.execute_reply": "2024-11-18T21:26:27.467552Z",
     "shell.execute_reply.started": "2024-11-18T21:26:27.428145Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "html[data-theme=dark],\n",
       "body[data-theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-index-preview {\n",
       "  grid-column: 2 / 5;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data,\n",
       ".xr-index-data-in:checked ~ .xr-index-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-index-name div,\n",
       ".xr-index-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data,\n",
       ".xr-index-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2,\n",
       ".xr-no-icon {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;category&#x27; (category: 17)&gt; Size: 2kB\n",
       "array([&#x27;Barbastellus barbastellus&#x27;, &#x27;Eptesicus serotinus&#x27;, &#x27;Myotis alcathoe&#x27;,\n",
       "       &#x27;Myotis bechsteinii&#x27;, &#x27;Myotis brandtii&#x27;, &#x27;Myotis daubentonii&#x27;,\n",
       "       &#x27;Myotis mystacinus&#x27;, &#x27;Myotis nattereri&#x27;, &#x27;Nyctalus leisleri&#x27;,\n",
       "       &#x27;Nyctalus noctula&#x27;, &#x27;Pipistrellus nathusii&#x27;,\n",
       "       &#x27;Pipistrellus pipistrellus&#x27;, &#x27;Pipistrellus pygmaeus&#x27;,\n",
       "       &#x27;Plecotus auritus&#x27;, &#x27;Plecotus austriacus&#x27;, &#x27;Rhinolophus ferrumequinum&#x27;,\n",
       "       &#x27;Rhinolophus hipposideros&#x27;], dtype=&#x27;&lt;U25&#x27;)\n",
       "Coordinates:\n",
       "    channel   int64 8B 0\n",
       "  * category  (category) &lt;U25 2kB &#x27;Barbastellus barbastellus&#x27; ... &#x27;Rhinolophu...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'category'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>category</span>: 17</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-4584fd8c-7638-4bce-b685-b4235bc7f62c' class='xr-array-in' type='checkbox' checked><label for='section-4584fd8c-7638-4bce-b685-b4235bc7f62c' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>&#x27;Barbastellus barbastellus&#x27; ... &#x27;Rhinolophus hipposideros&#x27;</span></div><div class='xr-array-data'><pre>array([&#x27;Barbastellus barbastellus&#x27;, &#x27;Eptesicus serotinus&#x27;, &#x27;Myotis alcathoe&#x27;,\n",
       "       &#x27;Myotis bechsteinii&#x27;, &#x27;Myotis brandtii&#x27;, &#x27;Myotis daubentonii&#x27;,\n",
       "       &#x27;Myotis mystacinus&#x27;, &#x27;Myotis nattereri&#x27;, &#x27;Nyctalus leisleri&#x27;,\n",
       "       &#x27;Nyctalus noctula&#x27;, &#x27;Pipistrellus nathusii&#x27;,\n",
       "       &#x27;Pipistrellus pipistrellus&#x27;, &#x27;Pipistrellus pygmaeus&#x27;,\n",
       "       &#x27;Plecotus auritus&#x27;, &#x27;Plecotus austriacus&#x27;, &#x27;Rhinolophus ferrumequinum&#x27;,\n",
       "       &#x27;Rhinolophus hipposideros&#x27;], dtype=&#x27;&lt;U25&#x27;)</pre></div></div></li><li class='xr-section-item'><input id='section-0739d6e9-b7c5-4cbf-8e90-7a6bb6305179' class='xr-section-summary-in' type='checkbox'  checked><label for='section-0739d6e9-b7c5-4cbf-8e90-7a6bb6305179' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>channel</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>0</div><input id='attrs-1e5f4451-3c23-42bb-aca2-3cff3ae2e120' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-1e5f4451-3c23-42bb-aca2-3cff3ae2e120' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-551eaab7-2856-4611-90a8-095ed76395d8' class='xr-var-data-in' type='checkbox'><label for='data-551eaab7-2856-4611-90a8-095ed76395d8' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(0)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>category</span></div><div class='xr-var-dims'>(category)</div><div class='xr-var-dtype'>&lt;U25</div><div class='xr-var-preview xr-preview'>&#x27;Barbastellus barbastellus&#x27; ... ...</div><input id='attrs-c2df1824-fc6a-44dc-b89f-2067b601b86c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-c2df1824-fc6a-44dc-b89f-2067b601b86c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c6aa65d1-f02c-4c99-a218-c7d32b900c85' class='xr-var-data-in' type='checkbox'><label for='data-c6aa65d1-f02c-4c99-a218-c7d32b900c85' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;Barbastellus barbastellus&#x27;, &#x27;Eptesicus serotinus&#x27;, &#x27;Myotis alcathoe&#x27;,\n",
       "       &#x27;Myotis bechsteinii&#x27;, &#x27;Myotis brandtii&#x27;, &#x27;Myotis daubentonii&#x27;,\n",
       "       &#x27;Myotis mystacinus&#x27;, &#x27;Myotis nattereri&#x27;, &#x27;Nyctalus leisleri&#x27;,\n",
       "       &#x27;Nyctalus noctula&#x27;, &#x27;Pipistrellus nathusii&#x27;,\n",
       "       &#x27;Pipistrellus pipistrellus&#x27;, &#x27;Pipistrellus pygmaeus&#x27;,\n",
       "       &#x27;Plecotus auritus&#x27;, &#x27;Plecotus austriacus&#x27;, &#x27;Rhinolophus ferrumequinum&#x27;,\n",
       "       &#x27;Rhinolophus hipposideros&#x27;], dtype=&#x27;&lt;U25&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-323c9084-4ecd-4c40-85ab-f5bb293a4037' class='xr-section-summary-in' type='checkbox'  ><label for='section-323c9084-4ecd-4c40-85ab-f5bb293a4037' class='xr-section-summary' >Indexes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>category</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-da568e1b-56c9-4c81-abee-085c7ab690fb' class='xr-index-data-in' type='checkbox'/><label for='index-da568e1b-56c9-4c81-abee-085c7ab690fb' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([&#x27;Barbastellus barbastellus&#x27;, &#x27;Eptesicus serotinus&#x27;, &#x27;Myotis alcathoe&#x27;,\n",
       "       &#x27;Myotis bechsteinii&#x27;, &#x27;Myotis brandtii&#x27;, &#x27;Myotis daubentonii&#x27;,\n",
       "       &#x27;Myotis mystacinus&#x27;, &#x27;Myotis nattereri&#x27;, &#x27;Nyctalus leisleri&#x27;,\n",
       "       &#x27;Nyctalus noctula&#x27;, &#x27;Pipistrellus nathusii&#x27;,\n",
       "       &#x27;Pipistrellus pipistrellus&#x27;, &#x27;Pipistrellus pygmaeus&#x27;,\n",
       "       &#x27;Plecotus auritus&#x27;, &#x27;Plecotus austriacus&#x27;, &#x27;Rhinolophus ferrumequinum&#x27;,\n",
       "       &#x27;Rhinolophus hipposideros&#x27;],\n",
       "      dtype=&#x27;object&#x27;, name=&#x27;category&#x27;))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-5a196bb2-65d9-4df2-8873-0c212bf0a265' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-5a196bb2-65d9-4df2-8873-0c212bf0a265' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'category' (category: 17)> Size: 2kB\n",
       "array(['Barbastellus barbastellus', 'Eptesicus serotinus', 'Myotis alcathoe',\n",
       "       'Myotis bechsteinii', 'Myotis brandtii', 'Myotis daubentonii',\n",
       "       'Myotis mystacinus', 'Myotis nattereri', 'Nyctalus leisleri',\n",
       "       'Nyctalus noctula', 'Pipistrellus nathusii',\n",
       "       'Pipistrellus pipistrellus', 'Pipistrellus pygmaeus',\n",
       "       'Plecotus auritus', 'Plecotus austriacus', 'Rhinolophus ferrumequinum',\n",
       "       'Rhinolophus hipposideros'], dtype='<U25')\n",
       "Coordinates:\n",
       "    channel   int64 8B 0\n",
       "  * category  (category) <U25 2kB 'Barbastellus barbastellus' ... 'Rhinolophu..."
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_dataset[\"class\"].category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5028922d-cd43-480f-a59e-b9a57dbb626d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:27.470061Z",
     "iopub.status.busy": "2024-11-18T21:26:27.469636Z",
     "iopub.status.idle": "2024-11-18T21:26:27.503493Z",
     "shell.execute_reply": "2024-11-18T21:26:27.502648Z",
     "shell.execute_reply.started": "2024-11-18T21:26:27.470021Z"
    }
   },
   "outputs": [],
   "source": [
    "assert spec.shape == new_spec.shape\n",
    "assert detection_mask.shape == new_detection_mask.shape\n",
    "assert size_mask.shape == new_size_mask.shape\n",
    "assert class_mask.shape[1:] == new_class_mask.shape[1:]\n",
    "assert class_mask.shape[0] == new_class_mask.shape[0] + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0072f1d5-1c07-41cf-879a-63e0a820f1f6",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:27.505404Z",
     "iopub.status.busy": "2024-11-18T21:26:27.504588Z",
     "iopub.status.idle": "2024-11-18T21:26:27.540355Z",
     "shell.execute_reply": "2024-11-18T21:26:27.539604Z",
     "shell.execute_reply.started": "2024-11-18T21:26:27.505373Z"
    }
   },
   "outputs": [],
   "source": [
    "def plot_versions(\n",
    "    original_version,\n",
    "    new_version,\n",
    "    title=\"\",\n",
    "    figsize=(20, 6),\n",
    "    cmap=\"gray\",\n",
    "):\n",
    "    plt.figure(figsize=figsize, facecolor=\"black\")\n",
    "    ax1 = plt.subplot(3, 1, 1)\n",
    "    ax1.pcolormesh(np.flipud(original_version), cmap=cmap)\n",
    "    ax1.set_title(\"Original\", fontdict={'color': \"white\"})\n",
    "    ax1.axis(\"off\")\n",
    "    \n",
    "    ax2 = plt.subplot(3, 1, 2)\n",
    "    ax2.pcolormesh(new_version, cmap=cmap)\n",
    "    ax2.set_title(\"New\", fontdict={'color': \"white\"})\n",
    "    ax2.axis(\"off\")\n",
    "    \n",
    "    max_val = max(original_version.max(), new_version.max())\n",
    "    \n",
    "    original_n = original_version / max_val\n",
    "    new_n = new_version / max_val\n",
    "    diff = np.abs(np.flipud(original_n) - new_n)\n",
    "    ax3 = plt.subplot(3, 1, 3)\n",
    "    ax3.pcolormesh(\n",
    "        np.stack([np.flipud(original_n), new_n, np.flipud(original_n), diff], axis=-1,)\n",
    "    )\n",
    "    ax3.set_title(\"Difference\", fontdict={'color': \"white\"})\n",
    "    ax3.axis(\"off\")\n",
    "    \n",
    "    plt.suptitle(title, fontdict={'color': \"white\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9f87f452-e197-4f04-a214-9b85287cdd59",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:27.542256Z",
     "iopub.status.busy": "2024-11-18T21:26:27.541352Z",
     "iopub.status.idle": "2024-11-18T21:26:28.074464Z",
     "shell.execute_reply": "2024-11-18T21:26:28.073770Z",
     "shell.execute_reply.started": "2024-11-18T21:26:27.542223Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 207180 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_versions(spec, new_spec, title=\"Spectrogram\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7db30b20-c0e5-4329-8c31-836d2cfeb595",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:28.075421Z",
     "iopub.status.busy": "2024-11-18T21:26:28.075178Z",
     "iopub.status.idle": "2024-11-18T21:26:28.536098Z",
     "shell.execute_reply": "2024-11-18T21:26:28.535260Z",
     "shell.execute_reply.started": "2024-11-18T21:26:28.075399Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23764 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_versions(detection_mask, new_detection_mask, title=\"Detection Heatmap\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a0d380dc-9502-4352-bd22-cbaa84117fdb",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:28.537246Z",
     "iopub.status.busy": "2024-11-18T21:26:28.536975Z",
     "iopub.status.idle": "2024-11-18T21:26:28.988473Z",
     "shell.execute_reply": "2024-11-18T21:26:28.987726Z",
     "shell.execute_reply.started": "2024-11-18T21:26:28.537222Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23760 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_versions(class_mask[6], new_class_mask[6], title=f\"{new_dataset.category[6].values} Heatmap\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f17029dd-4623-4684-b966-6faa0dc76a2d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:28.989272Z",
     "iopub.status.busy": "2024-11-18T21:26:28.989031Z",
     "iopub.status.idle": "2024-11-18T21:26:29.437666Z",
     "shell.execute_reply": "2024-11-18T21:26:29.436822Z",
     "shell.execute_reply.started": "2024-11-18T21:26:28.989249Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19164 characters]",
      "text/plain": [
       "<Figure size 2000x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_versions(class_mask[11], new_class_mask[11], title=f\"{new_dataset.category[11].values} Heatmap\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "7d5618a5-30d6-40bd-bff9-c8bb6649d841",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:29.438700Z",
     "iopub.status.busy": "2024-11-18T21:26:29.438451Z",
     "iopub.status.idle": "2024-11-18T21:26:29.471501Z",
     "shell.execute_reply": "2024-11-18T21:26:29.470607Z",
     "shell.execute_reply.started": "2024-11-18T21:26:29.438677Z"
    }
   },
   "outputs": [],
   "source": [
    "x_new, y_new = np.nonzero(new_size_mask.max(axis=0)) \n",
    "x_orig, y_orig = np.nonzero(np.flipud(size_mask.max(axis=0)))\n",
    "\n",
    "assert (x_new == x_orig).all()\n",
    "\n",
    "# NOTE: a difference of 1 pixel is due to discrepancies on how frequency bins are interpreted.\n",
    "# shouldn't be an issue\n",
    "assert (y_new == y_orig + 1).all()\n",
    "\n",
    "width_new, height_new = values_new = new_size_mask[:, x_new, y_new]\n",
    "width_orig, height_orig = values_orig = np.flip(size_mask,axis=1)[:, x_orig, y_orig]\n",
    "\n",
    "assert (np.floor(width_new) == width_orig).all()\n",
    "assert (np.ceil(height_new) == height_orig).all()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5d201d2f-3fee-4ff4-9086-106a2b0607f7",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-11-18T21:26:29.472757Z",
     "iopub.status.busy": "2024-11-18T21:26:29.472487Z",
     "iopub.status.idle": "2024-11-18T21:26:29.508832Z",
     "shell.execute_reply": "2024-11-18T21:26:29.508055Z",
     "shell.execute_reply.started": "2024-11-18T21:26:29.472734Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data_dir': '/data1/bat_data/data/',\n",
       " 'ann_dir': '/data1/bat_data/annotations/anns_same/',\n",
       " 'train_split': 'same',\n",
       " 'standardize_classs_names_ip': 'Rhinolophus ferrumequinum;Rhinolophus hipposideros',\n",
       " 'model_name': 'Net2DFast',\n",
       " 'num_filters': 128,\n",
       " 'experiment': '../../experiments/2021_12_13__20_20_37/',\n",
       " 'model_file_name': '../../experiments/2021_12_13__20_20_37/2021_12_13__20_20_37.pth.tar',\n",
       " 'op_im_dir': '../../experiments/2021_12_13__20_20_37/op_ims/',\n",
       " 'op_im_dir_test': '../../experiments/2021_12_13__20_20_37/op_ims_test/',\n",
       " 'notes': '',\n",
       " 'target_samp_rate': 256000,\n",
       " 'fft_win_length': 0.002,\n",
       " 'fft_overlap': 0.75,\n",
       " 'max_freq': 120000,\n",
       " 'min_freq': 10000,\n",
       " 'resize_factor': 0.5,\n",
       " 'spec_height': 256,\n",
       " 'spec_train_width': 512,\n",
       " 'spec_divide_factor': 32,\n",
       " 'denoise_spec_avg': True,\n",
       " 'scale_raw_audio': False,\n",
       " 'max_scale_spec': False,\n",
       " 'spec_scale': 'pcen',\n",
       " 'detection_overlap': 0.01,\n",
       " 'ignore_start_end': 0.01,\n",
       " 'detection_threshold': 0.01,\n",
       " 'nms_kernel_size': 9,\n",
       " 'nms_top_k_per_sec': 200,\n",
       " 'target_sigma': 2.0,\n",
       " 'aug_prob': 0.2,\n",
       " 'augment_at_train': True,\n",
       " 'augment_at_train_combine': True,\n",
       " 'echo_max_delay': 0.005,\n",
       " 'stretch_squeeze_delta': 0.04,\n",
       " 'mask_max_time_perc': 0.05,\n",
       " 'mask_max_freq_perc': 0.1,\n",
       " 'spec_amp_scaling': 2.0,\n",
       " 'aug_sampling_rates': [220500,\n",
       "  256000,\n",
       "  300000,\n",
       "  312500,\n",
       "  384000,\n",
       "  441000,\n",
       "  500000],\n",
       " 'train_loss': 'focal',\n",
       " 'det_loss_weight': 1.0,\n",
       " 'size_loss_weight': 0.1,\n",
       " 'class_loss_weight': 2.0,\n",
       " 'individual_loss_weight': 0.0,\n",
       " 'emb_dim': 0,\n",
       " 'lr': 0.001,\n",
       " 'batch_size': 8,\n",
       " 'num_workers': 4,\n",
       " 'num_epochs': 200,\n",
       " 'num_eval_epochs': 5,\n",
       " 'device': 'cuda',\n",
       " 'save_test_image_during_train': False,\n",
       " 'save_test_image_after_train': True,\n",
       " 'convert_to_genus': False,\n",
       " 'genus_mapping': [0, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6],\n",
       " 'class_names': ['Barbastellus barbastellus',\n",
       "  'Eptesicus serotinus',\n",
       "  'Myotis alcathoe',\n",
       "  'Myotis bechsteinii',\n",
       "  'Myotis brandtii',\n",
       "  'Myotis daubentonii',\n",
       "  'Myotis mystacinus',\n",
       "  'Myotis nattereri',\n",
       "  'Nyctalus leisleri',\n",
       "  'Nyctalus noctula',\n",
       "  'Pipistrellus nathusii',\n",
       "  'Pipistrellus pipistrellus',\n",
       "  'Pipistrellus pygmaeus',\n",
       "  'Plecotus auritus',\n",
       "  'Plecotus austriacus',\n",
       "  'Rhinolophus ferrumequinum',\n",
       "  'Rhinolophus hipposideros'],\n",
       " 'classes_to_ignore': ['', ' ', 'Unknown', 'Not Bat'],\n",
       " 'generic_class': ['Bat'],\n",
       " 'events_of_interest': ['Echolocation'],\n",
       " 'standardize_classs_names': ['Rhinolophus ferrumequinum',\n",
       "  'Rhinolophus hipposideros'],\n",
       " 'train_sets': [{'dataset_name': 'BatDetective',\n",
       "   'is_test': False,\n",
       "   'is_binary': True,\n",
       "   'ann_path': 'train_set_bulgaria_batdetective_with_bbs.json',\n",
       "   'wav_path': 'bat_detective/audio/'},\n",
       "  {'dataset_name': 'bat_logger_qeop_empty',\n",
       "   'is_test': False,\n",
       "   'is_binary': True,\n",
       "   'ann_path': 'bat_logger_qeop_empty.json',\n",
       "   'wav_path': 'bat_logger_qeop_empty/audio/'},\n",
       "  {'dataset_name': 'bat_logger_2016_empty',\n",
       "   'is_test': False,\n",
       "   'is_binary': True,\n",
       "   'ann_path': 'train_set_bat_logger_2016_empty.json',\n",
       "   'wav_path': 'bat_logger_2016/audio/'},\n",
       "  {'dataset_name': 'echobank',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'Echobank_train_expert_TRAIN.json',\n",
       "   'wav_path': 'echobank/audio/'},\n",
       "  {'dataset_name': 'sn_scot_nor',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'sn_scot_nor_0.5_expert_TRAIN.json',\n",
       "   'wav_path': 'sn_scot_nor/audio/'},\n",
       "  {'dataset_name': 'BCT_1_sec',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BCT_1_sec_train_expert_TRAIN.json',\n",
       "   'wav_path': 'BCT_1_sec/audio/'},\n",
       "  {'dataset_name': 'bcireland',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'bcireland_expert_TRAIN.json',\n",
       "   'wav_path': 'bcireland/audio/'},\n",
       "  {'dataset_name': 'rhinolophus_steve_BCT',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'rhinolophus_steve_BCT_expert_TRAIN.json',\n",
       "   'wav_path': 'rhinolophus_steve_BCT/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2018',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2018_1_sec_train_expert_TRAIN.json',\n",
       "   'wav_path': 'bat_data_martyn_2018/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2018_test',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2018_1_sec_test_expert_TRAIN.json',\n",
       "   'wav_path': 'bat_data_martyn_2018_test/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2019',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2019_1_sec_train_expert_TRAIN.json',\n",
       "   'wav_path': 'bat_data_martyn_2019/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2019_test',\n",
       "   'is_test': False,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2019_1_sec_test_expert_TRAIN.json',\n",
       "   'wav_path': 'bat_data_martyn_2019_test/audio/'}],\n",
       " 'test_sets': [{'dataset_name': 'echobank',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'Echobank_train_expert_TEST.json',\n",
       "   'wav_path': 'echobank/audio/'},\n",
       "  {'dataset_name': 'sn_scot_nor',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'sn_scot_nor_0.5_expert_TEST.json',\n",
       "   'wav_path': 'sn_scot_nor/audio/'},\n",
       "  {'dataset_name': 'BCT_1_sec',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BCT_1_sec_train_expert_TEST.json',\n",
       "   'wav_path': 'BCT_1_sec/audio/'},\n",
       "  {'dataset_name': 'bcireland',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'bcireland_expert_TEST.json',\n",
       "   'wav_path': 'bcireland/audio/'},\n",
       "  {'dataset_name': 'rhinolophus_steve_BCT',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'rhinolophus_steve_BCT_expert_TEST.json',\n",
       "   'wav_path': 'rhinolophus_steve_BCT/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2018',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2018_1_sec_train_expert_TEST.json',\n",
       "   'wav_path': 'bat_data_martyn_2018/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2018_test',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2018_1_sec_test_expert_TEST.json',\n",
       "   'wav_path': 'bat_data_martyn_2018_test/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2019',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2019_1_sec_train_expert_TEST.json',\n",
       "   'wav_path': 'bat_data_martyn_2019/audio/'},\n",
       "  {'dataset_name': 'bat_data_martyn_2019_test',\n",
       "   'is_test': True,\n",
       "   'is_binary': False,\n",
       "   'ann_path': 'BritishBatCalls_MartynCooke_2019_1_sec_test_expert_TEST.json',\n",
       "   'wav_path': 'bat_data_martyn_2019_test/audio/'}],\n",
       " 'class_inv_freq': [1.9637118577957153,\n",
       "  0.7146786451339722,\n",
       "  2.441218852996826,\n",
       "  2.6182825565338135,\n",
       "  0.955857515335083,\n",
       "  0.29615065455436707,\n",
       "  0.6982086896896362,\n",
       "  0.7116808295249939,\n",
       "  1.6066733598709106,\n",
       "  5.473054885864258,\n",
       "  1.386149525642395,\n",
       "  1.0264047384262085,\n",
       "  0.7815048694610596,\n",
       "  1.8502148389816284,\n",
       "  2.458908796310425,\n",
       "  0.885977566242218,\n",
       "  0.8449437618255615],\n",
       " 'genus_names': ['Barbastellus',\n",
       "  'Eptesicus',\n",
       "  'Myotis',\n",
       "  'Nyctalus',\n",
       "  'Pipistrellus',\n",
       "  'Plecotus',\n",
       "  'Rhinolophus'],\n",
       " 'class_names_short': ['Bar bar',\n",
       "  'Ept ser',\n",
       "  'Myo alc',\n",
       "  'Myo bec',\n",
       "  'Myo bra',\n",
       "  'Myo dau',\n",
       "  'Myo mys',\n",
       "  'Myo nat',\n",
       "  'Nyc lei',\n",
       "  'Nyc noc',\n",
       "  'Pip nat',\n",
       "  'Pip pip',\n",
       "  'Pip pyg',\n",
       "  'Ple aur',\n",
       "  'Ple aus',\n",
       "  'Rhi fer',\n",
       "  'Rhi hip'],\n",
       " 'ip_height': 128}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "old_parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b903e17-acee-4555-8e67-d7ba9ba731d1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "batdetect2-dev",
   "language": "python",
   "name": "batdetect2-dev"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
