Skip to content

Commit

Permalink
Fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Sep 23, 2024
1 parent 0475b39 commit a7ea6a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/torchio/transforms/augmentation/intensity/random_ghosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def __init__(
self.args_names = ['num_ghosts', 'axis', 'intensity', 'restore']

def apply_transform(self, subject: Subject) -> Subject:
axis: Union[int, Dict[str, int]]
num_ghosts: Union[int, Dict[str, int]]
intensity: Union[float, Dict[str, float]]
restore: Union[Optional[float], Dict[str, Optional[float]]]
for name, image in self.get_images_dict(subject).items():
if self.arguments_are_dict():
assert isinstance(self.axis, dict)
Expand Down Expand Up @@ -253,8 +257,8 @@ def _get_planes_to_modify(
) -> torch.Tensor:
slices = [slice(None)] * spectrum.ndim
slices[axis] = slice(None, None, num_ghosts)
slices = tuple(slices)
return spectrum[slices]
slices_tuple = tuple(slices)
return spectrum[slices_tuple]

@staticmethod
def _get_slices_to_restore(
Expand All @@ -271,6 +275,6 @@ def _get_slices_to_restore(
size_restore = int(np.round(restore_center * dim_shape))
slice_ = slice(mid_idx - size_restore // 2, mid_idx + size_restore // 2)

Check warning on line 276 in src/torchio/transforms/augmentation/intensity/random_ghosting.py

View check run for this annotation

Codecov / codecov/patch

src/torchio/transforms/augmentation/intensity/random_ghosting.py#L275-L276

Added lines #L275 - L276 were not covered by tests
slices[axis] = slice_
slices = tuple(slices)
restore_tensor = spectrum[slices]
return restore_tensor, slices
slices_tuple = tuple(slices)
restore_tensor = spectrum[slices_tuple]
return restore_tensor, slices_tuple

0 comments on commit a7ea6a8

Please sign in to comment.