Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions panoptica/example_spine_matched_instance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"import numpy as np\n",
"from auxiliary.nifti.io import read_nifti\n",
"from rich import print as pprint\n",
"from panoptica import MatchedInstancePair, Panoptic_Evaluator"
"from panoptica import MatchedInstancePair, Panoptic_Evaluator\n",
"from panoptica.metrics import Metrics"
]
},
{
Expand Down Expand Up @@ -192,7 +193,7 @@
"text": [
"Panoptic: Start Evaluation\n",
"-- Got MatchedInstancePair, will evaluate instances\n",
"-- evaluate took 1.7750227451324463 seconds to execute.\n"
"-- evaluate took 1.4501242637634277 seconds to execute.\n"
]
}
],
Expand All @@ -201,7 +202,8 @@
"\n",
"evaluator = Panoptic_Evaluator(\n",
" expected_input=MatchedInstancePair,\n",
" iou_threshold=0.5,\n",
" decision_metric=Metrics.IOU,\n",
" decision_threshold=0.5,\n",
")\n",
"\n",
"result, debug_data = evaluator.evaluate(sample)"
Expand All @@ -226,15 +228,15 @@
"text": [
"Number of instances in prediction: 22\n",
"Number of instances in reference: 22\n",
"True Positives (tp): 19\n",
"False Positives (fp): 3\n",
"False Negatives (fn): 3\n",
"Recognition Quality / F1 Score (RQ): 0.8636363636363636\n",
"Segmentation Quality (SQ): 0.8328184295330796 ± 0.15186064004517466\n",
"True Positives (tp): 22\n",
"False Positives (fp): 0\n",
"False Negatives (fn): 0\n",
"Recognition Quality / F1 Score (RQ): 1.0\n",
"Segmentation Quality (SQ): 0.719252280051296 ± 0.15186064004517466\n",
"Panoptic Quality (PQ): 0.719252280051296\n",
"DSC-based Segmentation Quality (DQ_DSC): 0.900292616009954 ± 0.10253566174957332\n",
"DSC-based Segmentation Quality (DQ_DSC): 0.7775254410995057 ± 0.10253566174957332\n",
"DSC-based Panoptic Quality (PQ_DSC): 0.7775254410995057\n",
"Average symmetric surface distance (ASSD): 0.250331887879225 ± 0.07696680402317076\n",
"Average symmetric surface distance (ASSD): 0.2161957213502398 ± 0.07696680402317076\n",
"ASSD-based Panoptic Quality (PQ_ASSD): 0.2161957213502398\n"
]
}
Expand Down Expand Up @@ -280,17 +282,17 @@
"<span style=\"font-weight: bold\">{</span>\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'num_pred_instances'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'num_ref_instances'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'tp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">19</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'fp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'fn'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'rq'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8636363636363636</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.8328184295330796</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'tp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'fp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'fn'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'rq'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.0</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.719252280051296</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_sd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.15186064004517466</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'pq'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.719252280051296</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_dsc'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.900292616009954</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_dsc'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7775254410995057</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_dsc_sd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.10253566174957332</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'pq_dsc'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.7775254410995057</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_assd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.250331887879225</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_assd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.2161957213502398</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'sq_assd_sd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.07696680402317076</span>,\n",
" <span style=\"color: #008000; text-decoration-color: #008000\">'pq_assd'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.2161957213502398</span>\n",
"<span style=\"font-weight: bold\">}</span>\n",
Expand All @@ -301,17 +303,17 @@
"\u001b[1m{\u001b[0m\n",
" \u001b[32m'num_pred_instances'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
" \u001b[32m'num_ref_instances'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
" \u001b[32m'tp'\u001b[0m: \u001b[1;36m19\u001b[0m,\n",
" \u001b[32m'fp'\u001b[0m: \u001b[1;36m3\u001b[0m,\n",
" \u001b[32m'fn'\u001b[0m: \u001b[1;36m3\u001b[0m,\n",
" \u001b[32m'rq'\u001b[0m: \u001b[1;36m0.8636363636363636\u001b[0m,\n",
" \u001b[32m'sq'\u001b[0m: \u001b[1;36m0.8328184295330796\u001b[0m,\n",
" \u001b[32m'tp'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
" \u001b[32m'fp'\u001b[0m: \u001b[1;36m0\u001b[0m,\n",
" \u001b[32m'fn'\u001b[0m: \u001b[1;36m0\u001b[0m,\n",
" \u001b[32m'rq'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n",
" \u001b[32m'sq'\u001b[0m: \u001b[1;36m0.719252280051296\u001b[0m,\n",
" \u001b[32m'sq_sd'\u001b[0m: \u001b[1;36m0.15186064004517466\u001b[0m,\n",
" \u001b[32m'pq'\u001b[0m: \u001b[1;36m0.719252280051296\u001b[0m,\n",
" \u001b[32m'sq_dsc'\u001b[0m: \u001b[1;36m0.900292616009954\u001b[0m,\n",
" \u001b[32m'sq_dsc'\u001b[0m: \u001b[1;36m0.7775254410995057\u001b[0m,\n",
" \u001b[32m'sq_dsc_sd'\u001b[0m: \u001b[1;36m0.10253566174957332\u001b[0m,\n",
" \u001b[32m'pq_dsc'\u001b[0m: \u001b[1;36m0.7775254410995057\u001b[0m,\n",
" \u001b[32m'sq_assd'\u001b[0m: \u001b[1;36m0.250331887879225\u001b[0m,\n",
" \u001b[32m'sq_assd'\u001b[0m: \u001b[1;36m0.2161957213502398\u001b[0m,\n",
" \u001b[32m'sq_assd_sd'\u001b[0m: \u001b[1;36m0.07696680402317076\u001b[0m,\n",
" \u001b[32m'pq_assd'\u001b[0m: \u001b[1;36m0.2161957213502398\u001b[0m\n",
"\u001b[1m}\u001b[0m\n"
Expand Down Expand Up @@ -343,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
24 changes: 15 additions & 9 deletions panoptica/example_spine_semantic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -88,7 +88,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -181,7 +181,7 @@
"-- Got SemanticPair, will approximate instances\n",
"-- Got UnmatchedInstancePair, will match instances\n",
"-- Got MatchedInstancePair, will evaluate instances\n",
"-- evaluate took 4.660651922225952 seconds to execute.\n"
"-- evaluate took 3.744478940963745 seconds to execute.\n"
]
}
],
Expand All @@ -192,7 +192,6 @@
" expected_input=SemanticPair,\n",
" instance_approximator=ConnectedComponentsInstanceApproximator(),\n",
" instance_matcher=NaiveThresholdMatching(),\n",
" iou_threshold=0.5,\n",
")\n",
"\n",
"result, debug_data = evaluator.evaluate(sample)"
Expand All @@ -208,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -237,7 +236,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand All @@ -261,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 18,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -316,6 +315,13 @@
"# get dict for further processing, e.g. for pandas\n",
"pprint(\"results dict: \", result.to_dict())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -334,7 +340,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
26 changes: 16 additions & 10 deletions panoptica/example_spine_unmatched_instance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -84,7 +84,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -96,7 +96,7 @@
" 107, 108, 109, 203, 204, 205, 206, 207, 208, 209], dtype=uint8))"
]
},
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -118,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -193,7 +193,7 @@
"Panoptic: Start Evaluation\n",
"-- Got UnmatchedInstancePair, will match instances\n",
"-- Got MatchedInstancePair, will evaluate instances\n",
"-- evaluate took 2.6646389961242676 seconds to execute.\n"
"-- evaluate took 2.4123013019561768 seconds to execute.\n"
]
}
],
Expand All @@ -202,7 +202,6 @@
"evaluator = Panoptic_Evaluator(\n",
" expected_input=UnmatchedInstancePair,\n",
" instance_matcher=NaiveThresholdMatching(),\n",
" iou_threshold=0.5,\n",
")\n",
"\n",
"result, debug_data = evaluator.evaluate(sample)"
Expand All @@ -218,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -247,7 +246,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -271,7 +270,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -326,6 +325,13 @@
"# get dict for further processing, e.g. for pandas\n",
"pprint(\"results dict: \", result.to_dict())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -344,7 +350,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down