Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Milk committed Jun 24, 2024
1 parent 11b717a commit 2809724
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
7 changes: 1 addition & 6 deletions lazyslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

__version__ = "0.1.0"

subpackages = [
"pp",
"tl",
"pl",
"get",
]
subpackages = ["pp", "tl", "pl", "get", "models"]


__getattr__, __dir__, __all__ = lazy.attach(
Expand Down
54 changes: 34 additions & 20 deletions lazyslide/__main__.py
Original file line number Diff line number Diff line change
@@ -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}")
2 changes: 2 additions & 0 deletions lazyslide/tl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .features import feature_extraction
from .tissue_props import tissue_props
from .domain import anatomical_domain
from .annotate import annotate
16 changes: 7 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [
"numba",
"opencv-python",
"openslide-python",
"tiffslide",
"matplotlib",
"legendkit",
"anndata",
Expand All @@ -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
Expand Down

0 comments on commit 2809724

Please sign in to comment.