Add RankSEG integration tutorial - #2068
Conversation
Signed-off-by: statmlben <bdai.hk@protonmail.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a MONAI tutorial with ChangesRankSEG tutorial integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Notebook
participant MSD Pancreas Archive
participant Pancreas DiNTS Bundle
participant RankSEG
participant Dice Evaluation
Notebook->>MSD Pancreas Archive: download and verify case members
Notebook->>Pancreas DiNTS Bundle: load model and run sliding-window inference
Pancreas DiNTS Bundle-->>Notebook: return logits
Notebook->>RankSEG: decode softmax probabilities
RankSEG-->>Notebook: return prediction
Notebook->>Dice Evaluation: compare argmax and RankSEG predictions
Dice Evaluation-->>Notebook: return Dice scores
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@modules/rankseg_integration.ipynb`:
- Line 47: Update the dependency-check command in the notebook setup cell to
validate both MONAI and nibabel imports before skipping installation. Ensure any
installation runs through the active kernel interpreter, and retain the existing
MONAI extras including nibabel and tqdm so the later LoadImaged call can read
.nii.gz files.
- Around line 630-653: Update both torch.load calls for the architecture and
checkpoint artifacts in the model-loading flow to use weights_only=True instead
of explicitly enabling full pickle deserialization. Preserve the existing paths
and map_location settings, and only retain weights_only=False if the loaded
files require trusted non-tensor objects.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e68feaab-cd4b-4ade-99e2-419988bdcf7c
📒 Files selected for processing (3)
README.mdmodules/rankseg_integration.ipynbrunner.sh
ericspod
left a comment
There was a problem hiding this comment.
Hi @statmlben thanks for this tutorial as we had discussed. I think it's fine overall for the existing content, but we need a discussion on what Rankseg is and how the algorithm works. At the top you should describe what it is, how it differs from other components, what it's used for, what the implications of using it are, etc. This by no means needs the same details as in your paper but should be motivating enough so readers know what the notebook is demonstrating and whether they'd want to use it themselves or not. I think the Coderabbit comments should be looked at but I had responses here as well.
Signed-off-by: statmlben <bdai.hk@protonmail.com>
|
Thanks @ericspod for the feedback. I added an introductory section near the top of the notebook explaining what RankSEG is, how it differs from argmax, fixed thresholding, and morphology-based post-processing, and how the RMA workflow operates at a high level. The section also discusses suitable use cases, probability requirements, computational cost, and the need to validate improvements on representative data. I also addressed your inline suggestions by consolidating the dependency installation command and using the Bundle |
garciadias
left a comment
There was a problem hiding this comment.
Thanks for this tutorial — I built a GPU Docker container (monai:blackwell, RTX 5090), installed the notebook's declared dependencies exactly as specified, and ran the full ./runner.sh -t modules/rankseg_integration.ipynb end-to-end. It passed cleanly and reproduced the PR description's numbers exactly (Argmax macro Dice 0.7747, RankSEG macro Dice 0.8502, Pancreas 0.8764 -> 0.8898, Tumor 0.6730 -> 0.8106). The RankSEG/RankSEGd transform code, shape handling, and Dice evaluation are all correct.
I left three inline comments. The main one (major) is that the MSD Task07 Pancreas case is downloaded from an unofficial personal Hugging Face account (MedOtter/msd-pancreas) rather than a MONAI-controlled source, unlike every other MSD download in this repo — I've included a concrete alternative (MONAI's own S3 mirror, which supports HTTP range requests) in that comment. The other two are minor (pinning the rankseg dependency, and linking to a fixed commit rather than a moving branch for an external benchmark claim).
|
Hi @garciadias , thank you for the detailed review. I addressed all three comments by switching to MONAI's official MSD S3 source with integrity checks, pinning Thanks again for helping improve the tutorial's provenance and reproducibility |
Signed-off-by: statmlben <bdai.hk@protonmail.com>
Signed-off-by: statmlben <bdai.hk@protonmail.com>
e245db0 to
1efa798
Compare
garciadias
left a comment
There was a problem hiding this comment.
All three review findings are resolved:
- The MSD Task07 Pancreas case now downloads from MONAI's own official S3 mirror (msd-for-monai.s3-us-west-2.amazonaws.com), pinned to an immutable S3 object version, via HTTP range requests that validate the tar header (name, size, type) and verify a SHA-256 digest of the extracted bytes — a more rigorous fix than what I suggested.
- rankseg is now pinned to ==0.0.5.
- The reproducibility link now points to a fixed commit SHA instead of the main branch.
I re-verified by rebuilding a clean GPU Docker container (monai:blackwell, RTX 5090) against a fresh worktree at the latest commit, installing the notebook's declared dependencies exactly as specified, and running the full ./runner.sh -t modules/rankseg_integration.ipynb end-to-end. It passed and reproduced identical results (Argmax macro Dice 0.7747, RankSEG macro Dice 0.8502, Pancreas 0.8764 -> 0.8898, Tumor 0.6730 -> 0.8106). I also independently confirmed the downloaded image and label files' SHA-256 hashes match the values hardcoded in the notebook. LGTM.
|
Thanks @garciadias for the thorough re-review and independent verification, much appreciated! Hi @ericspod, I’ve addressed the requested changes, including the introductory discussion of RankSEG and the dependency/model-loading updates. @garciadias has also re-run the complete notebook in a clean GPU environment and approved the PR. The remaining Actions checks were cancelled by GitHub infrastructure errors before the repository code was executed ( |
Sorry @statmlben, somehow GitHub failed to run some of the CI, and this got stuck for a while. Now that everything is passing, we can just wait for @ericspod to approve and merge. |
Related to MONAI-#8908
Description
This PR adds a runnable tutorial demonstrating how to use RankSEG as an optional third-party post-processing transform in a MONAI workflow.
The tutorial:
pancreas_ct_dints_segmentationMONAI Bundle and a real MSD Task07 Pancreas case;RankSEGtransform;RankSEGdtransform in a MONAIComposepost-processing pipeline;This PR also adds the tutorial to the repository README and registers it in
doesnt_contain_max_epochsbecause it is an inference-only notebook.Checks
Results
Summary by CodeRabbit
New Features
Documentation