From 18f753425761efba075055043cb56baa4ef40aa5 Mon Sep 17 00:00:00 2001 From: Godin Date: Wed, 21 Oct 2020 15:46:17 +0200 Subject: [PATCH 1/3] Unified dimension order of output array to TZCXY --- apeer_ometiff_library/io.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apeer_ometiff_library/io.py b/apeer_ometiff_library/io.py index 14e8294..e6973e7 100755 --- a/apeer_ometiff_library/io.py +++ b/apeer_ometiff_library/io.py @@ -1,6 +1,7 @@ import tifffile import numpy as np from apeer_ometiff_library import omexmlClass +from xmltodict import parse def read_ometiff(input_path): @@ -27,6 +28,28 @@ def read_ometiff(input_path): if size_t == 1: array = np.expand_dims(array, axis=-5) + # Makes sure to return the array in (T, Z, C, X, Y) order + + dim_format = pixels.DimensionOrder + + if dim_format == "XYCZT": + pass + elif dim_format == "XYZCT": + array = np.moveaxis(array, 1, 2) + elif dim_format == "XYCTZ": + array = np.moveaxis(array, 0, 1) + elif dim_format == "XYZTC": + array = np.moveaxis(array, 0, 2) + elif dim_format == "XYTZC": + array = np.moveaxis(array, 0, 2) + array = np.moveaxis(array, 0, 1) + elif dim_format == "XYTCZ": + array = np.moveaxis(array, 1, 2) + array = np.moveaxis(array, 0, 1) + else: + print(array.shape) + raise Exception("Unknow dimension format") + return array, omexml_string def update_xml(omexml, Image_ID=None, Image_Name=None, Image_AcquisitionDate=None, From a72b06595b768df22ac56ea6892c7202ca4d9932 Mon Sep 17 00:00:00 2001 From: Godin Date: Wed, 21 Oct 2020 15:46:41 +0200 Subject: [PATCH 2/3] updated requirements and version to 1.7.2 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e53ca4b..fa94831 100644 --- a/setup.py +++ b/setup.py @@ -2,12 +2,12 @@ from setuptools import setup setup(name='apeer-ometiff-library', - version='1.7.1', + version='1.7.2', description='Library to read and write ometiff images', url='https://github.com/apeer-micro/apeer-ometiff-library', author='apeer-micro', packages=setuptools.find_packages(), - install_requires=['numpy', 'scikit-image'], + install_requires=['numpy','xmltodict','tifffile'], license='MIT', classifiers=[ "Programming Language :: Python :: 3", From 110d7e313d15f8ece54d2360e587fbe8b2dea6b9 Mon Sep 17 00:00:00 2001 From: Godin Date: Wed, 21 Oct 2020 16:30:12 +0200 Subject: [PATCH 3/3] removed xmltodict library --- apeer_ometiff_library/io.py | 3 +-- requirements.txt | 1 - setup.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apeer_ometiff_library/io.py b/apeer_ometiff_library/io.py index e6973e7..9a4d5aa 100755 --- a/apeer_ometiff_library/io.py +++ b/apeer_ometiff_library/io.py @@ -1,7 +1,6 @@ import tifffile import numpy as np -from apeer_ometiff_library import omexmlClass -from xmltodict import parse +from apeer_ometiff_library import omexmlClass def read_ometiff(input_path): diff --git a/requirements.txt b/requirements.txt index fe654c4..fe539ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ numpy==1.16.5 -xmltodict==0.12.0 tifffile==2020.2.16 diff --git a/setup.py b/setup.py index fa94831..f815026 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ url='https://github.com/apeer-micro/apeer-ometiff-library', author='apeer-micro', packages=setuptools.find_packages(), - install_requires=['numpy','xmltodict','tifffile'], + install_requires=['numpy','tifffile'], license='MIT', classifiers=[ "Programming Language :: Python :: 3",