From 615578a2d0a500b0cfaa78bf6b58a0617024d92b Mon Sep 17 00:00:00 2001
From: s214735 <s214735@dtu.dk>
Date: Thu, 23 Jan 2025 15:44:42 +0100
Subject: [PATCH] checkup of rest of notebooks

---
 docs/notebooks/Untitled.ipynb                 |  71 ---
 ...es from DOI.ipynb => doi_references.ipynb} |  86 +++-
 docs/notebooks/ome_zarr.ipynb                 |  17 +-
 docs/notebooks/segmentation.ipynb             |  30 +-
 docs/notebooks/segmentation_pipeline.ipynb    | 418 ------------------
 docs/notebooks/structure_tensor.ipynb         |  14 +-
 qim3d/utils/_doi.py                           |   2 +-
 7 files changed, 108 insertions(+), 530 deletions(-)
 delete mode 100644 docs/notebooks/Untitled.ipynb
 rename docs/notebooks/{references from DOI.ipynb => doi_references.ipynb} (90%)
 delete mode 100644 docs/notebooks/segmentation_pipeline.ipynb

diff --git a/docs/notebooks/Untitled.ipynb b/docs/notebooks/Untitled.ipynb
deleted file mode 100644
index c946f3b2..00000000
--- a/docs/notebooks/Untitled.ipynb
+++ /dev/null
@@ -1,71 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "id": "0b73f2d8",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "import qim3d"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "id": "73db6886",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "vol = qim3d.examples.bone_128x128x128"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 8,
-   "id": "22d86d4d",
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "2fefeafbd89c4f9fa5a08dc1a5d503d1",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "HBox(children=(interactive(children=(IntSlider(value=64, description='Z', max=127), Output()), layout=Layout(a…"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "qim3d.viz.orthogonal(vol)"
-   ]
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
-   "language": "python",
-   "name": "python3"
-  },
-  "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.11.5"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/docs/notebooks/references from DOI.ipynb b/docs/notebooks/doi_references.ipynb
similarity index 90%
rename from docs/notebooks/references from DOI.ipynb
rename to docs/notebooks/doi_references.ipynb
index d60c313d..4ea0dbf9 100644
--- a/docs/notebooks/references from DOI.ipynb	
+++ b/docs/notebooks/doi_references.ipynb
@@ -13,12 +13,13 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 1,
    "id": "35b9fe6b",
    "metadata": {},
    "outputs": [],
    "source": [
     "import qim3d\n",
+    "\n",
     "doi = \"https://doi.org/10.1007/s10851-021-01041-3\""
    ]
   },
@@ -32,7 +33,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 2,
    "id": "17720b94",
    "metadata": {},
    "outputs": [
@@ -46,7 +47,7 @@
     }
    ],
    "source": [
-    "bibtext = qim3d.utils.get_bibtex(doi)"
+    "bibtex = qim3d.utils.get_bibtex(doi)"
    ]
   },
   {
@@ -59,12 +60,49 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 5,
    "id": "a15baf83",
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Stephensen Hans J. T., Svane Anne Marie, Villanueva Carlos B., Goldman Steven A., Sporring Jon (2021). Measuring Shape Relations Using r-Parallel Sets. Springer Science and Business Media LLC (http://dx.doi.org/10.1007/s10851-021-01041-3). DOI: 10.1007/s10851-021-01041-3\n"
+     ]
+    }
+   ],
    "source": [
-    "reference = qim3d.utils.get_reference(doi)"
+    "reference = qim3d.utils.get_reference(doi)\n",
+    "print(reference)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "2b75ed86",
+   "metadata": {},
+   "source": [
+    "We can also use the `custom_header` method to generate a reference string with a custom header format."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "id": "e1ac5d24",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "Stephensen, H. J. T., Svane, A. M., Villanueva, C. B., Goldman, S. A., & Sporring, J. (2021). Measuring Shape Relations Using r-Parallel Sets. Journal of Mathematical Imaging and Vision, 63(8), 1069–1083. https://doi.org/10.1007/s10851-021-01041-3\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "header = {\"Accept\": \"text/bibliography\"}\n",
+    "custom_header = qim3d.utils.custom_header(doi, header)"
    ]
   },
   {
@@ -72,12 +110,12 @@
    "id": "88a65569",
    "metadata": {},
    "source": [
-    "Lastly, to get metadata from the doi, use the `get_metadata` method:"
+    "To get metadata from the doi, use the `get_metadata` method:"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 7,
    "id": "6d4d215e",
    "metadata": {
     "scrolled": false
@@ -408,13 +446,41 @@
        "   'group': {'name': 'EthicsHeading', 'label': 'Conflict of interest'}}]}"
       ]
      },
-     "execution_count": 9,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "qim3d.utils.get_metadata(doi)"
+    "metadata = qim3d.utils.get_metadata(doi)\n",
+    "metadata"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "acc89618",
+   "metadata": {},
+   "source": [
+    "Lastly, we can generate a reference string using the metadata dictionary using the `build_reference_string` method:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "id": "84aac0f1",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Stephensen Hans J. T., Svane Anne Marie, Villanueva Carlos B., Goldman Steven A., Sporring Jon (2021). Measuring Shape Relations Using r-Parallel Sets. Springer Science and Business Media LLC (http://dx.doi.org/10.1007/s10851-021-01041-3). DOI: 10.1007/s10851-021-01041-3\n"
+     ]
+    }
+   ],
+   "source": [
+    "reference = qim3d.utils.build_reference_string(metadata)\n",
+    "print(reference)"
    ]
   }
  ],
diff --git a/docs/notebooks/ome_zarr.ipynb b/docs/notebooks/ome_zarr.ipynb
index ec0562b0..5c485d9d 100644
--- a/docs/notebooks/ome_zarr.ipynb
+++ b/docs/notebooks/ome_zarr.ipynb
@@ -102,15 +102,16 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
      "name": "stderr",
      "output_type": "stream",
      "text": [
-      "File already downloaded:\n",
-      "/home/s214735/qim3d/docs/notebooks/Crab/OkinawaCrab.tif\n",
+      "Downloading \u001b[1mOkinawaCrab.tif\u001b[0m\n",
+      "https://archive.compute.dtu.dk/download/public/projects/viscomp_data_repository/Crab/OkinawaCrab.tif\n",
+      "1.86GB [01:31, 21.8MB/s]                                                        \n",
       "\n",
       "Loading OkinawaCrab.tif\n"
      ]
@@ -118,7 +119,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "c8510c263d2842e39e5067531823f451",
+       "model_id": "73ab33bf78424c2cbb8d1efedfb536a8",
        "version_major": 2,
        "version_minor": 0
       },
@@ -172,7 +173,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "c1e38c07b2d14b9b81f653dd085f157c",
+       "model_id": "bd3f056e42534a808d475217e96d5520",
        "version_major": 2,
        "version_minor": 0
       },
@@ -215,7 +216,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "36481522fd0b444c9940c1c028596544",
+       "model_id": "c5cb53e381be4ab99698d3d320cc49a2",
        "version_major": 2,
        "version_minor": 0
       },
@@ -301,7 +302,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "d4bd61011d794f14b4b8487666b2c8ea",
+       "model_id": "88cf5ef25eee404397c6238bf2942179",
        "version_major": 2,
        "version_minor": 0
       },
@@ -326,7 +327,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "927a9b89fe0f4e3598f6aad61451c254",
+       "model_id": "55fac021ed464735a8c59516cd63144b",
        "version_major": 2,
        "version_minor": 0
       },
diff --git a/docs/notebooks/segmentation.ipynb b/docs/notebooks/segmentation.ipynb
index 920d62a2..d08d0e73 100644
--- a/docs/notebooks/segmentation.ipynb
+++ b/docs/notebooks/segmentation.ipynb
@@ -21,12 +21,12 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "5c2f4fac066740eca21a30d0a9cb4b36",
+       "model_id": "d92cd04a11a0407f9ee91f9b02aa10b7",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…"
+       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), _dom_classes=('widget-inte…"
       ]
      },
      "execution_count": 1,
@@ -49,21 +49,21 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "878a63fbbd804ee290a4f988c8d4e971",
+       "model_id": "f9f9c05c93fe403c98fb188994a3b9b5",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…"
+       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), _dom_classes=('widget-inte…"
       ]
      },
-     "execution_count": 2,
+     "execution_count": 6,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -83,7 +83,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -108,7 +108,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -128,27 +128,27 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "386452590d3b44fb9f1a9e8d6332453f",
+       "model_id": "9a7b627a102346f08b4bd7bb029f865e",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…"
+       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), _dom_classes=('widget-inte…"
       ]
      },
-     "execution_count": 6,
+     "execution_count": 5,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "qim3d.viz.slicer(vol_cc)\n"
+    "qim3d.viz.slicer(vol_cc)"
    ]
   },
   {
@@ -190,12 +190,12 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "da40a0a00349401ca5d141b83e0bac2b",
+       "model_id": "90b8a88af23240ebb7de60566d2f58f1",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…"
+       "interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), _dom_classes=('widget-inte…"
       ]
      },
      "execution_count": 8,
diff --git a/docs/notebooks/segmentation_pipeline.ipynb b/docs/notebooks/segmentation_pipeline.ipynb
deleted file mode 100644
index 4983a7fd..00000000
--- a/docs/notebooks/segmentation_pipeline.ipynb
+++ /dev/null
@@ -1,418 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Deep learning volume segmentation\n",
-    "\n",
-    "Authors: Alessia Saccardo (s212246@dtu.dk) & Felipe Delestro (fima@dtu.dk)\n",
-    "\n",
-    "This notebook aims to demonstrate the feasibility of implementing a comprehensive deep learning segmentation pipeline solely leveraging the capabilities offered by the qim3d library. Specifically, it will highlight the utilization of the annotation tool and walk through the process of creating and training a Unet model."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "### Imports"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "import qim3d\n",
-    "import numpy as np \n",
-    "import os "
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "### Load data\n",
-    "Qim3d library contains a set of example volumes which can be easily loaded using `qim3d.examples.{volume_name}`"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "vol = qim3d.examples.bone_128x128x128"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "To easily have an insight of how the volume looks like we can interact with it using the `slicer` function from `qim3d`"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "qim3d.viz.slicer(vol)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Generate dataset for training\n",
-    "\n",
-    "In order to train the classification model, we need to create a dataset from the volume.\n",
-    "\n",
-    "This means that we'll need a few slices to be used for `training` and at least one for the `test`"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "The dataset for training the model is managed by `qim3d.utils.prepare_datasets` and it expects files to follow this structure:\n",
-    "\n",
-    "<pre>\n",
-    "dataset\n",
-    "├── test\n",
-    "│   ├── images\n",
-    "│   │   └── FileA.png\n",
-    "│   └── labels\n",
-    "│       └── FileA.png\n",
-    "└── train\n",
-    "    ├── images\n",
-    "    │   ├── FileB.png\n",
-    "    │   └── FileC.png\n",
-    "    └── labels\n",
-    "        ├── FileB.png\n",
-    "        └── FileC.png\n",
-    "\n",
-    "\n",
-    "</pre>\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# Number of slices that will be used\n",
-    "ntraining = 4\n",
-    "ntest = 1"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "In the following cell, we get the slice indices, making sure that we're not using the same indices for training and test."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# Create a set with all the indices\n",
-    "all_idxs = set(range(vol.shape[0]))\n",
-    "\n",
-    "# Get indices for training data\n",
-    "training_idxs = list(np.random.choice(list(all_idxs), size=ntraining))\n",
-    "print(f\"Slices for training data...: {training_idxs}\")\n",
-    "\n",
-    "# Get indices for test data\n",
-    "test_idxs = list(np.random.choice(list(all_idxs - set(training_idxs)), size=ntest, replace=False))\n",
-    "print(f\"Slices for test data.......: {test_idxs}\")"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "## Create folder structure\n",
-    "Here we create the necessary directories"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# Base path for the training data\n",
-    "base_path = os.path.expanduser(\"~/dataset\")\n",
-    "\n",
-    "# Create directories\n",
-    "print(\"Creating directories:\")\n",
-    "for folder_split in [\"train\", \"test\"]:\n",
-    "    for folder_type in [\"images\", \"labels\"]:\n",
-    "        path = os.path.join(base_path, folder_split, folder_type)\n",
-    "        os.makedirs(path, exist_ok=True)\n",
-    "        print(path)\n",
-    "\n",
-    "# Here we have the option to remove any previous files\n",
-    "clean_files = True\n",
-    "if clean_files:\n",
-    "    for root, dirs, files in os.walk(base_path):\n",
-    "        for file in files:\n",
-    "            file_path = os.path.join(root, file)\n",
-    "            os.remove(file_path)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Annotate data\n",
-    "\n",
-    "The following cell will generate an annotation tool for each slice that was requested. \n",
-    "\n",
-    "You should use the tool to drawn a mask over the structures you're willing to detect, and press the button `Update` so that the mask is saved."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "annotation_tools = {}\n",
-    "for idx in training_idxs + test_idxs:\n",
-    "    if idx in training_idxs:\n",
-    "        subset = \"training\"\n",
-    "    elif idx in test_idxs:\n",
-    "        subset = \"test\"\n",
-    "    annotation_tools[idx] = qim3d.gui.annotation_tool.Interface()\n",
-    "    annotation_tools[idx].name_suffix = f\"_{idx}\"  \n",
-    "    print(f\"Annotation for slice {idx} ({subset})\")\n",
-    "    annotation_tools[idx].launch(vol[idx])"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "### Getting masks from the annotation tool\n",
-    "The masks are stored in the annotation tool when the button `Update` is pressed\n",
-    "\n",
-    "Here we extract the masks and save them to disk, followign the standard needed for the DL model"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "print(\"Saving images and masks to disk\")\n",
-    "for idx in training_idxs + test_idxs:\n",
-    "    \n",
-    "    if idx in training_idxs:\n",
-    "        folder_split = \"train\"\n",
-    "\n",
-    "    elif idx in test_idxs:\n",
-    "        folder_split = \"test\"\n",
-    "\n",
-    "    print (f\"- slice {idx} ({folder_split})\")\n",
-    "    mask_dict = annotation_tools[idx].get_result()\n",
-    "    mask = list(mask_dict.values())[0]\n",
-    "\n",
-    "    # Save image\n",
-    "    qim3d.io.save(os.path.join(base_path,folder_split,\"images\",f\"{idx}.png\"), vol[idx], replace=True)\n",
-    "    # Save label\n",
-    "    qim3d.io.save(os.path.join(base_path,folder_split,\"labels\",f\"{idx}.png\"), mask, replace=True)\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Build Unet"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Building and training the Unet model is straightforward using `qim3d`. \n",
-    "\n",
-    "We first need to instantiate the model by defying its size, which can be either *small*, *medium* or *large*. "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# defining model\n",
-    "model = qim3d.models.UNet(size = 'small', dropout = 0.25)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Then we need to decide which type of augumentation to apply to the data. \n",
-    "\n",
-    "The `qim3d.utils.Augmentation` allows to specify how the images should be reshaped to the appropriate size and the level of transformation to apply respectively to train, test and validation sets. \n",
-    "\n",
-    "The resize must be choosen between [*crop*, *reshape*, *padding*] and the level of transformation must be chosse between [*None*, *light*, *moderate*, *heavy*]. The user can also specify the mean and standard deviation values for normalizing pixel intensities."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# defining augmentation\n",
-    "aug = qim3d.utils.Augmentation(resize = 'crop', transform_train = 'light')"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Then the datasets and dataloaders are instantiated "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# datasets and dataloaders\n",
-    "train_set, val_set, test_set = qim3d.utils.prepare_datasets(path = base_path,\n",
-    "                                                            val_fraction = 0.5,\n",
-    "                                                            model = model,\n",
-    "                                                            augmentation = aug)\n",
-    "\n",
-    "\n",
-    "train_loader, val_loader, test_loader = qim3d.utils.prepare_dataloaders(train_set, \n",
-    "                                                                        val_set,\n",
-    "                                                                        test_set,\n",
-    "                                                                        batch_size = 1)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "The hyperparameters are defined using the function `qim3d.models.Hyperparameters` and the model can be easily trained by running the function `qim3d.utils.train_model` which returns also a plot of the losses at the end of the training if the option is selected by the user "
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Train model"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# model hyperparameters\n",
-    "hyperparameters = qim3d.models.Hyperparameters(model, n_epochs=10, \n",
-    "                                               learning_rate = 5e-3, loss_function='DiceCE',\n",
-    "                                               weight_decay=1e-3)\n",
-    "\n",
-    "# training model\n",
-    "qim3d.utils.train_model(model, hyperparameters, train_loader, val_loader, plot=True)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Check results\n",
-    "\n",
-    "To compute the inference step it is just needed to run `qim3d.utils.inference`.\n",
-    "\n",
-    "The results can be visualize with the function `qim3d.viz.grid_pred` that shows the predicted segmentation along with a comparison between the ground truth."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "in_targ_preds_test = qim3d.utils.inference(test_set, model)\n",
-    "qim3d.viz.grid_pred(in_targ_preds_test,alpha=1)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Compute inference on entire volume\n",
-    "\n",
-    "Given that the input is a volume, the goal is to perform inference on the entire volume rather than individual slices.\n",
-    "\n",
-    "By using the function `qim3d.utils.volume_inference` it is possible to obtain the segmentation volume output"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "inference_vol = qim3d.utils.models.volume_inference(vol, model)\n",
-    "qim3d.viz.slicer(inference_vol)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "We can also visualize the created mask together with the original volume"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "vol_masked = qim3d.viz.vol_masked(vol, inference_vol, viz_delta=128)\n",
-    "qim3d.viz.slicer(vol_masked, cmap=\"PiYG\")"
-   ]
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
-   "language": "python",
-   "name": "python3"
-  },
-  "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.11.5"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 4
-}
diff --git a/docs/notebooks/structure_tensor.ipynb b/docs/notebooks/structure_tensor.ipynb
index ca40198b..45ae942a 100644
--- a/docs/notebooks/structure_tensor.ipynb
+++ b/docs/notebooks/structure_tensor.ipynb
@@ -38,7 +38,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "e949facde9fe46c0b764b0e6e4634596",
+       "model_id": "297c6d1d979c477eba14df1c46b6ce8b",
        "version_major": 2,
        "version_minor": 0
       },
@@ -54,10 +54,10 @@
     "import qim3d\n",
     "\n",
     "# Import 3D volume of brain tissue\n",
-    "NT = qim3d.examples.NT_128x128x128\n",
+    "vol = qim3d.examples.NT_128x128x128\n",
     "\n",
     "# Visuaize the 3D volume\n",
-    "qim3d.viz.volumetric(NT)"
+    "qim3d.viz.volumetric(vol)"
    ]
   },
   {
@@ -75,7 +75,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "b4b06b17f3754c8388400d57671375ea",
+       "model_id": "b23720c4acaf4321b3b8aada5743d8d7",
        "version_major": 2,
        "version_minor": 0
       },
@@ -89,7 +89,7 @@
    ],
    "source": [
     "# Compute eigenvalues and eigenvectors of the structure tensor\n",
-    "val, vec = qim3d.processing.structure_tensor(NT, visualize = True, axis = 0) # Slicing in z-direction"
+    "val, vec = qim3d.processing.structure_tensor(vol, visualize=True, axis=0)"
    ]
   },
   {
@@ -107,7 +107,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "0742605ac0b7413a8477ccaa5ab60806",
+       "model_id": "7b1389b0bf1847e6b249c960eeb8e888",
        "version_major": 2,
        "version_minor": 0
       },
@@ -121,7 +121,7 @@
    ],
    "source": [
     "# Compute eigenvalues and eigenvectors of the structure tensor\n",
-    "val, vec = qim3d.processing.structure_tensor(NT, visualize = True, axis = 2) # Slicing in x-direction"
+    "val, vec = qim3d.processing.structure_tensor(vol, visualize=True, axis=2)"
    ]
   }
  ],
diff --git a/qim3d/utils/_doi.py b/qim3d/utils/_doi.py
index 1859ed53..e5127063 100644
--- a/qim3d/utils/_doi.py
+++ b/qim3d/utils/_doi.py
@@ -35,7 +35,7 @@ def _make_request(doi: str, header: str) -> requests.Response:
     return response
 
 
-def _log_and_get_text(doi, header) -> str:
+def _log_and_get_text(doi: str, header: str) -> str:
     response = _make_request(doi, header)
 
     if response and response.encoding:
-- 
GitLab