Skip to content

Commit

Permalink
log instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
niksirbi committed Apr 4, 2024
1 parent 5f4ca51 commit af0e782
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 8 additions & 3 deletions examples/convert_tiffs_to_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import shutil

from loguru import logger

from stack_to_chunk import MultiScaleGroup
from stack_to_chunk.io_helpers import load_env_var_as_path, read_tiff_stack_with_dask

Expand All @@ -31,24 +33,27 @@


if __name__ == "__main__":

tiff_files = sorted(channel_dir.glob("*.tif"))
# Create a folders for the subject and channel in the output directory
zarr_file_path = output_dir / subject_id / f"{subject_id}_{channel}.zarr"
if zarr_file_path.exists():
print(f"Deleting existing {zarr_file_path}")
logger.info(f"Deleting existing {zarr_file_path}")
shutil.rmtree(zarr_file_path)

# Create a MultiScaleGroup object (zarr group)
group = MultiScaleGroup(
zarr_file_path,
name=f"{subject_id}_{channel}",
spatial_unit="micrometer",
voxel_sizes=(3, 3, 3),
voxel_size=(3, 3, 3),
)

# Read the tiff stack into a dask array
da_arr = read_tiff_stack_with_dask(channel_dir)
logger.info(
f"Read tiff stack into Dask array with shape {da_arr.shape}, "
f"dtype {da_arr.dtype}, and chunk sizes {da_arr.chunksize}"
)

# Add the dask array to the zarr group
group.add_full_res_data(
Expand Down
10 changes: 4 additions & 6 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ per-file-ignores = {"docs/*" = [
"D400",
"D415",
"T201", # `print` found
], "examples/*" = [
"INP001", # is part of an implicit namespace package
], "test_*" = [
"D103", # Missing docstring in public function
"INP001", # is part of an implicit namespace package
"S101",
]}
select = [
"ALL",
]
isort.known-first-party = [
"stack_to_chunk",
]
select = ["ALL"]
isort.known-first-party = ["stack_to_chunk"]

0 comments on commit af0e782

Please sign in to comment.