Skip to content

Commit

Permalink
- Fix bug wrt. supporting non-file images.
Browse files Browse the repository at this point in the history
- Make layers optional in czi metadata.
- Delta_t for tif.
  • Loading branch information
Wim Pomp committed Feb 13, 2024
1 parent 735523a commit 8a66c57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ndbioimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,11 @@ def __init__(self, path, dtype=None, axes=None):
if isinstance(path, str):
path = Path(path)
self.path, self.series = self.split_path_series(path)
if isinstance(path, Path):
if isinstance(path, Path) and path.exists():
self.title = self.path.name
self.acquisitiondate = datetime.fromtimestamp(self.path.stat().st_mtime).strftime('%y-%m-%dT%H:%M:%S')
else: # ndarray
self.title = 'ndarray'
self.title = self.__class__.__name__
self.acquisitiondate = 'now'

self.reader = None
Expand Down
4 changes: 2 additions & 2 deletions ndbioimage/readers/cziread.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def def_list(item):
model.Plane(the_c=c, the_z=z, the_t=t, delta_t=delta_ts[t], exposure_time=exposure_times[c]))

idx = 0
for layer in metadata.find("Layers"):
for layer in metadata.find("Layers") or []:
rectangle = layer.find("Elements").find("Rectangle")
if rectangle is not None:
geometry = rectangle.find("Geometry")
Expand Down Expand Up @@ -552,7 +552,7 @@ def def_list(item):
position_z=float(positions.attrib["Z"]), position_z_unit=um))

idx = 0
for layer in metadata.find("Layers"):
for layer in [] if (ml := metadata.find("Layers")) is None else ml:
rectangle = layer.find("Elements").find("Rectangle")
if rectangle is not None:
geometry = rectangle.find("Geometry")
Expand Down
4 changes: 3 additions & 1 deletion ndbioimage/readers/tifread.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def ome(self):
'float', 'double', 'complex', 'double-complex', 'bit'):
dtype = 'float'

interval_t = metadata.get('interval', 0)

ome = model.OME()
ome.instruments.append(model.Instrument(id='Instrument:0'))
ome.instruments[0].objectives.append(model.Objective(id='Objective:0'))
Expand All @@ -63,7 +65,7 @@ def ome(self):
dimension_order="XYCZT", type=dtype, physical_size_x=pxsize, physical_size_y=pxsize),
objective_settings=model.ObjectiveSettings(id="Objective:0")))
for c, z, t in product(range(size_c), range(size_z), range(size_t)):
ome.images[0].pixels.planes.append(model.Plane(the_c=c, the_z=z, the_t=t, delta_t=0))
ome.images[0].pixels.planes.append(model.Plane(the_c=c, the_z=z, the_t=t, delta_t=interval_t * t))
return ome

def open(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ndbioimage"
version = "2023.12.2"
version = "2024.2.0"
description = "Bio image reading, metadata and some affine registration."
authors = ["W. Pomp <w.pomp@nki.nl>"]
license = "GPLv3"
Expand Down

0 comments on commit 8a66c57

Please sign in to comment.