Skip to content

Commit 6d7902d

Browse files
committed
Address typing errors
1 parent 712fc70 commit 6d7902d

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/torchio/data/image.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -749,36 +749,6 @@ def to_ras(self) -> Image:
749749
return ToCanonical()(self)
750750
return self
751751

752-
def to_video(
753-
self,
754-
output_path: TypePath,
755-
frame_rate: float | None = 15,
756-
seconds: float | None = None,
757-
direction: str = 'I',
758-
verbosity: str = 'error',
759-
) -> None:
760-
"""Create a video showing all image slices along a specified direction.
761-
762-
Args:
763-
output_path: Path to the output video file.
764-
frame_rate: Number of frames per second (FPS).
765-
seconds: Target duration of the full video.
766-
direction:
767-
verbosity:
768-
769-
.. note:: Only ``frame_rate`` or ``seconds`` may (and must) be specified.
770-
"""
771-
from ..visualization import make_video # avoid circular import
772-
773-
make_video(
774-
self.to_ras(),
775-
output_path,
776-
frame_rate=frame_rate,
777-
seconds=seconds,
778-
direction=direction,
779-
verbosity=verbosity,
780-
)
781-
782752
def get_center(self, lps: bool = False) -> TypeTripletFloat:
783753
"""Get image center in RAS+ or LPS+ coordinates.
784754
@@ -917,6 +887,36 @@ def hist(self, **kwargs) -> None:
917887
x = self.data.flatten().numpy()
918888
plot_histogram(x, **kwargs)
919889

890+
def to_video(
891+
self,
892+
output_path: TypePath,
893+
frame_rate: float | None = 15,
894+
seconds: float | None = None,
895+
direction: str = 'I',
896+
verbosity: str = 'error',
897+
) -> None:
898+
"""Create a video showing all image slices along a specified direction.
899+
900+
Args:
901+
output_path: Path to the output video file.
902+
frame_rate: Number of frames per second (FPS).
903+
seconds: Target duration of the full video.
904+
direction:
905+
verbosity:
906+
907+
.. note:: Only ``frame_rate`` or ``seconds`` may (and must) be specified.
908+
"""
909+
from ..visualization import make_video # avoid circular import
910+
911+
make_video(
912+
self.to_ras(), # type: ignore[arg-type]
913+
output_path,
914+
frame_rate=frame_rate,
915+
seconds=seconds,
916+
direction=direction,
917+
verbosity=verbosity,
918+
)
919+
920920

921921
class LabelMap(Image):
922922
"""Image whose pixel values represent segmentation labels.

src/torchio/visualization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ def make_video(
358358
)
359359
warnings.warn(message, RuntimeWarning, stacklevel=2)
360360
spacing_iso = min(spacing_h, spacing_w)
361-
target = spacing_f, spacing_iso, spacing_iso
362-
image = Resample(target)(image) # type: ignore[assignment]
361+
target_spacing = spacing_f, spacing_iso, spacing_iso
362+
image = Resample(target_spacing)(image) # type: ignore[assignment]
363363

364364
# Check that height and width are multiples of 2 for H.265 encoding
365365
num_frames, height, width = image.spatial_shape

0 commit comments

Comments
 (0)