-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters