Skip to content

Commit 79dcd75

Browse files
committed
updated tutorials to modular_metrics PR
1 parent 183305d commit 79dcd75

3 files changed

Lines changed: 58 additions & 44 deletions

File tree

panoptica/example_spine_matched_instance.ipynb

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
"import numpy as np\n",
6363
"from auxiliary.nifti.io import read_nifti\n",
6464
"from rich import print as pprint\n",
65-
"from panoptica import MatchedInstancePair, Panoptic_Evaluator"
65+
"from panoptica import MatchedInstancePair, Panoptic_Evaluator\n",
66+
"from panoptica.metrics import Metrics"
6667
]
6768
},
6869
{
@@ -192,7 +193,7 @@
192193
"text": [
193194
"Panoptic: Start Evaluation\n",
194195
"-- Got MatchedInstancePair, will evaluate instances\n",
195-
"-- evaluate took 1.7750227451324463 seconds to execute.\n"
196+
"-- evaluate took 1.4501242637634277 seconds to execute.\n"
196197
]
197198
}
198199
],
@@ -201,7 +202,8 @@
201202
"\n",
202203
"evaluator = Panoptic_Evaluator(\n",
203204
" expected_input=MatchedInstancePair,\n",
204-
" iou_threshold=0.5,\n",
205+
" decision_metric=Metrics.IOU,\n",
206+
" decision_threshold=0.5,\n",
205207
")\n",
206208
"\n",
207209
"result, debug_data = evaluator.evaluate(sample)"
@@ -226,15 +228,15 @@
226228
"text": [
227229
"Number of instances in prediction: 22\n",
228230
"Number of instances in reference: 22\n",
229-
"True Positives (tp): 19\n",
230-
"False Positives (fp): 3\n",
231-
"False Negatives (fn): 3\n",
232-
"Recognition Quality / F1 Score (RQ): 0.8636363636363636\n",
233-
"Segmentation Quality (SQ): 0.8328184295330796 ± 0.15186064004517466\n",
231+
"True Positives (tp): 22\n",
232+
"False Positives (fp): 0\n",
233+
"False Negatives (fn): 0\n",
234+
"Recognition Quality / F1 Score (RQ): 1.0\n",
235+
"Segmentation Quality (SQ): 0.719252280051296 ± 0.15186064004517466\n",
234236
"Panoptic Quality (PQ): 0.719252280051296\n",
235-
"DSC-based Segmentation Quality (DQ_DSC): 0.900292616009954 ± 0.10253566174957332\n",
237+
"DSC-based Segmentation Quality (DQ_DSC): 0.7775254410995057 ± 0.10253566174957332\n",
236238
"DSC-based Panoptic Quality (PQ_DSC): 0.7775254410995057\n",
237-
"Average symmetric surface distance (ASSD): 0.250331887879225 ± 0.07696680402317076\n",
239+
"Average symmetric surface distance (ASSD): 0.2161957213502398 ± 0.07696680402317076\n",
238240
"ASSD-based Panoptic Quality (PQ_ASSD): 0.2161957213502398\n"
239241
]
240242
}
@@ -280,17 +282,17 @@
280282
"<span style=\"font-weight: bold\">{</span>\n",
281283
" <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",
282284
" <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",
283-
" <span style=\"color: #008000; text-decoration-color: #008000\">'tp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">19</span>,\n",
284-
" <span style=\"color: #008000; text-decoration-color: #008000\">'fp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>,\n",
285-
" <span style=\"color: #008000; text-decoration-color: #008000\">'fn'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>,\n",
286-
" <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",
287-
" <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",
285+
" <span style=\"color: #008000; text-decoration-color: #008000\">'tp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>,\n",
286+
" <span style=\"color: #008000; text-decoration-color: #008000\">'fp'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
287+
" <span style=\"color: #008000; text-decoration-color: #008000\">'fn'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0</span>,\n",
288+
" <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",
289+
" <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",
288290
" <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",
289291
" <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",
290-
" <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",
292+
" <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",
291293
" <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",
292294
" <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",
293-
" <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",
295+
" <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",
294296
" <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",
295297
" <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",
296298
"<span style=\"font-weight: bold\">}</span>\n",
@@ -301,17 +303,17 @@
301303
"\u001b[1m{\u001b[0m\n",
302304
" \u001b[32m'num_pred_instances'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
303305
" \u001b[32m'num_ref_instances'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
304-
" \u001b[32m'tp'\u001b[0m: \u001b[1;36m19\u001b[0m,\n",
305-
" \u001b[32m'fp'\u001b[0m: \u001b[1;36m3\u001b[0m,\n",
306-
" \u001b[32m'fn'\u001b[0m: \u001b[1;36m3\u001b[0m,\n",
307-
" \u001b[32m'rq'\u001b[0m: \u001b[1;36m0.8636363636363636\u001b[0m,\n",
308-
" \u001b[32m'sq'\u001b[0m: \u001b[1;36m0.8328184295330796\u001b[0m,\n",
306+
" \u001b[32m'tp'\u001b[0m: \u001b[1;36m22\u001b[0m,\n",
307+
" \u001b[32m'fp'\u001b[0m: \u001b[1;36m0\u001b[0m,\n",
308+
" \u001b[32m'fn'\u001b[0m: \u001b[1;36m0\u001b[0m,\n",
309+
" \u001b[32m'rq'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n",
310+
" \u001b[32m'sq'\u001b[0m: \u001b[1;36m0.719252280051296\u001b[0m,\n",
309311
" \u001b[32m'sq_sd'\u001b[0m: \u001b[1;36m0.15186064004517466\u001b[0m,\n",
310312
" \u001b[32m'pq'\u001b[0m: \u001b[1;36m0.719252280051296\u001b[0m,\n",
311-
" \u001b[32m'sq_dsc'\u001b[0m: \u001b[1;36m0.900292616009954\u001b[0m,\n",
313+
" \u001b[32m'sq_dsc'\u001b[0m: \u001b[1;36m0.7775254410995057\u001b[0m,\n",
312314
" \u001b[32m'sq_dsc_sd'\u001b[0m: \u001b[1;36m0.10253566174957332\u001b[0m,\n",
313315
" \u001b[32m'pq_dsc'\u001b[0m: \u001b[1;36m0.7775254410995057\u001b[0m,\n",
314-
" \u001b[32m'sq_assd'\u001b[0m: \u001b[1;36m0.250331887879225\u001b[0m,\n",
316+
" \u001b[32m'sq_assd'\u001b[0m: \u001b[1;36m0.2161957213502398\u001b[0m,\n",
315317
" \u001b[32m'sq_assd_sd'\u001b[0m: \u001b[1;36m0.07696680402317076\u001b[0m,\n",
316318
" \u001b[32m'pq_assd'\u001b[0m: \u001b[1;36m0.2161957213502398\u001b[0m\n",
317319
"\u001b[1m}\u001b[0m\n"
@@ -343,7 +345,7 @@
343345
"name": "python",
344346
"nbconvert_exporter": "python",
345347
"pygments_lexer": "ipython3",
346-
"version": "3.10.13"
348+
"version": "3.11.6"
347349
}
348350
},
349351
"nbformat": 4,

panoptica/example_spine_semantic.ipynb

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"cell_type": "code",
58-
"execution_count": 2,
58+
"execution_count": 13,
5959
"metadata": {},
6060
"outputs": [],
6161
"source": [
@@ -88,7 +88,7 @@
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 3,
91+
"execution_count": 2,
9292
"metadata": {},
9393
"outputs": [],
9494
"source": [
@@ -105,7 +105,7 @@
105105
},
106106
{
107107
"cell_type": "code",
108-
"execution_count": 4,
108+
"execution_count": 14,
109109
"metadata": {},
110110
"outputs": [
111111
{
@@ -181,7 +181,7 @@
181181
"-- Got SemanticPair, will approximate instances\n",
182182
"-- Got UnmatchedInstancePair, will match instances\n",
183183
"-- Got MatchedInstancePair, will evaluate instances\n",
184-
"-- evaluate took 4.660651922225952 seconds to execute.\n"
184+
"-- evaluate took 3.744478940963745 seconds to execute.\n"
185185
]
186186
}
187187
],
@@ -192,7 +192,6 @@
192192
" expected_input=SemanticPair,\n",
193193
" instance_approximator=ConnectedComponentsInstanceApproximator(),\n",
194194
" instance_matcher=NaiveThresholdMatching(),\n",
195-
" iou_threshold=0.5,\n",
196195
")\n",
197196
"\n",
198197
"result, debug_data = evaluator.evaluate(sample)"
@@ -208,7 +207,7 @@
208207
},
209208
{
210209
"cell_type": "code",
211-
"execution_count": 5,
210+
"execution_count": 16,
212211
"metadata": {},
213212
"outputs": [
214213
{
@@ -237,7 +236,7 @@
237236
},
238237
{
239238
"cell_type": "code",
240-
"execution_count": 6,
239+
"execution_count": 17,
241240
"metadata": {},
242241
"outputs": [
243242
{
@@ -261,7 +260,7 @@
261260
},
262261
{
263262
"cell_type": "code",
264-
"execution_count": 7,
263+
"execution_count": 18,
265264
"metadata": {},
266265
"outputs": [
267266
{
@@ -316,6 +315,13 @@
316315
"# get dict for further processing, e.g. for pandas\n",
317316
"pprint(\"results dict: \", result.to_dict())"
318317
]
318+
},
319+
{
320+
"cell_type": "code",
321+
"execution_count": null,
322+
"metadata": {},
323+
"outputs": [],
324+
"source": []
319325
}
320326
],
321327
"metadata": {
@@ -334,7 +340,7 @@
334340
"name": "python",
335341
"nbconvert_exporter": "python",
336342
"pygments_lexer": "ipython3",
337-
"version": "3.10.13"
343+
"version": "3.11.6"
338344
}
339345
},
340346
"nbformat": 4,

panoptica/example_spine_unmatched_instance.ipynb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"cell_type": "code",
58-
"execution_count": 2,
58+
"execution_count": 1,
5959
"metadata": {},
6060
"outputs": [],
6161
"source": [
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": 3,
87+
"execution_count": 2,
8888
"metadata": {},
8989
"outputs": [
9090
{
@@ -96,7 +96,7 @@
9696
" 107, 108, 109, 203, 204, 205, 206, 207, 208, 209], dtype=uint8))"
9797
]
9898
},
99-
"execution_count": 3,
99+
"execution_count": 2,
100100
"metadata": {},
101101
"output_type": "execute_result"
102102
}
@@ -118,7 +118,7 @@
118118
},
119119
{
120120
"cell_type": "code",
121-
"execution_count": 4,
121+
"execution_count": 3,
122122
"metadata": {},
123123
"outputs": [
124124
{
@@ -193,7 +193,7 @@
193193
"Panoptic: Start Evaluation\n",
194194
"-- Got UnmatchedInstancePair, will match instances\n",
195195
"-- Got MatchedInstancePair, will evaluate instances\n",
196-
"-- evaluate took 2.6646389961242676 seconds to execute.\n"
196+
"-- evaluate took 2.4123013019561768 seconds to execute.\n"
197197
]
198198
}
199199
],
@@ -202,7 +202,6 @@
202202
"evaluator = Panoptic_Evaluator(\n",
203203
" expected_input=UnmatchedInstancePair,\n",
204204
" instance_matcher=NaiveThresholdMatching(),\n",
205-
" iou_threshold=0.5,\n",
206205
")\n",
207206
"\n",
208207
"result, debug_data = evaluator.evaluate(sample)"
@@ -218,7 +217,7 @@
218217
},
219218
{
220219
"cell_type": "code",
221-
"execution_count": 5,
220+
"execution_count": 4,
222221
"metadata": {},
223222
"outputs": [
224223
{
@@ -247,7 +246,7 @@
247246
},
248247
{
249248
"cell_type": "code",
250-
"execution_count": 6,
249+
"execution_count": 5,
251250
"metadata": {},
252251
"outputs": [
253252
{
@@ -271,7 +270,7 @@
271270
},
272271
{
273272
"cell_type": "code",
274-
"execution_count": 7,
273+
"execution_count": 6,
275274
"metadata": {},
276275
"outputs": [
277276
{
@@ -326,6 +325,13 @@
326325
"# get dict for further processing, e.g. for pandas\n",
327326
"pprint(\"results dict: \", result.to_dict())"
328327
]
328+
},
329+
{
330+
"cell_type": "code",
331+
"execution_count": null,
332+
"metadata": {},
333+
"outputs": [],
334+
"source": []
329335
}
330336
],
331337
"metadata": {
@@ -344,7 +350,7 @@
344350
"name": "python",
345351
"nbconvert_exporter": "python",
346352
"pygments_lexer": "ipython3",
347-
"version": "3.10.13"
353+
"version": "3.11.6"
348354
}
349355
},
350356
"nbformat": 4,

0 commit comments

Comments
 (0)