diff --git a/model_server/base/accessors.py b/model_server/base/accessors.py index da9f177f90a801d027a3a772bb3fce598a17ad4d..712bbacf19296201775e1d7d49ef45b356ac1d1d 100644 --- a/model_server/base/accessors.py +++ b/model_server/base/accessors.py @@ -34,8 +34,6 @@ class GenericImageDataAccessor(ABC): def is_3d(self): return True if self.shape_dict['Z'] > 1 else False - # TODO: implement is_probability - def is_mask(self): return is_mask(self._data) @@ -117,6 +115,10 @@ class TifSingleSeriesFileAccessor(GenericImageFileAccessor): axs.append('C') da = np.expand_dims(da, len(da.shape)) + if 'Z' not in axs: + axs.append('Z') + da = np.expand_dims(da, len(da.shape)) + yxcz = np.moveaxis( da, [axs.index(k) for k in order], diff --git a/model_server/base/batch.py b/model_server/base/batch.py deleted file mode 100644 index 999aa4ccbba63ebc9615d88395373ac354d664cd..0000000000000000000000000000000000000000 --- a/model_server/base/batch.py +++ /dev/null @@ -1,22 +0,0 @@ -def get_tif_seq(where, prefix=None, verbose=True): - files = [ff for ff in os.listdir(where) if ff.startswith(prefix)] - files.sort() - paths = [where / fn for fn in files] - ndas = [imread(pa.__str__()) for pa in paths] - assert all([n.shape == ndas[0].shape and n.dtype == ndas[0].dtype for n in ndas]) - if verbose: - print(f'Successfully read {len(ndas)} x {ndas[0].shape} px images of type {ndas[0].dtype} from:\n{where}') - return ndas - -def write_tif_zstack(data, desc, dtype='uint16', subdir='output'): - where = root / subdir - filename = desc + '.tif' - if not os.path.exists(where): - os.makedirs(where) - abspath = where / filename - imwrite( - abspath, - np.array(data).astype(dtype), - imagej=True - ) - print(f'Successfully wrote {len(data)} x {data[0].shape} px images of type {dtype} to:\n{abspath}') \ No newline at end of file