Add subject mapping adapter examples - #1496
Conversation
📖 Docs PreviewPreview of the documentation for this PR: 🔗 https://smokeshow.helpmanual.io/1h4l0m671q3q0v2d215w/ Built from 8e30d6e |
There was a problem hiding this comment.
Pull request overview
This PR updates TorchIO’s MONAI and Cornucopia adapter transforms to apply per-subject logic via SubjectsBatch.map_subjects() (preserving batching semantics like history/annotations), tightens adapter output validation to avoid silently dropping unsupported outputs, and adds/links new documentation examples for writing batch-native and subject-mapped custom transforms.
Changes:
- Refactor
MonaiAdapterandCornucopiaAdapterto useSubjectsBatch.map_subjects()and fix probability gating edge case whenp=0and the random draw is exactly0. - Make adapter output handling stricter (e.g., explicit rejection of new tensor keys / non-tensor outputs) and add tests covering metadata updates, history/annotation preservation, and the
p=0edge case. - Add a new “Write a custom transform” how-to and update conceptual/migration docs + nav to reference the new batching/mapping and replay APIs.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| zensical.toml | Adds the new custom transform how-to page to site navigation. |
| tests/test_monai_adapter.py | Adds coverage for metadata updates, explicit rejection of new tensor fields, preserved history/annotations, and p=0 edge case. |
| tests/test_cornucopia_adapter.py | Adds coverage for preserved history/annotations, p=0 edge case, and non-tensor output rejection. |
| src/torchio/transforms/monai_adapter.py | Switches to map_subjects(), fixes p=0 edge case, and makes dict-transform outputs explicit/validated (no silent drops). |
| src/torchio/transforms/cornucopia_adapter.py | Switches to map_subjects(), fixes p=0 edge case, and enforces tensor outputs. |
| docs/how-to/custom-transform.md | New executable examples for vectorized image ops, batched metadata ops, subject-wise mapping, and exact replay. |
| docs/get-started/migration.md | Updates migration guidance to use map_subjects() and clarifies schema/annotation constraints. |
| docs/concepts/transforms.md | Updates schema rules, clarifies spatial+annotation behavior, and documents apply_with_params() replay with links to the new how-to. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b0b687 to
661c177
Compare
530c9ed to
cf91c4e
Compare
661c177 to
980611a
Compare
cf91c4e to
2951b11
Compare
4d0023c to
48cc8ed
Compare
2951b11 to
b2cb211
Compare
48cc8ed to
e0dd3a1
Compare
b2cb211 to
2253d34
Compare
e0dd3a1 to
09967c1
Compare
5c0ed59 to
6124888
Compare
7437809 to
ab7a8f1
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: baf5f11a-f67c-44dc-804e-6be849fa9160
ab7a8f1 to
8e30d6e
Compare
6124888 to
88d4d99
Compare
|
[Generated by a coding agent] Superseded by the simpler replacement stack:
The adapter and custom-transform features remain, now built on the simplified exact-history model. |
[Generated by a coding agent]
Summary
SubjectsBatch.map_subjects()Validation
Stack (merge bottom-up)