tiamat-python 0.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ """
2
+ Protocol for readers.
3
+ """
4
+
5
+ from typing import Protocol
6
+
7
+ import numpy as np
8
+
9
+ from ..io import ImageAccessor
10
+ from ..metadata import ImageMetadata
11
+
12
+ CheckResult = bool | int | float
13
+
14
+
15
+ class ImageReader(Protocol):
16
+ """
17
+ Protocol for reading image data and metadata from a source.
18
+
19
+ Expected call order in a pipeline:
20
+ 1. `read_metadata` → supplies metadata to the first transformer's `transform_metadata`
21
+ 2. `read_image` → supplies image data to the first transformer's `transform_image`
22
+ """
23
+
24
+ def read_image(self, accessor: ImageAccessor) -> np.ndarray:
25
+ """
26
+ Read and return the image content.
27
+
28
+ Args:
29
+ accessor (ImageAccessor): Accessor defining which part of the image to read.
30
+
31
+ Returns:
32
+ np.ndarray: The resulting image data as a Numpy array.
33
+ """
34
+ raise NotImplementedError
35
+
36
+ def read_metadata(self) -> ImageMetadata:
37
+ """
38
+ Read and return metadata associated with the image.
39
+
40
+ Returns:
41
+ ImageMetadata: The metadata of the image containing shape, spatial and channel dimensions, spacing,
42
+ and other properties.
43
+ """
44
+
45
+ raise NotImplementedError
46
+
47
+ @classmethod
48
+ def check_file(cls, fname: str) -> bool | int | float:
49
+ """
50
+ Check if the reader is compatible with the given file.
51
+
52
+ Args:
53
+ fname (str): The file path or identifier.
54
+
55
+ Returns:
56
+ Truthy value if the file is supported. Can return a numeric
57
+ score indicating priority among multiple readers.
58
+ """
59
+ raise NotImplementedError