From e2404833441fe4e6369751720cea03d090b578f1 Mon Sep 17 00:00:00 2001 From: Ali Khan Date: Tue, 8 Oct 2024 08:40:49 -0400 Subject: [PATCH] cleanout unused lib/dask_image.py --- workflow/lib/dask_image.py | 45 ----------------------------- workflow/scripts/tif_to_zarr.py | 1 - workflow/scripts/tif_to_zarr_gcs.py | 1 - 3 files changed, 47 deletions(-) delete mode 100644 workflow/lib/dask_image.py diff --git a/workflow/lib/dask_image.py b/workflow/lib/dask_image.py deleted file mode 100644 index dbc06c3..0000000 --- a/workflow/lib/dask_image.py +++ /dev/null @@ -1,45 +0,0 @@ -from __future__ import annotations - -import os -from glob import glob - -try: - import tifffile -except (AttributeError, ImportError): - pass - -from dask.array.core import Array -from dask.base import tokenize - - -def add_leading_dimension(x): - return x[None, ...] - -def imread(fn, page): - return tifffile.imread(fn,key=page) - - -def imread_pages(filename, preprocess=None): - - - tif = tifffile.TiffFile(filename) - pages = [i for i in range(len(tif.pages))] - name = "imread-%s" % tokenize(filename, os.path.getmtime(filename)) - - sample = tif.pages[0].asarray() - - if preprocess: - sample = preprocess(sample) - - keys = [(name, i) + (0,) * len(sample.shape) for i in pages] - if preprocess: - values = [ - (add_leading_dimension, (preprocess, (imread, filename,i))) for i in pages - ] - else: - values = [(add_leading_dimension, (imread, filename,i)) for i in pages] - dsk = dict(zip(keys, values)) - - chunks = ((1,) * len(pages),) + tuple((d,) for d in sample.shape) - - return Array(dsk, name, chunks, sample.dtype) diff --git a/workflow/scripts/tif_to_zarr.py b/workflow/scripts/tif_to_zarr.py index 034a9cb..8787c9f 100644 --- a/workflow/scripts/tif_to_zarr.py +++ b/workflow/scripts/tif_to_zarr.py @@ -5,7 +5,6 @@ import dask.array as da from dask.delayed import delayed from dask.array.image import imread as imread_tifs -from lib.dask_image import imread_pages from itertools import product from dask.diagnostics import ProgressBar diff --git a/workflow/scripts/tif_to_zarr_gcs.py b/workflow/scripts/tif_to_zarr_gcs.py index ac6ac93..4e1d642 100644 --- a/workflow/scripts/tif_to_zarr_gcs.py +++ b/workflow/scripts/tif_to_zarr_gcs.py @@ -8,7 +8,6 @@ import dask.array.image from itertools import product from dask.diagnostics import ProgressBar -from lib.dask_image import imread_pages import gcsfs import pyvips from snakemake.io import expand