czi_img = pylibczirw_tools.read_5darray(img_path,output_order="TCZYX",
output_dask=True,
remove_adim=True
)
Is this the right way to do it? It takes more than 1 hour..
However, if I use the following code to initialize a dask array it takes ~5 minutes for a 255GB dataset
from dask import delayed as da_delayed
import dask.array as da
from pylibCZIrw import czi as pyczi
from tqdm import trange
czidoc = pyczi.CziReader(img_path)
temp_frame = czidoc.read()
print("Array Shape: ",temp_frame.shape)
total_bbox = czidoc.total_bounding_box
z_slices = total_bbox['Z'][1]
nchannels = total_bbox['C'][1]
total_time = total_bbox['T'][1]
#initialise empty list to hold the dask arrays
img=[]
for time in trange(total_time):
ch_stack=[]
for ch in range(nchannels):
z_stack=[]
for z in range(z_slices):
z_slice = da.from_delayed(
da_delayed(czidoc.read)(plane={'C': ch, 'T': time,'Z':z}), shape=temp_frame.shape, dtype=temp_frame.dtype
)
z_slice = da.squeeze(z_slice)
#z_slice = z_slice.swapaxes(0,1)
z_stack.append(z_slice)
z_stack = da.stack(z_stack,axis=0)
#break
ch_stack.append(z_stack)
img.append(ch_stack)
image_stack = da.stack(img,axis=0)