Skip to content

Commit

Permalink
Write ome-ngff metadata to .zattrs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyzubov committed Jan 16, 2025
1 parent ec08282 commit b660f44
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 423 deletions.
172 changes: 0 additions & 172 deletions src/conversion_lib.py

This file was deleted.

9 changes: 0 additions & 9 deletions src/n5_attrs_template.json

This file was deleted.

71 changes: 0 additions & 71 deletions src/tif_to_zarr.py

This file was deleted.

33 changes: 21 additions & 12 deletions src/tiff_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,37 @@
import dask.array as da
from natsort import natsorted
from glob import glob
from tiff_volume import TiffVolume

class TiffStack():
class TiffStack(TiffVolume):

def __init__(self,
src_path: str):
src_path: str,
axes : list[str],
scale : list[float],
translation : list[float],
units : list[str]):
"""Construct all the necessary attributes for the proper conversion of tiff to OME-NGFF Zarr.
Args:
input_filepath (str): path to source tiff file.
"""
self.input_filepath = src_path


self.src_path = src_path
self.stack_list = natsorted(glob(os.path.join(src_path, '*.tif*')))
probe_image_store = imread(os.path.join(src_path, self.stack_list[0]), aszarr=True)
probe_image_arr = da.from_zarr(probe_image_store)

self.dtype = probe_image_arr.dtype
self.shape = [len(self.stack_list)] + list(probe_image_arr.shape)




#metadata
self.zarr_metadata = {
"axes": axes,
"translation": translation,
"scale": scale,
"units": units,
}

def write_tile_slab_to_zarr(self,
chunk_num : int,
zarray : zarr.Array,
Expand All @@ -52,16 +61,16 @@ def write_tile_slab_to_zarr(self,
print(f'Tiff tile with index {slab_index} is not present in tiff stack.')
np_slab[slab_index - chunk_num, :, :] = image_tile

# write a tiff stack slab into zarr array
# write a tiff stack slab into a zarr array
zarray[chunk_num : chunk_num+ zarray.chunks[0], :, :] = np_slab



#parallel writing of tiff stack into zarr array
def write_to_zarr(self,
zarray : zarr.Group,
client : Client
):
zarray : zarr.Array,
client : Client
):
chunks_list = np.arange(0, zarray.shape[0], zarray.chunks[0])
print(chunks_list)

Expand Down
Loading

0 comments on commit b660f44

Please sign in to comment.