tiamat-python 0.1.15__tar.gz → 0.1.16__tar.gz
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.
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/PKG-INFO +1 -1
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/color.py +29 -3
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/intensity_mapping.py +46 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/PKG-INFO +1 -1
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/LICENSE +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/README.md +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/README.rst +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/pyproject.toml +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/setup.cfg +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/setup.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tests/test_metadata.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tests/test_package.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/__init__.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/array.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/cache.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/cli.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/constants.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/errors.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/io.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/metadata/__init__.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/metadata/dimensions.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/metadata/metadata.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/pipeline.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/__init__.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/factory.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/generic.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/memory.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/nifti.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/pipeline.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/processing.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/protocol.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/stack.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/readers/zarr.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/serialization.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/__init__.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/access.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/affine.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/axes.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/coordinates.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/dfield.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/mask.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/metadata.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/normalization.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/protocol.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat/transformers/view.py +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/SOURCES.txt +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/dependency_links.txt +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/entry_points.txt +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/requires.txt +0 -0
- {tiamat_python-0.1.15 → tiamat_python-0.1.16}/tiamat_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tiamat-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Tiled Image Access, Manipulation, and Analysis Toolkit
|
|
5
5
|
Author-email: "Big Data Analytics Group, Forschungszentrum Juelich, Institute of Neuroscience and Medicine (INM-1)" <inm1-bda@fz-juelich.de>
|
|
6
6
|
License:
|
|
@@ -19,6 +19,7 @@ class LUTTransformer(Transformer):
|
|
|
19
19
|
color_map: str | np.ndarray | list | tuple,
|
|
20
20
|
vmin: float | None = None,
|
|
21
21
|
vmax: float | None = None,
|
|
22
|
+
nan_color: float | tuple[float, ...] | None = None,
|
|
22
23
|
) -> None:
|
|
23
24
|
"""
|
|
24
25
|
Initialize a LUTTransformer.
|
|
@@ -30,11 +31,14 @@ class LUTTransformer(Transformer):
|
|
|
30
31
|
matplotlib colormap name. If `None`, metadata.value_range[0] is used.
|
|
31
32
|
vmax: Optional upper bound used for normalization when `color_map` is a
|
|
32
33
|
matplotlib colormap name. If `None`, metadata.value_range[1] is used.
|
|
34
|
+
nan_color: Optional color value used for NaN pixels after color mapping.
|
|
35
|
+
If `None`, the colormap's default NaN behavior is preserved.
|
|
33
36
|
"""
|
|
34
37
|
|
|
35
38
|
self.color_map = color_map
|
|
36
39
|
self.vmin = vmin
|
|
37
40
|
self.vmax = vmax
|
|
41
|
+
self.nan_color = nan_color
|
|
38
42
|
|
|
39
43
|
def transform_access(self, accessor: ImageAccessor, metadata: ImageMetadata) -> ImageAccessor:
|
|
40
44
|
"""
|
|
@@ -70,9 +74,31 @@ class LUTTransformer(Transformer):
|
|
|
70
74
|
vmin = self.vmin if self.vmin is not None else metadata_vmin
|
|
71
75
|
vmax = self.vmax if self.vmax is not None else metadata_vmax
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
nan_mask = None
|
|
78
|
+
if self.nan_color is not None:
|
|
79
|
+
nan_mask = np.isnan(image)
|
|
80
|
+
image = np.where(nan_mask, vmin, image)
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
mapped_image = self._apply_color_map(
|
|
83
|
+
image=image,
|
|
84
|
+
value_range=(vmin, vmax),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if self.nan_color is not None and np.any(nan_mask):
|
|
88
|
+
output_channels = mapped_image.shape[-1] if mapped_image.ndim > image.ndim else None
|
|
89
|
+
if np.isscalar(self.nan_color):
|
|
90
|
+
nan_color = (self.nan_color,) * 3
|
|
91
|
+
else:
|
|
92
|
+
nan_color = tuple(self.nan_color)
|
|
93
|
+
|
|
94
|
+
if len(nan_color) == 3 and output_channels == 4:
|
|
95
|
+
nan_color = (*nan_color, 1)
|
|
96
|
+
elif len(nan_color) != output_channels:
|
|
97
|
+
raise ValueError("nan_color length must match the output channel count")
|
|
98
|
+
|
|
99
|
+
mapped_image[nan_mask] = nan_color
|
|
100
|
+
|
|
101
|
+
return mapped_image
|
|
76
102
|
|
|
77
103
|
def _apply_color_map(self, image: np.ndarray, value_range: tuple[float, float]) -> np.ndarray:
|
|
78
104
|
"""
|
|
@@ -100,7 +126,7 @@ class LUTTransformer(Transformer):
|
|
|
100
126
|
elif isinstance(self.color_map, (np.ndarray, (tuple, list))):
|
|
101
127
|
# Color map provided as indexable array.
|
|
102
128
|
color_map = np.asarray(self.color_map)
|
|
103
|
-
return color_map[image]
|
|
129
|
+
return color_map[image.astype(int)]
|
|
104
130
|
else:
|
|
105
131
|
raise RuntimeError(f"Unknown type for color map: {type(self.color_map)}")
|
|
106
132
|
|
|
@@ -103,6 +103,52 @@ class MappingTransformer(Transformer):
|
|
|
103
103
|
return self.mapping_function(value)
|
|
104
104
|
|
|
105
105
|
|
|
106
|
+
class ReplaceValueTransformer(MappingTransformer):
|
|
107
|
+
"""
|
|
108
|
+
Replace one numeric value with another.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
def __init__(
|
|
112
|
+
self,
|
|
113
|
+
value_to_replace: float,
|
|
114
|
+
replacement_value: float,
|
|
115
|
+
target_dtype: type[np.floating] = np.float32,
|
|
116
|
+
) -> None:
|
|
117
|
+
"""
|
|
118
|
+
Initialize the transformer.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
value_to_replace: Numeric value to replace. NaN is supported.
|
|
122
|
+
replacement_value: Numeric value to use as the replacement.
|
|
123
|
+
target_dtype: Floating point dtype for the transformed image.
|
|
124
|
+
Defaults to np.float32.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
super().__init__(
|
|
128
|
+
mapping_function=self._replace_value(
|
|
129
|
+
value_to_replace,
|
|
130
|
+
replacement_value,
|
|
131
|
+
),
|
|
132
|
+
target_dtype=target_dtype,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
@staticmethod
|
|
136
|
+
def _replace_value(value_to_replace: float, replacement_value: float) -> Callable:
|
|
137
|
+
"""Create a mapping function that also supports matching NaN."""
|
|
138
|
+
|
|
139
|
+
if np.isnan(value_to_replace):
|
|
140
|
+
|
|
141
|
+
def mapping_function(input_value):
|
|
142
|
+
return np.where(np.isnan(input_value), replacement_value, input_value)
|
|
143
|
+
|
|
144
|
+
else:
|
|
145
|
+
|
|
146
|
+
def mapping_function(input_value):
|
|
147
|
+
return np.where(input_value == value_to_replace, replacement_value, input_value)
|
|
148
|
+
|
|
149
|
+
return mapping_function
|
|
150
|
+
|
|
151
|
+
|
|
106
152
|
# maybe only in tiamat-openseadragon?
|
|
107
153
|
# Commen used functions
|
|
108
154
|
class LogIntensityMappingTransformer(MappingTransformer):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tiamat-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Tiled Image Access, Manipulation, and Analysis Toolkit
|
|
5
5
|
Author-email: "Big Data Analytics Group, Forschungszentrum Juelich, Institute of Neuroscience and Medicine (INM-1)" <inm1-bda@fz-juelich.de>
|
|
6
6
|
License:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|