Skip to content

Commit

Permalink
Fix error with dimensions being expanded based on preferred dimension…
Browse files Browse the repository at this point in the history
…s order, not actual one
  • Loading branch information
Yevgen Polyak committed Apr 27, 2022
1 parent 01847d2 commit f596693
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
50 changes: 38 additions & 12 deletions apeer_ometiff_library/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,61 @@ def read_ometiff(input_path):
size_x = pixels.SizeX
size_y = pixels.SizeY

# Expand image array to 5D of order (T, Z, C, X, Y)
if size_c == 1:
array = np.expand_dims(array, axis=-3)
if size_z == 1:
array = np.expand_dims(array, axis=-4)
if size_t == 1:
array = np.expand_dims(array, axis=-5)

# Makes sure to return the array in (T, Z, C, X, Y) order

# Expand image array to 5D and make sure to return the array in (T, Z, C, X, Y) order
dim_format = pixels.DimensionOrder

if dim_format == "XYCZT":
pass
if size_c == 1:
array = np.expand_dims(array, axis=-3)
if size_z == 1:
array = np.expand_dims(array, axis=-4)
if size_t == 1:
array = np.expand_dims(array, axis=-5)
elif dim_format == "XYZCT":
if size_z == 1:
array = np.expand_dims(array, axis=-3)
if size_c == 1:
array = np.expand_dims(array, axis=-4)
if size_t == 1:
array = np.expand_dims(array, axis=-5)
array = np.moveaxis(array, 1, 2)
elif dim_format == "XYCTZ":
if size_c == 1:
array = np.expand_dims(array, axis=-3)
if size_t == 1:
array = np.expand_dims(array, axis=-4)
if size_z == 1:
array = np.expand_dims(array, axis=-5)
array = np.moveaxis(array, 0, 1)
elif dim_format == "XYZTC":
if size_z == 1:
array = np.expand_dims(array, axis=-3)
if size_t == 1:
array = np.expand_dims(array, axis=-4)
if size_c == 1:
array = np.expand_dims(array, axis=-5)
array = np.moveaxis(array, 0, 2)
elif dim_format == "XYTZC":
if size_t == 1:
array = np.expand_dims(array, axis=-3)
if size_z == 1:
array = np.expand_dims(array, axis=-4)
if size_c == 1:
array = np.expand_dims(array, axis=-5)
array = np.moveaxis(array, 0, 2)
array = np.moveaxis(array, 0, 1)
elif dim_format == "XYTCZ":
if size_t == 1:
array = np.expand_dims(array, axis=-3)
if size_c == 1:
array = np.expand_dims(array, axis=-4)
if size_z == 1:
array = np.expand_dims(array, axis=-5)
array = np.moveaxis(array, 1, 2)
array = np.moveaxis(array, 0, 1)
else:
print(array.shape)
raise Exception("Unknow dimension format")
raise Exception("Unknow dimension format")

return array, omexml_string

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup

setup(name='apeer-ometiff-library',
version='1.8.2',
version='1.8.3',
description='Library to read and write ometiff images',
url='https://github.com/apeer-micro/apeer-ometiff-library',
author='apeer-micro',
Expand Down

0 comments on commit f596693

Please sign in to comment.