Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make transform return the same type as input #1182

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/torchio/transforms/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import TypeVar
from typing import Union

import numpy as np
Expand Down Expand Up @@ -49,6 +50,8 @@
'Superior',
)

InputType = TypeVar('InputType', bound=TypeTransformInput)


class Transform(ABC):
"""Abstract class for all TorchIO transforms.
Expand Down Expand Up @@ -127,8 +130,8 @@ def __init__(

def __call__(
self,
data: TypeTransformInput,
) -> TypeTransformInput:
data: InputType,
) -> InputType:
"""Transform data and return a result of the same type.

Args:
Expand Down
Loading