Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Milk committed Dec 4, 2023
1 parent 2098ff8 commit f4af26a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 69 deletions.
5 changes: 1 addition & 4 deletions lazyslide/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""Working with whole slide imaging"""
__version__ = "0.1.0"

from .wsi import WSI, create_tiles_coords, filter_tiles
from .readers.utils import get_crop_left_top_width_height
from .cv_mods import TissueDetectionHE
from .h5 import H5File
from .wsi import WSI
from .utils import get_reader


Expand Down
2 changes: 0 additions & 2 deletions lazyslide/h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
from pathlib import Path

import h5py
import numpy as np

from .utils import TileOps


class H5File:
"""A class that handle storage and reading of h5 file"""
# TODO: Add options to save contours and holes

COORDS_KEY = "coords"
MASKS_KEY = "masks"
Expand Down
49 changes: 0 additions & 49 deletions lazyslide/torch_dataset.py

This file was deleted.

8 changes: 8 additions & 0 deletions lazyslide/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from dataclasses import dataclass, field
from itertools import tee
from typing import Type

from .readers.base import ReaderBase
from .readers.vips import VipsReader
from .readers.openslide import OpenSlideReader


def pairwise(iterable):
# pairwise('ABCDEFG') --> AB BC CD DE EF FG
a, b = tee(iterable)
next(b, None)
return zip(a, b)


def get_reader(reader="auto") -> Type[ReaderBase]:
"""Return an available backend"""

Expand Down
18 changes: 4 additions & 14 deletions lazyslide/wsi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import warnings
from itertools import tee
from numbers import Integral
from pathlib import Path
from typing import Iterable
Expand All @@ -11,20 +10,12 @@
from matplotlib import pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle
from numba import njit, prange
from numba import njit

from .cv_mods import TissueDetectionHE
from .h5 import H5File
from .readers.base import ReaderBase
from .torch_dataset import WSIDataset
from .utils import get_reader, TileOps


def pairwise(iterable):
# pairwise('ABCDEFG') --> AB BC CD DE EF FG
a, b = tee(iterable)
next(b, None)
return zip(a, b)
from .utils import pairwise, get_reader, TileOps


@njit
Expand Down Expand Up @@ -576,9 +567,8 @@ def plot_mask(self,
fig.savefig(savefig, **save_kws)
return ax

def to_dataset(self, transform=None, run_pretrained=False, **kwargs):
# TODO: Allow resize transform on-the-fly to fit into different models
return WSIDataset(self, transform=transform, run_pretrained=run_pretrained, **kwargs)
# def to_dataset(self, transform=None, run_pretrained=False, **kwargs):
# return WSIDataset(self, transform=transform, run_pretrained=run_pretrained, **kwargs)

def get_patch(self, left, top, width, height, level=0, **kwargs):
return self.reader.get_patch(left, top, width, height, level=level, **kwargs)
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ dependencies = [
vips = [
"pyvips",
]
all = [
"ncls"
]
dev = [
"flit",
"pytest >=2.7.3",
Expand Down

0 comments on commit f4af26a

Please sign in to comment.