Skip to content

Feature/multi aggregation eval - #31

Merged
ejdam87 merged 241 commits into
masterfrom
feature/multi-aggregation-eval
Jul 26, 2026
Merged

Feature/multi aggregation eval#31
ejdam87 merged 241 commits into
masterfrom
feature/multi-aggregation-eval

Conversation

@ejdam87

@ejdam87 ejdam87 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

This PR adds aggregator evaluation and related

Summary by CodeRabbit

  • New Features
    • Added multi-aggregator slide-level evaluation for prediction experiments.
    • Reports results from max, mean-pool-max, top-k, and majority-vote aggregation methods.
    • Logs classification metrics, including accuracy, precision, recall, specificity, and negative predictive value.
    • Added experiment configurations across supported models, embedding workflows, stain data, and test datasets.
    • Added kernel-size, span, and top-k estimation experiment configurations.

@ejdam87
ejdam87 requested review from a team, Adames4 and vejtek July 24, 2026 12:42
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ejdam87, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ff8dfbbe-c76a-4859-b486-c601942f3940

📥 Commits

Reviewing files that changed from the base of the PR and between 74985a7 and b46c2be.

📒 Files selected for processing (7)
  • preprocessing/embeddings/tile_embeddings.py
  • preprocessing/masks/quality_control_v2.py
  • prostate_cancer/callbacks/cam_callback.py
  • prostate_cancer/callbacks/multi_aggregator_eval_callback.py
  • prostate_cancer/datamodule/datasets/base.py
  • prostate_cancer/datamodule/datasets/embeddings_dataset.py
  • prostate_cancer/datamodule/datasets/tile_dataset.py
📝 Walkthrough

Walkthrough

Adds MultiAggregatorEvalCallback for parallel slide-level aggregation, thresholding, majority voting, JSON/MLflow output, and metrics logging, plus Hydra configurations for embedding, image, and aggregator-estimation experiments.

Changes

Multi-aggregator callback and experiment configurations

Layer / File(s) Summary
Callback pipeline and wiring
prostate_cancer/callbacks/*, configs/callbacks/multi_aggregator_eval.yaml
Aggregates prediction tiles with max, mean-pool-max, and top-k aggregators; records per-aggregator and majority-vote results; logs JSON artifacts and classification metrics.
Embedding evaluation experiments
configs/experiment/predict/embeddings/*/multi_aggregator_eval/*
Adds PGP and Virchow2 base and MMCi TL-test Hydra compositions with aggregator parameters and evaluation metadata.
Image model evaluation experiments
configs/experiment/predict/images/{google_vit,resnet50,vgg16}/multi_aggregator_eval/*
Adds multi-aggregator evaluation configurations for standard, stain, and 224-sized image prediction variants.
Aggregator estimation experiments
configs/experiment/predict/images/google_vit/estimations/*
Adds mean-pool-max, span, and top-k estimation configurations with tiling, thresholds, and parameter sweep ranges.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Lightning
  participant MultiAggregatorEvalCallback
  participant Aggregators
  participant MLflow
  Lightning->>MultiAggregatorEvalCallback: deliver prediction batches
  MultiAggregatorEvalCallback->>Aggregators: update tile outputs
  Aggregators-->>MultiAggregatorEvalCallback: return slide predictions
  MultiAggregatorEvalCallback->>MLflow: log result tables and metrics
Loading

Suggested reviewers: adames4, vejtek

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: adding multi-aggregation evaluation support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/multi-aggregation-eval

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_base.yaml`:
- Around line 15-19: Update top_k_aggregator in
configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_base.yaml,
configs/experiment/predict/images/google_vit/estimations/stain_top_k_estimation.yaml,
and
configs/experiment/predict/images/google_vit/estimations/top_k_estimation.yaml
so no configuration combines kernel_size: 1 with k greater than 1; ensure k is
less than or equal to kernel_size in every affected multi-aggregator estimator
configuration.

In `@prostate_cancer/callbacks/multi_aggregator_eval_callback.py`:
- Around line 28-31: Update the module or class docstring around the aggregation
description to insert a blank line after the one-line summary and before the
longer description, satisfying Ruff D205 without changing the documented
behavior.
- Around line 113-115: Update the target handling in the callback’s prediction
aggregation flow around slide_name and target: require a non-missing carcinoma
target before appending results to stored tables, and raise a clear error when
it is absent. Ensure _compute_metrics only receives valid labeled targets,
preserving the existing metric computation path.
- Around line 78-87: Update the validation before the `cast` in the callback
setup to reject both a missing `trainer.datamodule` attribute and a `None`
datamodule value, raising the existing intended `ValueError` before accessing
`datamodule.predict`; preserve the existing `TileDataModule` cast and slide
selection flow for valid values.
- Around line 139-162: Update on_predict_epoch_end to gather and merge tables
and majority_table from all distributed ranks before computing metrics or
writing artifacts. Restrict JSON generation, MLflow artifact logging, and
mlflow.log_metrics to global-zero, using the merged data so each slide and
majority-vote result is logged once.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e5d3cfb2-108b-4a56-ad85-b5620609a5e6

📥 Commits

Reviewing files that changed from the base of the PR and between 4e5ca5d and 74985a7.

📒 Files selected for processing (37)
  • configs/callbacks/multi_aggregator_eval.yaml
  • configs/experiment/predict/embeddings/pgp/multi_aggregator_eval/base.yaml
  • configs/experiment/predict/embeddings/pgp/multi_aggregator_eval/mmci_tl_test.yaml
  • configs/experiment/predict/embeddings/pgp/multi_aggregator_eval/stain_base.yaml
  • configs/experiment/predict/embeddings/pgp/multi_aggregator_eval/stain_mmci_tl_test.yaml
  • configs/experiment/predict/embeddings/virchow2/multi_aggregator_eval/base.yaml
  • configs/experiment/predict/embeddings/virchow2/multi_aggregator_eval/mmci_tl_test.yaml
  • configs/experiment/predict/embeddings/virchow2/multi_aggregator_eval/stain_base.yaml
  • configs/experiment/predict/embeddings/virchow2/multi_aggregator_eval/stain_mmci_tl_test.yaml
  • configs/experiment/predict/images/google_vit/estimations/mpm_estimation.yaml
  • configs/experiment/predict/images/google_vit/estimations/span_estimation.yaml
  • configs/experiment/predict/images/google_vit/estimations/stain_mpm_estimation.yaml
  • configs/experiment/predict/images/google_vit/estimations/stain_span_estimation.yaml
  • configs/experiment/predict/images/google_vit/estimations/stain_top_k_estimation.yaml
  • configs/experiment/predict/images/google_vit/estimations/top_k_estimation.yaml
  • configs/experiment/predict/images/google_vit/multi_aggregator_eval/base.yaml
  • configs/experiment/predict/images/google_vit/multi_aggregator_eval/mmci_tl_test.yaml
  • configs/experiment/predict/images/google_vit/multi_aggregator_eval/stain_base.yaml
  • configs/experiment/predict/images/google_vit/multi_aggregator_eval/stain_mmci_tl_test.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/base.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/base_224.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/mmci_tl_test.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/mmci_tl_test_224.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_base.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_base_224.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_mmci_tl_test.yaml
  • configs/experiment/predict/images/resnet50/multi_aggregator_eval/stain_mmci_tl_test_224.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/base.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/base_224.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/mmci_tl_test.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/mmci_tl_test_224.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/stain_base.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/stain_base_224.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/stain_mmci_tl_test.yaml
  • configs/experiment/predict/images/vgg16/multi_aggregator_eval/stain_mmci_tl_test_224.yaml
  • prostate_cancer/callbacks/__init__.py
  • prostate_cancer/callbacks/multi_aggregator_eval_callback.py

Comment thread prostate_cancer/callbacks/multi_aggregator_eval_callback.py Outdated
Comment thread prostate_cancer/callbacks/multi_aggregator_eval_callback.py
Comment thread prostate_cancer/callbacks/multi_aggregator_eval_callback.py
Comment thread prostate_cancer/callbacks/multi_aggregator_eval_callback.py
@ejdam87
ejdam87 merged commit 3a07ef2 into master Jul 26, 2026
3 checks passed
@ejdam87
ejdam87 deleted the feature/multi-aggregation-eval branch July 26, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants