diff --git a/mzarr/__init__.py b/mzarr/__init__.py index dace05b..034f46c 100644 --- a/mzarr/__init__.py +++ b/mzarr/__init__.py @@ -1,7 +1 @@ -__version__ = "0.0.5" - -import numcodecs -from imagecodecs.numcodecs import JpegXl -from mzarr.mzarr import Mzarr - -numcodecs.register_codec(JpegXl) +__version__ = "0.0.6" diff --git a/mzarr/mzarr.py b/mzarr/mzarr.py index 404e2a6..8533bd6 100644 --- a/mzarr/mzarr.py +++ b/mzarr/mzarr.py @@ -5,8 +5,11 @@ from imagecodecs.numcodecs import JpegXl from typing import Optional, List, Union, Literal, Any import os +import numcodecs +numcodecs.register_codec(JpegXl) + class Mzarr: def __init__(self, store: Union[np.ndarray, str], mode: Literal['r', 'r+', 'a', 'w', 'w-'] = 'a') -> None: """ @@ -32,7 +35,10 @@ def __init__(self, store: Union[np.ndarray, str], mode: Literal['r', 'r+', 'a', if isinstance(store, str): self.load(store, mode) else: - self.array = store + if store.dtype in [np.uint8, np.uint16, np.float16, np.float32]: + self.array = store + else: + raise RuntimeError("Currently only the dtypes 'uint8', 'uint16', 'float16', 'float32' are supported. Dtype {} is not supported".format(store.dtype)) def load(self, path: str, mode: Literal['r', 'r+', 'a', 'a'] = 'a') -> None: """ diff --git a/mzarr/nifti2mzarr.py b/mzarr/nifti2mzarr.py index 44625da..d1a8155 100644 --- a/mzarr/nifti2mzarr.py +++ b/mzarr/nifti2mzarr.py @@ -4,7 +4,7 @@ import os from natsort import natsorted import SimpleITK as sitk -from mzarr.mzarr import Mzarr +from mzarr import Mzarr import numpy as np from typing import Union, Tuple diff --git a/mzarr/tiff2mzarr.py b/mzarr/tiff2mzarr.py index b726e0f..e0de673 100644 --- a/mzarr/tiff2mzarr.py +++ b/mzarr/tiff2mzarr.py @@ -4,7 +4,7 @@ from os.path import join from natsort import natsorted import tifffile -from mzarr.mzarr import Mzarr +from mzarr import Mzarr import numpy as np