Skip to content
Snippets Groups Projects
Commit cd952c85 authored by Christian Kento Rasmussen's avatar Christian Kento Rasmussen
Browse files

created load function for dask

parent b2fa4120
Branches
Tags v0.3.2
4 merge requests!102Conv zarr tiff folders,!100Conv zarr nifti,!99Zarr cli,!96Zarr loading and converting
......@@ -603,6 +603,27 @@ class DataLoader:
else:
return vol
def load_zarr(self, path: str):
""" Loads a Zarr array from disk.
Args:
path (str): The path to the Zarr array on disk.
Returns:
dask.array | numpy.ndarray: The dask array loaded from disk.
if 'self.virtual_stack' is True, returns a dask array object, else returns a numpy.ndarray object.
"""
# Opens the Zarr array
vol = da.from_zarr(path)
# If virtual stack is disabled, return the computed array (np.ndarray)
if not self.virtual_stack:
vol = vol.compute()
return vol
def check_file_size(self, filename: str):
"""
Checks if there is enough memory where the file can be loaded.
......@@ -674,6 +695,8 @@ class DataLoader:
return self.load_vol(path)
elif path.endswith((".dcm", ".DCM")):
return self.load_dicom(path)
elif path.endswith(".zarr"):
return self.load_zarr(path)
else:
try:
return self.load_pil(path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment