From 6e5f6c0489c87a8081a6ed2ac0daeeca299732de Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 4 Mar 2024 23:15:33 -0500 Subject: [PATCH] WIP: ENH: Use cuCIM in CLI conversion --- ngff_zarr/cli.py | 30 ++++++++++++++++++++++++++++++ ngff_zarr/detect_cli_io_backend.py | 2 ++ 2 files changed, 32 insertions(+) diff --git a/ngff_zarr/cli.py b/ngff_zarr/cli.py index 259c45d..d0bf2c8 100755 --- a/ngff_zarr/cli.py +++ b/ngff_zarr/cli.py @@ -336,6 +336,36 @@ def shutdown_client(sig_id, frame): # noqa: ARG001 _multiscales_to_ngff_zarr( live, args, output_store, rich_dask_progress, multiscales ) + elif input_backend is ConversionBackend.CUCIM: + try: + # import cucim + # print('ARGS', args) + + # cuimage = cucim.CuImage(str(args.input[0])) + if args.chunks is None: + # Present the existing chunks and resolution levels + # [...] + # multiscales = cucim_image_to_multiscales(cuimage) + pass + + else: + # ngff_image = cucim_image_to_ngff_image(cucimage) + # multiscales = _ngff_image_to_multiscales( + # live, + # ngff_image, + # args, + # progress, + # rich_dask_progress, + # subtitle, + # method, + # ) + pass + _multiscales_to_ngff_zarr( + live, args, output_store, rich_dask_progress, multiscales + ) + except ImportError: + sys.stdout.write("[red]Please install the [i]cucim[/i] package.\n") + sys.exit(1) elif input_backend is ConversionBackend.TIFFFILE: try: import tifffile diff --git a/ngff_zarr/detect_cli_io_backend.py b/ngff_zarr/detect_cli_io_backend.py index ab293b7..5f821bd 100644 --- a/ngff_zarr/detect_cli_io_backend.py +++ b/ngff_zarr/detect_cli_io_backend.py @@ -105,6 +105,8 @@ def detect_cli_io_backend(input: List[str]) -> ConversionBackend: if extension in itk_supported_extensions: return ConversionBackend.ITK + extension = Path(input[0]).suffixes[-1].lower() + if importlib.util.find_spec("cucim") is not None: cucim_supported_extensions = (".svs", ".tif", ".tiff")