Add exact transform parameter replay - #1495
Conversation
📖 Docs PreviewPreview of the documentation for this PR: 🔗 https://smokeshow.helpmanual.io/162c5808510w275s1w5o/ Built from 88d4d99 |
There was a problem hiding this comment.
Pull request overview
This PR introduces an “exact replay” pathway for TorchIO transforms by adding Transform.apply_with_params(), enabling callers to reapply a transform using a previously recorded parameter dict while preserving the standard execution lifecycle (wrapping/unwrapping, copy semantics, type restoration, and history recording).
Changes:
- Added
Transform.apply_with_params()plus shared internal execution via_execute()to avoid duplicating lifecycle logic. - Implemented validation for reserved per-instance batching fields (
_batch_size,_batched_keys,_keep) when replaying parameters. - Explicitly disabled parameter replay for composition-style transforms and opaque adapter transforms, and added targeted tests covering replay semantics.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_transforms_base.py | Adds comprehensive tests for exact-parameter replay behavior, history semantics, copying, and batched-param validation. |
| src/torchio/transforms/transform.py | Implements apply_with_params(), refactors execution into _execute(), and validates batched replay metadata. |
| src/torchio/transforms/monai_adapter.py | Marks MonaiAdapter as not supporting apply_with_params() due to lack of a single param kernel. |
| src/torchio/transforms/cornucopia_adapter.py | Marks CornucopiaAdapter as not supporting apply_with_params() for the same reason. |
| src/torchio/transforms/compose.py | Marks Compose/OneOf/SomeOf as not supporting replay and simplifies rebatching error handling to align with current batch-schema validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
530c9ed to
cf91c4e
Compare
4bd8001 to
2ea69be
Compare
cf91c4e to
2951b11
Compare
4be07a8 to
a13d20a
Compare
b2cb211 to
2253d34
Compare
663847d to
22ccd57
Compare
5c0ed59 to
6124888
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
f239e5b to
8fa6c2e
Compare
6124888 to
88d4d99
Compare
|
[Generated by a coding agent] Superseded by the simpler replacement stack:
Exact replay is retained in #1503, while #1502 removes private batching metadata from persisted histories. |
[Generated by a coding agent]
Summary
Transform.apply_with_params()for exact parameter application_batch_size,_batched_keys, and_keepdimensionsValidation
Stack (merge bottom-up)