From f41b7d8ccd27cbecffd12bf39aef92fcbdef156a Mon Sep 17 00:00:00 2001 From: Roman Gluskin Date: Wed, 17 Jan 2024 09:34:04 +0000 Subject: [PATCH] Fixing an exception in OME mif files that return isRGB=True but getRGBChannelCount()==8 --- bioformats/formatreader.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bioformats/formatreader.py b/bioformats/formatreader.py index 19795a4..e7de04f 100644 --- a/bioformats/formatreader.py +++ b/bioformats/formatreader.py @@ -821,15 +821,12 @@ def read(self, c = None, z = 0, t = 0, series = None, index = None, logger.warning("WARNING: failed to get MaxSampleValue for image. Intensities may be improperly scaled.") if index is not None: image = np.frombuffer(openBytes_func(index), dtype) - if len(image) / height / width in (3,4): - n_channels = int(len(image) / height / width) - if self.rdr.isInterleaved(): - image.shape = (height, width, n_channels) - else: - image.shape = (n_channels, height, width) - image = image.transpose(1, 2, 0) + n_channels = int(len(image) / height / width) + if self.rdr.isInterleaved(): + image.shape = (height, width, n_channels) else: - image.shape = (height, width) + image.shape = (n_channels, height, width) + image = image.transpose(1, 2, 0) elif self.rdr.isRGB() and self.rdr.isInterleaved(): index = self.rdr.getIndex(z,0,t) image = np.frombuffer(openBytes_func(index), dtype)