From 04bfb2f0eb870bf89cbba6824e277c60f6fca175 Mon Sep 17 00:00:00 2001 From: iback Date: Fri, 31 Jan 2025 10:41:33 +0000 Subject: [PATCH 1/2] added example for aggregating values and evaluation over dataset --- panoptica/example_aggregation.ipynb | 2469 +++++++++++++++++++++++++++ 1 file changed, 2469 insertions(+) create mode 100644 panoptica/example_aggregation.ipynb diff --git a/panoptica/example_aggregation.ipynb b/panoptica/example_aggregation.ipynb new file mode 100644 index 0000000..b120867 --- /dev/null +++ b/panoptica/example_aggregation.ipynb @@ -0,0 +1,2469 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Use Case: Aggregatinv over Datasets\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Dependencies" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install panoptica auxiliary rich numpy > /dev/null" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you installed the packages and requirements on your own machine, you can skip this section and start from the import section.\n", + "\n", + "### Setup Colab environment (optional) \n", + "Otherwise you can follow and execute the tutorial on your browser.\n", + "In order to start working on the notebook, click on the following button, this will open this page in the Colab environment and you will be able to execute the code on your own (*Google account required*).\n", + "\n", + "\n", + " \"Open\n", + "\n", + "\n", + "Now that you are visualizing the notebook in Colab, run the next cell to install the packages we will use. There are few things you should follow in order to properly set the notebook up:\n", + "1. Warning: This notebook was not authored by Google. Click on 'Run anyway'.\n", + "1. When the installation commands are done, there might be \"Restart runtime\" button at the end of the output. Please, click it.\n", + "If you run the next cell in a Google Colab environment, it will **clone the 'tutorials' repository** in your google drive. This will create a **new folder** called \"tutorials\" in **your Google Drive**.\n", + "All generated file will be created/uploaded to your Google Drive respectively.\n", + "\n", + "After the first execution of the next cell, you might receive some warnings and notifications, please follow these instructions:\n", + " - 'Permit this notebook to access your Google Drive files?' Click on 'Yes', and select your account.\n", + " - Google Drive for desktop wants to access your Google Account. Click on 'Allow'.\n", + "\n", + "Afterwards the \"tutorials\" folder has been created. You can navigate it through the lefthand panel in Colab. You might also have received an email that informs you about the access on your Google Drive." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import sys\n", + "\n", + "# Check if we are in google colab currently\n", + "try:\n", + " import google.colab\n", + "\n", + " colabFlag = True\n", + "except ImportError as r:\n", + " colabFlag = False\n", + "\n", + "# Execute certain steps only if we are in a colab environment\n", + "if colabFlag:\n", + " # Create a folder in your Google Drive\n", + " from google.colab import drive\n", + "\n", + " drive.mount(\"/content/drive\")\n", + " # clone repository and set path\n", + " !git clone https://github.com/BrainLesion/tutorials.git /content/drive/MyDrive/tutorials\n", + " BASE_PATH = \"/content/drive/MyDrive/tutorials/panoptica\"\n", + " sys.path.insert(0, BASE_PATH)\n", + "\n", + "else: # normal jupyter notebook environment\n", + " BASE_PATH = \".\" # current working directory would be BraTs-Toolkit anyways if you are not in colab" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup Imports" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "from auxiliary.nifti.io import read_nifti\n", + "from rich import print as pprint\n", + "from panoptica import InputType, Panoptica_Evaluator\n", + "from panoptica.metrics import Metric" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For demonstration purposes, we will quickly define some numpy predictions and will compare it to the same reference array\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "reference_array = np.array([\n", + " [0,1,0,0,0],\n", + " [1,1,0,0,0],\n", + " [0,0,0,2,0],\n", + " [0,0,2,2,2],\n", + " [0,0,0,2,0],\n", + "])\n", + "\n", + "# Lets give them names, in practice this should be sample/subject names for easy recognition\n", + "predictions = {\n", + " \"subject_perfect\": np.array([\n", + " [0,1,0,0,0],\n", + " [1,1,0,0,0],\n", + " [0,0,0,2,0],\n", + " [0,0,2,2,2],\n", + " [0,0,0,2,0],\n", + " ]),\n", + " \"subject_horrible\": np.array([\n", + " [0,0,0,0,0],\n", + " [1,0,0,0,0],\n", + " [0,0,0,0,2],\n", + " [0,0,0,0,2],\n", + " [0,0,0,0,2],\n", + " ]),\n", + " \"subject_overprediction\": np.array([\n", + " [0,1,0,0,0],\n", + " [1,1,1,0,0],\n", + " [0,1,2,2,2],\n", + " [0,0,2,2,2],\n", + " [0,0,0,2,2],\n", + " ]),\n", + "}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Run Evaluation" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Panoptic: Start Evaluation\n", + "-- Got MatchedInstancePair, will evaluate instances\n", + "Panoptic: Start Evaluation\n", + "-- Got MatchedInstancePair, will evaluate instances\n" + ] + } + ], + "source": [ + "# let's calculate one sample as usual\n", + "\n", + "# Let's define that label 1 and 2 (see arrays above) should be treated as different groups \n", + "from panoptica.utils import SegmentationClassGroups, LabelGroup\n", + "# (in practice, this could be different classes of labels, instead of multiple instances of the same class)\n", + "segmentation_class_groups = SegmentationClassGroups({\"Structure1\": LabelGroup(1), \"Structure2\": LabelGroup(2)})\n", + "\n", + "evaluator = Panoptica_Evaluator(\n", + " expected_input=InputType.MATCHED_INSTANCE,\n", + " decision_metric=Metric.IOU,\n", + " decision_threshold=0.0,\n", + " segmentation_class_groups=segmentation_class_groups,\n", + ")\n", + "\n", + "\n", + "result = evaluator.evaluate(predictions[\"subject_perfect\"], reference_array)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Inspect Results\n", + "The results object allows access to individual metrics and provides helper methods for further processing" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "+++ MATCHING +++\n", + "Number of instances in reference (num_ref_instances): 1\n", + "Number of instances in prediction (num_pred_instances): 1\n", + "True Positives (tp): 1\n", + "False Positives (fp): 0\n", + "False Negatives (fn): 0\n", + "Recognition Quality / F1-Score (rq): 1.0\n", + "\n", + "+++ GLOBAL +++\n", + "Global Binary Dice (global_bin_dsc): 1.0\n", + "\n", + "+++ INSTANCE +++\n", + "Segmentation Quality IoU (sq): 1.0 +- 0.0\n", + "Panoptic Quality IoU (pq): 1.0\n", + "Segmentation Quality Dsc (sq_dsc): 1.0 +- 0.0\n", + "Panoptic Quality Dsc (pq_dsc): 1.0\n", + "Segmentation Quality ASSD (sq_assd): 0.0 +- 0.0\n", + "Segmentation Quality Relative Volume Difference (sq_rvd): 0.0 +- 0.0\n", + "\n", + "\n", + "+++ MATCHING +++\n", + "Number of instances in reference (num_ref_instances): 1\n", + "Number of instances in prediction (num_pred_instances): 1\n", + "True Positives (tp): 1\n", + "False Positives (fp): 0\n", + "False Negatives (fn): 0\n", + "Recognition Quality / F1-Score (rq): 1.0\n", + "\n", + "+++ GLOBAL +++\n", + "Global Binary Dice (global_bin_dsc): 1.0\n", + "\n", + "+++ INSTANCE +++\n", + "Segmentation Quality IoU (sq): 1.0 +- 0.0\n", + "Panoptic Quality IoU (pq): 1.0\n", + "Segmentation Quality Dsc (sq_dsc): 1.0 +- 0.0\n", + "Panoptic Quality Dsc (pq_dsc): 1.0\n", + "Segmentation Quality ASSD (sq_assd): 0.0 +- 0.0\n", + "Segmentation Quality Relative Volume Difference (sq_rvd): 0.0 +- 0.0\n", + "\n" + ] + } + ], + "source": [ + "# print all results by using the group names\n", + "print(result[\"structure1\"])\n", + "print(result[\"structure2\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Aggregate over Dataset\n", + "Now lets define a Panoptica-Aggregator that aggregates and collects these results in a file." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['num_ref_instances', 'num_pred_instances', 'tp', 'fp', 'fn', 'prec', 'rec', 'rq', 'sq', 'sq_std', 'pq', 'sq_dsc', 'sq_dsc_std', 'pq_dsc', 'sq_assd', 'sq_assd_std', 'sq_rvd', 'sq_rvd_std', 'global_bin_dsc', 'computation_time']\n" + ] + } + ], + "source": [ + "from panoptica import Panoptica_Aggregator\n", + "from pathlib import Path\n", + "import os\n", + "\n", + "output_file = str(Path(os.path.abspath(\"\")).parent.joinpath(\"example_aggregation.tsv\"))\n", + "aggregator = Panoptica_Aggregator(panoptica_evaluator=evaluator, output_file=output_file, log_times=True,)\n", + "print(aggregator.evaluation_metrics)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Call evaluate on subject_perfect\n", + "Saved entry subject_perfect into /DATA/NAS/ongoing_projects/hendrik/panoptica/tutorials/example_aggregation.tsv\n", + "Call evaluate on subject_horrible\n", + "Saved entry subject_horrible into /DATA/NAS/ongoing_projects/hendrik/panoptica/tutorials/example_aggregation.tsv\n", + "Call evaluate on subject_overprediction\n", + "Saved entry subject_overprediction into /DATA/NAS/ongoing_projects/hendrik/panoptica/tutorials/example_aggregation.tsv\n" + ] + } + ], + "source": [ + "# loop over our predictions\n", + "# in a real scenario, any other form of iteratively receiving prediction data and feeding it into the aggregator works fine as well!\n", + "for name, pred_arr in predictions.items():\n", + " aggregator.evaluate(pred_arr, reference_array, name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Evaluate Dataset\n", + "After evaluating all samples in a dataset, we can use the created .tsv externally.\n", + "Or we use the inbuild panoptica statistics features to easily get statisics.\n", + "Let's do that!" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found 3 entries\n", + "Found metrics: ['num_ref_instances', 'num_pred_instances', 'tp', 'fp', 'fn', 'prec', 'rec', 'rq', 'sq', 'sq_std', 'pq', 'sq_dsc', 'sq_dsc_std', 'pq_dsc', 'sq_assd', 'sq_assd_std', 'sq_rvd', 'sq_rvd_std', 'global_bin_dsc', 'computation_time']\n", + "Found groups: ['structure2', 'structure1']\n", + "\n", + "Group across_groups:\n", + "num_ref_instances : 1.0 +- 0.0\n", + "num_pred_instances : 1.0 +- 0.0\n", + "tp : 1.0 +- 0.0\n", + "fp : 0.0 +- 0.0\n", + "fn : 0.0 +- 0.0\n", + "prec : 1.0 +- 0.0\n", + "rec : 1.0 +- 0.0\n", + "rq : 1.0 +- 0.0\n", + "sq : 0.617 +- 0.028\n", + "sq_std : 0.0 +- 0.0\n", + "pq : 0.617 +- 0.028\n", + "sq_dsc : 0.712 +- 0.038\n", + "sq_dsc_std : 0.0 +- 0.0\n", + "pq_dsc : 0.712 +- 0.038\n", + "sq_assd : 0.311 +- 0.038\n", + "sq_assd_std : 0.0 +- 0.0\n", + "sq_rvd : 0.033 +- 0.033\n", + "sq_rvd_std : 0.0 +- 0.0\n", + "global_bin_dsc : 0.712 +- 0.038\n", + "computation_time : 0.982 +- 0.057\n", + "\n" + ] + } + ], + "source": [ + "statistics_obj = aggregator.make_statistic()\n", + "# equivalent would be\n", + "# from panoptica import Panoptica_Statistic\n", + "# statistics_obj = Panoptica_Statistic.from_file()\n", + "statistics_obj.print_summary()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "With this statistics object, we can get the metric values for each group, metric, and sample interchangeably" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'structure1': [1.0, 0.5, 0.75], 'structure2': [1.0, 0.25, 0.7692307692307693]}" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "statistics_obj.get_one_subject(\"subject_perfect\")\n", + "# gets the values for one subject (map from metric to value)\n", + "statistics_obj.get_one_group(\"structure1\")\n", + "# This gets one group, so mapping metric to the values\n", + "statistics_obj.get_one_metric(\"global_bin_dsc\")\n", + "# This gets one metric, so mapping group to the values" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1.0, 0.5, 0.75]" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# get the metric values for a group and metric\n", + "statistics_obj.get(\"structure1\", \"global_bin_dsc\")" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'structure1': {'num_ref_instances': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'num_pred_instances': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'tp': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'fp': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'fn': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'prec': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'rec': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'rq': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'sq': [0.333, 1.0], avg = 0.644 +- 0.274,\n", + " 'sq_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'pq': [0.333, 1.0], avg = 0.644 +- 0.274,\n", + " 'sq_dsc': [0.5, 1.0], avg = 0.75 +- 0.204,\n", + " 'sq_dsc_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'pq_dsc': [0.5, 1.0], avg = 0.75 +- 0.204,\n", + " 'sq_assd': [0.0, 0.417], avg = 0.273 +- 0.193,\n", + " 'sq_assd_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'sq_rvd': [-0.667, 0.667], avg = 0.0 +- 0.544,\n", + " 'sq_rvd_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'global_bin_dsc': [0.5, 1.0], avg = 0.75 +- 0.204,\n", + " 'computation_time': [0.76, 1.19], avg = 0.926 +- 0.189},\n", + " 'structure2': {'num_ref_instances': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'num_pred_instances': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'tp': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'fp': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'fn': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'prec': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'rec': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'rq': [1.0, 1.0], avg = 1.0 +- 0.0,\n", + " 'sq': [0.143, 1.0], avg = 0.589 +- 0.351,\n", + " 'sq_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'pq': [0.143, 1.0], avg = 0.589 +- 0.351,\n", + " 'sq_dsc': [0.25, 1.0], avg = 0.673 +- 0.314,\n", + " 'sq_dsc_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'pq_dsc': [0.25, 1.0], avg = 0.673 +- 0.314,\n", + " 'sq_assd': [0.0, 0.833], avg = 0.349 +- 0.353,\n", + " 'sq_assd_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'sq_rvd': [-0.4, 0.6], avg = 0.067 +- 0.411,\n", + " 'sq_rvd_std': [0.0, 0.0], avg = 0.0 +- 0.0,\n", + " 'global_bin_dsc': [0.25, 1.0], avg = 0.673 +- 0.314,\n", + " 'computation_time': [0.878, 1.123], avg = 1.039 +- 0.114}}" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# get a summary dictionary across groups and metrics\n", + "statistics_obj.get_summary_dict(include_across_group=False) # we set this to false because we only have on group, otherwise this would yield also the averages across all groups" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can also create figures and some useful ordering with this" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: nbformat in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (5.10.4)\n", + "Requirement already satisfied: fastjsonschema>=2.15 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from nbformat) (2.21.1)\n", + "Requirement already satisfied: jsonschema>=2.6 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from nbformat) (4.23.0)\n", + "Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from nbformat) (5.7.1)\n", + "Requirement already satisfied: traitlets>=5.1 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from nbformat) (5.14.1)\n", + "Requirement already satisfied: attrs>=22.2.0 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat) (23.1.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat) (2024.10.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat) (0.36.2)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from jsonschema>=2.6->nbformat) (0.22.3)\n", + "Requirement already satisfied: platformdirs>=2.5 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from jupyter-core!=5.0.*,>=4.12->nbformat) (4.1.0)\n", + "Requirement already satisfied: typing-extensions>=4.4.0 in /opt/anaconda3/envs/seg11panoptdev/lib/python3.11/site-packages (from referencing>=0.28.4->jsonschema>=2.6->nbformat) (4.9.0)\n" + ] + } + ], + "source": [ + "!pip install --upgrade nbformat" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "alignmentgroup": "True", + "boxpoints": "all", + "fillcolor": "rgba(255,255,255,0)", + "hoveron": "points", + "hovertemplate": "Structure=%{x}
global_bin_dsc=%{y}", + "legendgroup": "", + "line": { + "color": "rgba(255,255,255,0)" + }, + "marker": { + "color": "#555555", + "size": 5 + }, + "name": "", + "offsetgroup": "", + "orientation": "v", + "pointpos": 0, + "showlegend": false, + "type": "box", + "x": [ + "structure1", + "structure1", + "structure1", + "structure2", + "structure2", + "structure2" + ], + "x0": " ", + "xaxis": "x", + "y": [ + 1, + 0.5, + 0.75, + 1, + 0.25, + 0.7692307692307693 + ], + "y0": " ", + "yaxis": "y" + }, + { + "name": "structure1", + "orientation": "v", + "type": "box", + "y": [ + 1, + 0.5, + 0.75 + ] + }, + { + "name": "structure2", + "orientation": "v", + "type": "box", + "y": [ + 1, + 0.25, + 0.7692307692307693 + ] + } + ], + "layout": { + "autosize": false, + "boxmode": "overlay", + "font": { + "family": "Arial" + }, + "height": 1200, + "legend": { + "tracegroupgap": 0 + }, + "margin": { + "t": 60 + }, + "showlegend": false, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "" + }, + "width": 850, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Structure" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "global_bin_dsc" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "statistics_obj.get_summary_figure(metric=\"global_bin_dsc\", horizontal=False)\n", + "# This plots one bar for each group on this metric by default" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "error_y": { + "array": [ + 0.2041241452319315, + 0.2041241452319315, + 0.2041241452319315 + ], + "type": "data" + }, + "name": "structure1", + "type": "bar", + "x": [ + "algorithm1", + "algorithm2", + "algorithm3" + ], + "y": [ + 0.75, + 0.75, + 0.75 + ] + }, + { + "error_y": { + "array": [ + 0.31364435442884786, + 0.31364435442884786, + 0.31364435442884786 + ], + "type": "data" + }, + "name": "structure2", + "type": "bar", + "x": [ + "algorithm1", + "algorithm2", + "algorithm3" + ], + "y": [ + 0.673076923076923, + 0.673076923076923, + 0.673076923076923 + ] + } + ], + "layout": { + "autosize": false, + "barmode": "group", + "font": { + "family": "Arial" + }, + "height": 1200, + "showlegend": true, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "" + }, + "width": 850, + "xaxis": { + "title": { + "text": "Different setups and groups" + } + }, + "yaxis": { + "gridcolor": "gray", + "gridwidth": 1, + "showgrid": true, + "title": { + "text": "global_bin_dsc" + } + } + } + }, + "text/html": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# We can also make plots over multiple statistics objects (usually reflecting different algorithms/predictors)\n", + "from panoptica.panoptica_statistics import make_curve_over_setups\n", + "# we simulate this by multiplying our statistics object\n", + "make_curve_over_setups(\n", + " statistics_dict = {\n", + " \"algorithm1\": statistics_obj,\n", + " \"algorithm2\": statistics_obj,\n", + " \"algorithm3\": statistics_obj,\n", + " },\n", + " metric=\"global_bin_dsc\",\n", + ")\n", + "# of course, as we use the same statistic object multiple times, each pair of bars is identical" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "seg11panoptdev", + "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.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 353f9086637a63bfaec2d1c06ad6b8201427c472 Mon Sep 17 00:00:00 2001 From: "brainless-bot[bot]" <153751247+brainless-bot[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:44:04 +0000 Subject: [PATCH 2/2] Autoformat with black --- panoptica/example_aggregation.ipynb | 86 +++++++++++++++++------------ 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/panoptica/example_aggregation.ipynb b/panoptica/example_aggregation.ipynb index b120867..2c1a24e 100644 --- a/panoptica/example_aggregation.ipynb +++ b/panoptica/example_aggregation.ipynb @@ -122,37 +122,45 @@ "metadata": {}, "outputs": [], "source": [ - "reference_array = np.array([\n", - " [0,1,0,0,0],\n", - " [1,1,0,0,0],\n", - " [0,0,0,2,0],\n", - " [0,0,2,2,2],\n", - " [0,0,0,2,0],\n", - "])\n", + "reference_array = np.array(\n", + " [\n", + " [0, 1, 0, 0, 0],\n", + " [1, 1, 0, 0, 0],\n", + " [0, 0, 0, 2, 0],\n", + " [0, 0, 2, 2, 2],\n", + " [0, 0, 0, 2, 0],\n", + " ]\n", + ")\n", "\n", "# Lets give them names, in practice this should be sample/subject names for easy recognition\n", "predictions = {\n", - " \"subject_perfect\": np.array([\n", - " [0,1,0,0,0],\n", - " [1,1,0,0,0],\n", - " [0,0,0,2,0],\n", - " [0,0,2,2,2],\n", - " [0,0,0,2,0],\n", - " ]),\n", - " \"subject_horrible\": np.array([\n", - " [0,0,0,0,0],\n", - " [1,0,0,0,0],\n", - " [0,0,0,0,2],\n", - " [0,0,0,0,2],\n", - " [0,0,0,0,2],\n", - " ]),\n", - " \"subject_overprediction\": np.array([\n", - " [0,1,0,0,0],\n", - " [1,1,1,0,0],\n", - " [0,1,2,2,2],\n", - " [0,0,2,2,2],\n", - " [0,0,0,2,2],\n", - " ]),\n", + " \"subject_perfect\": np.array(\n", + " [\n", + " [0, 1, 0, 0, 0],\n", + " [1, 1, 0, 0, 0],\n", + " [0, 0, 0, 2, 0],\n", + " [0, 0, 2, 2, 2],\n", + " [0, 0, 0, 2, 0],\n", + " ]\n", + " ),\n", + " \"subject_horrible\": np.array(\n", + " [\n", + " [0, 0, 0, 0, 0],\n", + " [1, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 2],\n", + " [0, 0, 0, 0, 2],\n", + " [0, 0, 0, 0, 2],\n", + " ]\n", + " ),\n", + " \"subject_overprediction\": np.array(\n", + " [\n", + " [0, 1, 0, 0, 0],\n", + " [1, 1, 1, 0, 0],\n", + " [0, 1, 2, 2, 2],\n", + " [0, 0, 2, 2, 2],\n", + " [0, 0, 0, 2, 2],\n", + " ]\n", + " ),\n", "}" ] }, @@ -182,10 +190,13 @@ "source": [ "# let's calculate one sample as usual\n", "\n", - "# Let's define that label 1 and 2 (see arrays above) should be treated as different groups \n", + "# Let's define that label 1 and 2 (see arrays above) should be treated as different groups\n", "from panoptica.utils import SegmentationClassGroups, LabelGroup\n", + "\n", "# (in practice, this could be different classes of labels, instead of multiple instances of the same class)\n", - "segmentation_class_groups = SegmentationClassGroups({\"Structure1\": LabelGroup(1), \"Structure2\": LabelGroup(2)})\n", + "segmentation_class_groups = SegmentationClassGroups(\n", + " {\"Structure1\": LabelGroup(1), \"Structure2\": LabelGroup(2)}\n", + ")\n", "\n", "evaluator = Panoptica_Evaluator(\n", " expected_input=InputType.MATCHED_INSTANCE,\n", @@ -291,7 +302,11 @@ "import os\n", "\n", "output_file = str(Path(os.path.abspath(\"\")).parent.joinpath(\"example_aggregation.tsv\"))\n", - "aggregator = Panoptica_Aggregator(panoptica_evaluator=evaluator, output_file=output_file, log_times=True,)\n", + "aggregator = Panoptica_Aggregator(\n", + " panoptica_evaluator=evaluator,\n", + " output_file=output_file,\n", + " log_times=True,\n", + ")\n", "print(aggregator.evaluation_metrics)" ] }, @@ -486,7 +501,9 @@ ], "source": [ "# get a summary dictionary across groups and metrics\n", - "statistics_obj.get_summary_dict(include_across_group=False) # we set this to false because we only have on group, otherwise this would yield also the averages across all groups" + "statistics_obj.get_summary_dict(\n", + " include_across_group=False\n", + ") # we set this to false because we only have on group, otherwise this would yield also the averages across all groups" ] }, { @@ -2425,13 +2442,14 @@ "source": [ "# We can also make plots over multiple statistics objects (usually reflecting different algorithms/predictors)\n", "from panoptica.panoptica_statistics import make_curve_over_setups\n", + "\n", "# we simulate this by multiplying our statistics object\n", "make_curve_over_setups(\n", - " statistics_dict = {\n", + " statistics_dict={\n", " \"algorithm1\": statistics_obj,\n", " \"algorithm2\": statistics_obj,\n", " \"algorithm3\": statistics_obj,\n", - " },\n", + " },\n", " metric=\"global_bin_dsc\",\n", ")\n", "# of course, as we use the same statistic object multiple times, each pair of bars is identical"