ngio 0.4.2__py3-none-any.whl → 0.4.4__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.
ngio/images/_image.py CHANGED
@@ -801,7 +801,7 @@ def derive_image_container(
801
801
  pixelsize=pixel_size.x,
802
802
  z_spacing=pixel_size.z,
803
803
  time_spacing=pixel_size.t,
804
- levels=ref_meta.levels,
804
+ levels=ref_meta.paths,
805
805
  yx_scaling_factor=ref_meta.yx_scaling(),
806
806
  z_scaling_factor=ref_meta.z_scaling(),
807
807
  time_unit=pixel_size.time_unit,
ngio/images/_label.py CHANGED
@@ -318,7 +318,7 @@ def derive_label(
318
318
  pixelsize=ref_image.pixel_size.x,
319
319
  z_spacing=ref_image.pixel_size.z,
320
320
  time_spacing=ref_image.pixel_size.t,
321
- levels=ref_meta.levels,
321
+ levels=ref_meta.paths,
322
322
  yx_scaling_factor=ref_meta.yx_scaling(),
323
323
  z_scaling_factor=ref_meta.z_scaling(),
324
324
  time_unit=ref_image.pixel_size.time_unit,
@@ -102,6 +102,20 @@ def valid_hex_color(v: str) -> bool:
102
102
  return True
103
103
 
104
104
 
105
+ def into_valid_hex_color(v: str) -> str:
106
+ """Convert a string into a valid hexadecimal color.
107
+
108
+ If the string is already a valid hexadecimal color, return it.
109
+ Otherwise, return a hexadecimal color based on the hash of the string.
110
+ """
111
+ # strip leading '#' if present
112
+ v = v.lstrip("#")
113
+ if valid_hex_color(v):
114
+ return v
115
+
116
+ return NgioColors.semi_random_pick(v.lower()).value
117
+
118
+
105
119
  class ChannelVisualisation(BaseModel):
106
120
  """Channel visualisation model.
107
121
 
@@ -135,13 +149,10 @@ class ChannelVisualisation(BaseModel):
135
149
  """
136
150
  if value is None:
137
151
  return NgioColors.semi_random_pick().value
138
- if isinstance(value, str) and valid_hex_color(value):
139
- return value
152
+ if isinstance(value, str):
153
+ return into_valid_hex_color(value)
140
154
  elif isinstance(value, NgioColors):
141
155
  return value.value
142
- elif isinstance(value, str):
143
- value_lower = value.lower()
144
- return NgioColors.semi_random_pick(value_lower).value
145
156
  else:
146
157
  raise NgioValueError(f"Invalid color {value}.")
147
158
 
@@ -159,19 +170,6 @@ class ChannelVisualisation(BaseModel):
159
170
  data["end"] = start + 1
160
171
  return data
161
172
 
162
- @model_validator(mode="after")
163
- def check_model(self) -> "ChannelVisualisation":
164
- """Check that the start and end values are within the min and max values."""
165
- if self.start < self.min or self.start > self.max:
166
- raise NgioValidationError(
167
- f"Start value {self.start} is out of range [{self.min}, {self.max}]"
168
- )
169
- if self.end < self.min or self.end > self.max:
170
- raise NgioValidationError(
171
- f"End value {self.end} is out of range [{self.min}, {self.max}]"
172
- )
173
- return self
174
-
175
173
  @classmethod
176
174
  def default_init(
177
175
  cls,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngio
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Next Generation file format IO
5
5
  Project-URL: homepage, https://github.com/BioVisionCenter/ngio
6
6
  Project-URL: repository, https://github.com/BioVisionCenter/ngio
@@ -23,6 +23,7 @@ Requires-Dist: filelock
23
23
  Requires-Dist: numpy
24
24
  Requires-Dist: ome-zarr-models
25
25
  Requires-Dist: pandas>=1.2.0
26
+ Requires-Dist: pillow
26
27
  Requires-Dist: polars
27
28
  Requires-Dist: pooch
28
29
  Requires-Dist: pyarrow
@@ -20,8 +20,8 @@ ngio/images/__init__.py,sha256=9Whvt7GTiCgT_vXaEEqGnDaY1-UsRk3dhLTv091F_g4,1211
20
20
  ngio/images/_abstract_image.py,sha256=hrB9xn4MFRxnxE1d7HKnM8SXVPUGhMD9u32yBHTsFiU,18517
21
21
  ngio/images/_create.py,sha256=61cuco2jUK25WzOY-Sel9s931FtGPL2ut25L9W10bJ4,10171
22
22
  ngio/images/_create_synt_container.py,sha256=il_rr5_2KIQ5Xsskj2rb2fEm100ZErZq89aW06kn_7k,5444
23
- ngio/images/_image.py,sha256=1WQOI26ITn1R2raR9JWVEhp6nKBE3ntXXAQr7EMTOEo,33054
24
- ngio/images/_label.py,sha256=RIfXrLSKMQ-j8q-aaSiWeIwFEKdxAkQT1HbJNq4PJv0,11800
23
+ ngio/images/_image.py,sha256=GDUmBhoTj9js7rC785g3__l_xSH1oKSgx2AAAr25OSM,33053
24
+ ngio/images/_label.py,sha256=Se3ZpgXDArtLHPlx9pw8Rnr5pZ_sEkmbeMh9sU63ncg,11799
25
25
  ngio/images/_masked_image.py,sha256=YhbBzgPZMav6rX0WYue1BaxAzEIsfaQrxUIOK6ZWZcw,18848
26
26
  ngio/images/_ome_zarr_container.py,sha256=UJERXEgBkwclpLaHzWqUIQc6P-TG4zYuKuxPukJGa4Y,38433
27
27
  ngio/images/_table_ops.py,sha256=jFv_AMqoB4JBpoWsMtZppZVW7dAOC_u-JpfNm8b33kY,15292
@@ -40,7 +40,7 @@ ngio/ome_zarr_meta/__init__.py,sha256=tzxW2oVhfeMBVuv3XkcbOLzMnbDvUnie-AVsvSxRkd
40
40
  ngio/ome_zarr_meta/_meta_handlers.py,sha256=ctknNDT8jxwyvxQf9on5gW31H1tRRsnneO38GT2UXoE,25880
41
41
  ngio/ome_zarr_meta/ngio_specs/__init__.py,sha256=U2FqZR91Ob2N6CqKdyw-_Ll-wMgmGuPZGVRCr6wuRFY,1698
42
42
  ngio/ome_zarr_meta/ngio_specs/_axes.py,sha256=gNzxCddn53m9dlNJlV5CL-aQS-nGJrbCDGfAp5L97LY,16412
43
- ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=CVsbG52U31TaMdTj8XqvClUdBya2Ar3qBjDo_xhP-NM,16967
43
+ ngio/ome_zarr_meta/ngio_specs/_channels.py,sha256=TDxIy-yVc2YaWPIFJRYnYwZbA8O5Ee_OiWppHYrEdpU,16647
44
44
  ngio/ome_zarr_meta/ngio_specs/_dataset.py,sha256=CrHnjVWBGYPqErKkHR-E2DKrE3DmGznXMkd3Y9Z4uYo,3434
45
45
  ngio/ome_zarr_meta/ngio_specs/_ngio_hcs.py,sha256=N1CGPOubwf0pvm8tiTnh-C1cOu9lToyDe3WagnEnPN4,17207
46
46
  ngio/ome_zarr_meta/ngio_specs/_ngio_image.py,sha256=XmqeffYRspBZmv8gCrfJvnykmBViWgDo2AtJJkR7OEs,15886
@@ -79,7 +79,7 @@ ngio/utils/_errors.py,sha256=pKQ12LUjQLYE1nUawemA5h7HsgznjaSvV1n2PQU33N0,759
79
79
  ngio/utils/_fractal_fsspec_store.py,sha256=RdcCFOgHexRKX9zZvJV5RI-5OPc7VOPS6q_IeRxm24I,1548
80
80
  ngio/utils/_logger.py,sha256=N5W0a_xwze4blS1MolidBkTMbjTbg8GPguJZNun3mAE,1392
81
81
  ngio/utils/_zarr_utils.py,sha256=GUOcAx02IcfrJ5tIdKu8ChtRUUaBbkkddW5jaCCYnS8,13797
82
- ngio-0.4.2.dist-info/METADATA,sha256=6cSiXSKGOPDF_YAnGvB2Y0OhOFeLGDXakuY7HKHUWHU,6095
83
- ngio-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
- ngio-0.4.2.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
85
- ngio-0.4.2.dist-info/RECORD,,
82
+ ngio-0.4.4.dist-info/METADATA,sha256=1yjBnjq6IURXZSApn3fLn31KBRWNLhTM6J4unvUrnHg,6117
83
+ ngio-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
+ ngio-0.4.4.dist-info/licenses/LICENSE,sha256=UgN_a1QCeNh9rZWfz-wORQFxE3elQzLWPQaoK6N6fxQ,1502
85
+ ngio-0.4.4.dist-info/RECORD,,
File without changes