Skip to content

237 240 per instance results#247

Merged
Hendrik-code merged 26 commits intomainfrom
237-240-per-instance-results
Apr 22, 2026
Merged

237 240 per instance results#247
Hendrik-code merged 26 commits intomainfrom
237-240-per-instance-results

Conversation

@ErikGro
Copy link
Copy Markdown
Collaborator

@ErikGro ErikGro commented Apr 10, 2026

This PR implements 237 240 respectively.

Global and averaged metrics are defined in the sample row.
Instance rows only define their instance metrics
The truncated example output looks like following:

subject_name endplate-n_ref_instances endplate-n_pred_instances endplate-tp endplate-fp endplate-fn endplate-prec endplate-rec endplate-rq endplate-sq endplate-sq_std endplate-pq endplate-sq_dsc endplate-sq_dsc_std endplate-pq_dsc endplate-global_bin_volume_pred endplate-global_bin_volume_ref endplate-global_bin_dsc endplate-global_bin_rvd endplate-computation_time ivd-n_ref_instances ivd-n_pred_instances ivd-tp ivd-fp ivd-fn ivd-prec ivd-rec ivd-rq ivd-sq ivd-sq_std ivd-pq ivd-sq_dsc ivd-sq_dsc_std ivd-pq_dsc ivd-global_bin_volume_pred ivd-global_bin_volume_ref ivd-global_bin_dsc ivd-global_bin_rvd ivd-computation_time sacrum-n_ref_instances sacrum-n_pred_instances sacrum-tp sacrum-fp sacrum-fn sacrum-prec sacrum-rec sacrum-rq sacrum-sq sacrum-sq_std sacrum-pq sacrum-sq_dsc sacrum-sq_dsc_std sacrum-pq_dsc sacrum-global_bin_volume_pred sacrum-global_bin_volume_ref sacrum-global_bin_dsc sacrum-global_bin_rvd sacrum-computation_time vertebra-n_ref_instances vertebra-n_pred_instances vertebra-tp vertebra-fp vertebra-fn vertebra-prec vertebra-rec vertebra-rq vertebra-sq vertebra-sq_std vertebra-pq vertebra-sq_dsc vertebra-sq_dsc_std vertebra-pq_dsc vertebra-global_bin_volume_pred vertebra-global_bin_volume_ref vertebra-global_bin_dsc vertebra-global_bin_rvd vertebra-computation_time
sample1 7 7 4 3 3 0.5714285714285714 0.5714285714285714 0.5714285714285714 0.7757607768614974 0.020970196469791622 0.4432918724922842 0.8735651300987373 0.013297939489101358 0.49918007434213557 15653 15446 0.6793787581594264 0.01340152790366438 0.03076695799973095 7 7 7 0 0 1.0 1.0 1.0 0.9356428989017713 0.02678689285966417 0.9356428989017713 0.9665515338708124 0.014455749243101751 0.9665515338708124 78770 77137 0.9423566613429801 0.02117012587992792 0.03775324999878649 1 1 1 0 0 1.0 1.0 1.0 0.9761063077643852 0.0 0.9761063077643852 0.9879087009935987 0.0 0.9879087009935987 45329 45836 0.9698239455931553 -0.011061174622567414 0.024147957999957725 7 7 7 0 0 1.0 1.0 1.0 0.9658619603341371 0.007220487600135381 0.9658619603341371 0.9826208051627631 0.0037474563305194635 0.9826208051627631 237614 239174 0.9631786034883428 -0.006522448092183933 0.06640583399712341
sample1-endplate_inst_0 0.799546485260771 0.8886088709677419
sample1-endplate_inst_1 0.7554438860971524 0.8606870229007634
sample1-endplate_inst_2 0.7937043282743114 0.8849890316515199
sample1-endplate_inst_3 0.7543484078137543 0.8599755948749237
sample1-ivd_inst_0 0.9554469273743017 0.9772159131490608
sample1-ivd_inst_1 0.932447646926368 0.9650431134933581
sample1-ivd_inst_2 0.970298615002802 0.9849254398439722
sample1-ivd_inst_3 0.9504240501965111 0.974581963446106
sample1-ivd_inst_4 0.9419905213270142 0.9701288559156579
sample1-ivd_inst_5 0.9158805031446541 0.9560935576528519
sample1-ivd_inst_6 0.8830120283407481 0.9378718935946797
sample1-sacrum_inst_0 0.9761063077643852 0.9879087009935987
sample1-vertebra_inst_0 0.9528324247452002 0.9758465833232188
sample1-vertebra_inst_1 0.9676380887834632 0.9835529148368208
sample1-vertebra_inst_2 0.9703972165845173 0.9849762356715078
sample1-vertebra_inst_3 0.9572474921713285 0.9781568207394954
sample1-vertebra_inst_4 0.9744055360604648 0.9870368759243838
sample1-vertebra_inst_5 0.9684790482253002 0.9839871540400098

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 10, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 10, 2026

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 10, 2026

🤖 I will now format your code with black. Check the status here.

@ErikGro ErikGro marked this pull request as draft April 10, 2026 19:56
@neuronflow neuronflow requested a review from Copilot April 11, 2026 07:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements per-instance metric persistence/output in the aggregator TSV to support downstream distribution/meta-analysis (issues #237 and #240), while adding safeguards in statistics/plotting to avoid double-counting when instance rows are present.

Changes:

  • Add optional TSV output of per-instance rows alongside the existing per-sample “master” row.
  • Extend PanopticaResult.to_dict() to optionally return [master_dict, inst_0_dict, …] for aggregator consumption.
  • Add statistics helpers/flags intended to exclude instance rows from summaries/figures by default.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
panoptica/panoptica_statistics.py Adds subject filtering helpers and “master-only” filtering for summaries/figures to avoid double counting with instance rows.
panoptica/panoptica_result.py Switches several metric IDs to be derived from Metric.*.result_id and adds optional per-instance dict export from list-metrics.
panoptica/panoptica_aggregator.py Adds output_individual_instance_metrics flag and writes additional _inst_ rows to TSV when enabled.
panoptica/metrics/metrics.py Introduces a result_id helper for metrics to standardize result key naming (sq_*).
panoptica/instance_evaluator.py Minor cleanup: remove redundant tp local and clarify return type comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread panoptica/panoptica_statistics.py Outdated
Comment thread panoptica/panoptica_statistics.py Outdated
Comment thread panoptica/panoptica_aggregator.py Outdated
Comment thread panoptica/panoptica_result.py
Comment thread panoptica/metrics/metrics.py
@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 13, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 13, 2026

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 13, 2026

🤖 I will now format your code with black. Check the status here.

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 13, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

@neuronflow
Copy link
Copy Markdown
Contributor

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 13, 2026

🤖 I will now format your code with black. Check the status here.

Comment thread panoptica/panoptica_aggregator.py
@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 13, 2026

What do you think about the export format?
The first row of each sample defines global and average (SQ) Metrics.
The following instance rows only set the values in the relevant semantic quality ("sq") columns.
The export is quite sparse and also it might be confusing that in SQ columns it is the average in the first and the individual values in the instance rows. Let me know what you think.
About the sparsity: an alternative format allowing nested values like in JSONL would be an option.

TODO: The Statistics package needs to be updated as well.

@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 20, 2026

/format

@ErikGro ErikGro marked this pull request as ready for review April 20, 2026 15:43
@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 20, 2026

🤖 I will now format your code with black. Check the status here.

@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 20, 2026

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 20, 2026

🤖 I will now format your code with black. Check the status here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread panoptica/utils/serialization.py
Comment thread panoptica/panoptica_aggregator.py
@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 21, 2026

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 21, 2026

🤖 I will now format your code with black. Check the status here.

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 21, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread panoptica/utils/serialization.py
Comment thread panoptica/utils/serialization.py
@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 22, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 22, 2026

🤖 Code Formatting Reminder

Hello there! 👋 It looks like the code in this pull request might benefit from some formatting improvements.
Fix the issues locally or use our auto format action by commenting /format on this PR!

Code style: black

@ErikGro
Copy link
Copy Markdown
Collaborator Author

ErikGro commented Apr 22, 2026

/format

@brainless-bot
Copy link
Copy Markdown
Contributor

brainless-bot Bot commented Apr 22, 2026

🤖 I will now format your code with black. Check the status here.

raise NotImplementedError(
"PanopticaAUTCResult does not support per-instance output; "
"set output_individual_instance_metrics=False on the aggregator when using is_autc=True."
)
Copy link
Copy Markdown
Collaborator Author

@ErikGro ErikGro Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We omit instance wise reporting for AUTC for now to keep complexity of tsv managable:
Combining them gives a roughly thresholds × instances blow-up of cells per subject, plus the question of which cells are meaningful (unmatched refs at a given threshold) vs. empty.

@Hendrik-code Hendrik-code merged commit a3f6ab7 into main Apr 22, 2026
13 checks passed
@Hendrik-code Hendrik-code deleted the 237-240-per-instance-results branch April 22, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] saving the calculated instance-wise metircs [FEATURE] Aggregator should write per-instance results

5 participants