Add exact transform parameter replay#1495
Open
fepegar wants to merge 5 commits into
Open
Conversation
Contributor
📖 Docs PreviewPreview of the documentation for this PR: 🔗 https://smokeshow.helpmanual.io/454c2e0c26592v3m3y3v/ Built from 6124888 |
This was referenced Jul 13, 2026
Contributor
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.
fepegar
force-pushed
the
fepegar/exact-transform-params
branch
from
July 13, 2026 21:33
530c9ed to
cf91c4e
Compare
fepegar
force-pushed
the
fepegar/lossless-subject-batches
branch
from
July 13, 2026 21:33
4bd8001 to
2ea69be
Compare
fepegar
force-pushed
the
fepegar/exact-transform-params
branch
from
July 13, 2026 21:47
cf91c4e to
2951b11
Compare
fepegar
force-pushed
the
fepegar/lossless-subject-batches
branch
from
July 13, 2026 22:15
4be07a8 to
a13d20a
Compare
fepegar
force-pushed
the
fepegar/exact-transform-params
branch
2 times, most recently
from
July 13, 2026 22:48
b2cb211 to
2253d34
Compare
fepegar
force-pushed
the
fepegar/exact-transform-params
branch
from
July 13, 2026 23:13
663847d to
22ccd57
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
fepegar
force-pushed
the
fepegar/exact-transform-params
branch
from
July 14, 2026 09:01
5c0ed59 to
6124888
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Generated by a coding agent]
Summary
Transform.apply_with_params()for exact parameter application_batch_size,_batched_keys, and_keepdimensionsValidation
Stack (merge bottom-up)