Skip to content

Commit

Permalink
Rewritten code base supporting full multi-dimensional images, improve…
Browse files Browse the repository at this point in the history
…d (ome) zarr support, added convenience rgb render function, various fixes and improvements
  • Loading branch information
folterj committed Jan 26, 2024
1 parent 14999ba commit b4894ca
Show file tree
Hide file tree
Showing 20 changed files with 556 additions and 314 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### Version 0.6.1
- Rewritten code base supporting full multi-dimensional images
- Improved (ome) zarr support
- Added convenience rgb render function

#### Version 0.5.3
- Decoupled hard requirements for Omero / bioformats
- Minor fixes to ome-zarr metadata
Expand Down
20 changes: 18 additions & 2 deletions OmeSliCC/BioSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def __init__(self,
self.has_ome_metadata = True
self.reader = ImageReader(filename)

#self.reader.rdr.getSeriesCount()
# good images have StageLabel in metadata?
self.indexes = []
# TODO: use self.metadata instead of self.bio_ome_metadata
for i in range(self.bio_ome_metadata.get_image_count()):
pmetadata = self.bio_ome_metadata.image(i).Pixels
if pmetadata.PhysicalSizeX is not None:
Expand All @@ -52,11 +55,24 @@ def __init__(self,
def _find_metadata(self):
self._get_ome_metadate()

def _asarray_level(self, level: int, x0: float = 0, y0: float = 0, x1: float = -1, y1: float = -1) -> np.ndarray:
def _asarray_level(self, level: int, x0: float = 0, y0: float = 0, x1: float = -1, y1: float = -1,
c: int = None, z: int = None, t: int = None) -> np.ndarray:
if x1 < 0 or y1 < 0:
x1, y1 = self.sizes[level]
if t is None:
t = 0
if z is None:
z = 0
xywh = (x0, y0, x1 - x0, y1 - y0)
image = self.reader.read(series=self.indexes[level], XYWH=xywh, rescale=False) # don't 'rescale' to 0-1!
image = self.reader.read(series=self.indexes[level], XYWH=xywh, rescale=False, # don't 'rescale' to 0-1!
c=c, z=z, t=t)
ndim0 = image.ndim
image = np.expand_dims(image, 0)
if ndim0 == 2:
image = np.expand_dims(image, 0)
else:
image = np.moveaxis(image, -1, 0)
image = np.expand_dims(image, 0)
return image

def close(self):
Expand Down
Loading

0 comments on commit b4894ca

Please sign in to comment.