Skip to content

Commit

Permalink
Fix some bugs in our usage of tifffile (#120)
Browse files Browse the repository at this point in the history
* Fix crash when writing one-channel OME-TIFF files
* Fix image resolution value for latest tifffile versions
  • Loading branch information
jmuhlich authored Apr 26, 2022
1 parent eccb25f commit 46b0d41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ashlar/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ def subres_tiles(self, level):
num_channels, h, w = self.level_full_shapes[level]
tshape = self.tile_shapes[level] or (h, w)
tiff = tifffile.TiffFile(self.path)
zimg = zarr.open(tiff.aszarr(series=0, level=level-1))
zimg = zarr.open(tiff.aszarr(series=0, level=level-1, squeeze=False))
for c in range(num_channels):
if self.verbose:
sys.stdout.write(
Expand All @@ -1192,7 +1192,7 @@ def subres_tiles(self, level):
tw = tshape[1] * self.scale
for y in range(0, zimg.shape[1], th):
for x in range(0, zimg.shape[2], tw):
a = zimg[c, y:y+th, x:x+tw]
a = zimg[c, y:y+th, x:x+tw, 0]
a = skimage.transform.downscale_local_mean(
a, (self.scale, self.scale)
)
Expand All @@ -1204,7 +1204,7 @@ def subres_tiles(self, level):
def run(self):
dtype = self.ref_mosaic.aligner.metadata.pixel_dtype
pixel_size = self.ref_mosaic.aligner.metadata.pixel_size
resolution_cm = round(10000 / pixel_size)
resolution_cm = 10000 / pixel_size
software = f"Ashlar v{_version}"
metadata = {
"Creator": software,
Expand Down Expand Up @@ -1255,7 +1255,7 @@ def __init__(self, mosaics, path_format, verbose=False):

def run(self):
pixel_size = self.mosaics[0].aligner.metadata.pixel_size
resolution_cm = round(10000 / pixel_size)
resolution_cm = 10000 / pixel_size
software = f"Ashlar v{_version}"
used_paths = set()
for mi, mosaic in enumerate(self.mosaics):
Expand Down

0 comments on commit 46b0d41

Please sign in to comment.