diff --git a/lazyslide/__init__.py b/lazyslide/__init__.py index 61b356f..a46c5f0 100644 --- a/lazyslide/__init__.py +++ b/lazyslide/__init__.py @@ -2,12 +2,7 @@ __version__ = "0.1.0" -subpackages = [ - "pp", - "tl", - "pl", - "get", -] +subpackages = ["pp", "tl", "pl", "get", "models"] __getattr__, __dir__, __all__ = lazy.attach( diff --git a/lazyslide/__main__.py b/lazyslide/__main__.py index 13c0591..2821e50 100644 --- a/lazyslide/__main__.py +++ b/lazyslide/__main__.py @@ -1,39 +1,53 @@ -from typer import Typer -from lazyslide import WSI - import warnings -import logging -from rich.logging import RichHandler +from typing import Optional -FORMAT = "%(message)s" -logging.basicConfig( - level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()] -) +from rich import print +from typer import Typer, Argument, Option + +from lazyslide import WSI -log = logging.getLogger("LAZYSLIDE") -log.setLevel(logging.INFO) warnings.filterwarnings("ignore", category=UserWarning) app = Typer(pretty_exceptions_show_locals=False) +# Define shared parameters +SLIDE = Argument(..., help="The slide file to process") +OUTPUT = Option( + None, + "--output", + "-o", + help="By default will write to a zarr file with the same name as the slide file", +) + @app.command() -def tissue(slide: str): +def tissue( + slide: str = SLIDE, + output: Optional[str] = OUTPUT, +): from lazyslide.pp import find_tissue - log.info(f"Read slide file {slide}") + print(f"Read slide file {slide}") wsi = WSI(slide) find_tissue(wsi) - wsi.write() - log.info(f"Write to {wsi.file}") + wsi.write(output) + print(f"Write to {wsi.file}") @app.command() -def tile(slide: str, tile_px: int, mpp: float): +def tile( + slide: str = SLIDE, + tile_px: int = Argument(..., help="The size of the tile in pixels"), + stride_px: int = Option( + None, help="The stride of the tile in pixels, by default equal to tile_px" + ), + mpp: float = Option(None, help="The microns per pixel"), + output: Optional[str] = OUTPUT, +): from lazyslide.pp import tiles - log.info(f"Read slide file {slide}") + print(f"Read slide file {slide}") wsi = WSI(slide) - tiles(wsi, tile_px=tile_px, mpp=mpp) - wsi.write() - log.info(f"Write to {wsi.file}") + tiles(wsi, tile_px=tile_px, stride_px=stride_px, mpp=mpp) + wsi.write(output) + print(f"Write to {wsi.file}") diff --git a/lazyslide/tl/__init__.py b/lazyslide/tl/__init__.py index 2cd357e..70abe39 100644 --- a/lazyslide/tl/__init__.py +++ b/lazyslide/tl/__init__.py @@ -1,2 +1,4 @@ from .features import feature_extraction from .tissue_props import tissue_props +from .domain import anatomical_domain +from .annotate import annotate diff --git a/pyproject.toml b/pyproject.toml index 04cfa69..a2c560d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ dependencies = [ "numba", "opencv-python", "openslide-python", + "tiffslide", "matplotlib", "legendkit", "anndata", @@ -40,15 +41,12 @@ all = [ "torchstain", ] dev = [ - "flit", - "pytest >=2.7.3", - "pytest-cov", - "pre-commit", - "ruff", - "mkdocs", - "mkdocs-material", - "mkdocstrings", - "mkdocstrings-python", + "hatchling", + "sphinx", + "sphinxawesome-theme", + "numpydoc", + "sphinx_design", + "sphinx_copybutton", ] # Define entry points