Dana-Farber-AIOS / pathml

Compare d5982f4 ... +13 ... d95ff9b

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 23 of 55 files from the diff.

@@ -4,4 +4,4 @@
Loading
4 4
"""
5 5
6 6
from .dataset import TileDataset
7 -
from .hovernet import HoVerNet, post_process_batch_hovernet, loss_hovernet
7 +
from .hovernet import HoVerNet, loss_hovernet, post_process_batch_hovernet

@@ -3,13 +3,9 @@
Loading
3 3
License: GNU GPL 2.0
4 4
"""
5 5
6 -
import os
7 6
import reprlib
8 7
from collections import OrderedDict
9 -
from pathlib import Path
10 -
from loguru import logger
11 8
12 -
import h5py
13 9
import pathml.core.h5managers
14 10
import pathml.core.masks
15 11
import pathml.core.tile
@@ -39,7 +35,7 @@
Loading
39 35
                        f"Tiles expects a list of type Tile but was given {type(tile)}"
40 36
                    )
41 37
                if tile.coords is None:
42 -
                    raise ValueError(f"tiles must contain valid coords")
38 +
                    raise ValueError("tiles must contain valid coords")
43 39
                coords = tile.coords
44 40
                tiledictionary[coords] = tile
45 41
            self._tiles = OrderedDict(tiledictionary)

@@ -3,7 +3,6 @@
Loading
3 3
License: GNU GPL 2.0
4 4
"""
5 5
6 -
from loguru import logger
7 6
import h5py
8 7
import numpy as np
9 8
import torch
@@ -52,7 +51,7 @@
Loading
52 51
            self.h5 = h5py.File(self.file_path, "r")
53 52
54 53
        k = self.tile_keys[ix]
55 -
        ### this part copied from h5manager.get_tile()
54 +
        # this part copied from h5manager.get_tile()
56 55
        tile_image = self.h5["tiles"][str(k)]["array"][:]
57 56
58 57
        # get corresponding masks if there are masks

@@ -4,16 +4,16 @@
Loading
4 4
"""
5 5
6 6
from .masks import Masks
7 -
from .slide_backends import OpenSlideBackend, BioFormatsBackend, DICOMBackend
7 +
from .slide_backends import BioFormatsBackend, DICOMBackend, OpenSlideBackend
8 8
from .slide_data import (
9 -
    SlideData,
9 +
    CODEXSlide,
10 10
    HESlide,
11 +
    IHCSlide,
11 12
    MultiparametricSlide,
13 +
    SlideData,
12 14
    VectraSlide,
13 -
    CODEXSlide,
14 -
    IHCSlide,
15 15
)
16 16
from .slide_dataset import SlideDataset
17 +
from .slide_types import SlideType, types
17 18
from .tile import Tile
18 19
from .tiles import Tiles
19 -
from .slide_types import SlideType, types

@@ -4,15 +4,11 @@
Loading
4 4
"""
5 5
6 6
from io import BytesIO
7 -
from typing import Tuple
8 7
9 8
import numpy as np
10 9
import openslide
11 -
from loguru import logger
12 -
import pathml.core
13 -
import pathml.core.tile
14 10
from javabridge.jutil import JavaException
15 -
from pathml.utils import pil_to_rgb
11 +
from loguru import logger
16 12
from PIL import Image
17 13
from pydicom.dataset import Dataset
18 14
from pydicom.encaps import get_frame_offsets
@@ -22,14 +18,18 @@
Loading
22 18
from pydicom.uid import UID
23 19
from scipy.ndimage import zoom
24 20
21 +
import pathml.core
22 +
import pathml.core.tile
23 +
from pathml.utils import pil_to_rgb
24 +
25 25
try:
26 26
    import bioformats
27 27
    import javabridge
28 28
    from bioformats.metadatatools import createOMEXMLMetadata
29 29
except ImportError:
30 30
    logger.exception("Unable to import bioformats, javabridge")
31 31
    raise Exception(
32 -
        f"Installation of PathML not complete. Please install openjdk8, bioformats, and javabridge:\nconda install openjdk==8.0.152\npip install javabridge==1.0.19 python-bioformats==4.0.0\nFor detailed installation instructions, please see https://github.com/Dana-Farber-AIOS/pathml/"
32 +
        "Installation of PathML not complete. Please install openjdk8, bioformats, and javabridge:\nconda install openjdk==8.0.152\npip install javabridge==1.0.19 python-bioformats==4.0.0\nFor detailed installation instructions, please see https://github.com/Dana-Farber-AIOS/pathml/"
33 33
    )
34 34
35 35
@@ -330,7 +330,8 @@
Loading
330 330
            try:
331 331
                self.pixel_dtype = pixel_dtype_map[ome_pixeltype]
332 332
                logger.info(f"Found corresponding dtype: {self.pixel_dtype}")
333 -
            except:
333 +
            # TODO: change to specific exception
334 +
            except Exception:
334 335
                logger.exception("datatype from metadata not found in pixel_dtype_map")
335 336
                raise Exception(
336 337
                    f"pixel type '{ome_pixeltype}' detected from OME metadata not recognized."
@@ -411,7 +412,7 @@
Loading
411 412
                f"input size {size} invalid. Must be a tuple of integer coordinates of len<2"
412 413
            )
413 414
        if series_as_channels:
414 -
            logger.info(f"using series_as_channels=True")
415 +
            logger.info("using series_as_channels=True")
415 416
            if level != 0:
416 417
                logger.exception(
417 418
                    f"When series_as_channels=True, must use level=0. Input 'level={level}' invalid."
@@ -490,7 +491,7 @@
Loading
490 491
                f"Scaling image to [0, 1] by dividing by {(2 ** (8 * self.pixel_dtype.itemsize))}"
491 492
            )
492 493
            # then scale to [0-255] and convert to 8 bit
493 -
            array_scaled = array_scaled * 2 ** 8
494 +
            array_scaled = array_scaled * 2**8
494 495
            return array_scaled.astype(np.uint8)
495 496
496 497
    def get_thumbnail(self, size=None):
@@ -507,7 +508,7 @@
Loading
507 508
            shape = data.slide.get_image_shape()
508 509
            thumb = data.slide.get_thumbnail(size=(1000,1000, shape[2], shape[3], shape[4]))
509 510
        """
510 -
        assert isinstance(size, (tuple, type(None))), f"Size must be a tuple of ints."
511 +
        assert isinstance(size, (tuple, type(None))), "Size must be a tuple of ints."
511 512
        if size is not None:
512 513
            if len(size) != len(self.shape):
513 514
                size = size + self.shape[len(size) :]
@@ -520,7 +521,7 @@
Loading
520 521
            ratio = tuple([x / y for x, y in zip(size, self.shape)])
521 522
            assert (
522 523
                ratio[3] == 1
523 -
            ), f"cannot interpolate between fluor channels, resampling doesn't apply, fix size[3]"
524 +
            ), "cannot interpolate between fluor channels, resampling doesn't apply, fix size[3]"
524 525
            image_array = zoom(array, ratio)
525 526
        return image_array
526 527
@@ -768,7 +769,7 @@
Loading
768 769
        Returns:
769 770
            np.ndarray: image at the specified region
770 771
        """
771 -
        assert level == 0 or level is None, f"dicom does not support levels"
772 +
        assert level == 0 or level is None, "dicom does not support levels"
772 773
        # check inputs first
773 774
        # check location
774 775
        if isinstance(location, tuple):
@@ -887,7 +888,7 @@
Loading
887 888
        Yields:
888 889
            pathml.core.tile.Tile: Extracted Tile object
889 890
        """
890 -
        assert level == 0 or level is None, f"dicom does not support levels"
891 +
        assert level == 0 or level is None, "dicom does not support levels"
891 892
        for i in range(self.n_frames):
892 893
893 894
            if not pad:

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 1 files with coverage changes found.

Changes in pathml/core/h5managers.py
-1
+1
Loading file...
Files Coverage
pathml -0.34% 86.18%
Project Totals (25 files) 86.18%
Loading