Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions example/performance-EfficientNetV2S.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
#
# =========================================================================

import histomics_stream as hs
import histomics_stream.tensorflow
import os
import time

import pooch
import tensorflow as tf
import time

import histomics_stream as hs
import histomics_stream.tensorflow


"""
This is a script that is used to make timings of histomics_stream. To some extent, it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
# =========================================================================

import argparse
import histomics_stream as hs
import histomics_stream.pytorch
import itertools
import os
import pooch
import time

import pooch
import torch
import torchvision

import histomics_stream as hs
import histomics_stream.pytorch


"""
This is a script that is used to make timings of histomics_stream. To some extent, it
may be specific to the computer / docker image it is used with and need minor tweaks to
Expand Down
9 changes: 6 additions & 3 deletions example/performance-detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
#
# =========================================================================

import histomics_stream as hs
import histomics_stream.tensorflow
import os
import time

import pooch
import tensorflow as tf
import time

import histomics_stream as hs
import histomics_stream.tensorflow


"""
This is a script that is used to make timings of histomics_stream. To some extent, it
Expand Down
9 changes: 6 additions & 3 deletions example/performance-mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
#
# =========================================================================

import histomics_stream as hs
import histomics_stream.tensorflow
import os
import time

import pooch
import tensorflow as tf
import tensorflow_datasets as tfds
import time

import histomics_stream as hs
import histomics_stream.tensorflow


"""
This is a script that is used to make timings of histomics_stream. To some extent, it
Expand Down
4 changes: 2 additions & 2 deletions histomics_stream/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

"""

from imagecodecs import jpeg_encode, jpeg_decode, jpeg2k_encode, jpeg2k_decode
from imagecodecs import jpeg2k_decode, jpeg2k_encode, jpeg_decode, jpeg_encode
from numcodecs.abc import Codec
from numcodecs.compat import ensure_ndarray, ensure_contiguous_ndarray, ndarray_copy
from numcodecs.compat import ensure_contiguous_ndarray, ensure_ndarray, ndarray_copy
from numcodecs.registry import register_codec


Expand Down
41 changes: 22 additions & 19 deletions histomics_stream/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

import copy
import itertools
import itk
import large_image
import large_image_source_tiff
import math
import numpy as np
import os
import random
import re

import itk
import large_image
import large_image_source_tiff
import numpy as np
import scipy.interpolate


Expand Down Expand Up @@ -184,13 +185,15 @@ def __call__(self, slide):

# Do the work.
if not re.compile(r"\.zarr$").search(filename):

# create large_image, prioritizing tiff source over openslide
try:
import large_image_source_tiff

ts = large_image_source_tiff.open(filename)
except:
import large_image

ts = large_image.open(filename)

# scan_magnification = highest available magnification from source
Expand Down Expand Up @@ -442,16 +445,12 @@ def __init__(self, study, **kwargs):
overlap_height = (
kwargs["overlap_height"]
if "overlap_height" in kwargs
else study["overlap_height"]
if "overlap_height" in study
else 0
else study["overlap_height"] if "overlap_height" in study else 0
)
overlap_width = (
kwargs["overlap_width"]
if "overlap_width" in kwargs
else study["overlap_width"]
if "overlap_width" in study
else 0
else study["overlap_width"] if "overlap_width" in study else 0
)

# Check values.
Expand Down Expand Up @@ -1151,16 +1150,20 @@ def _find_in_range_and_delete(self, subtree):
# Process this internal node
means = subtree["means"]
recurse = dict(
(qkey, self._find_in_range_and_delete(qvalue))
if all(
(
self.maxs[col] > means[col]
if qkey & 2 ** (self.data.shape[1] - 1 - col)
else self.mins[col] < means[col]
for col in range(self.data.shape[1])
(
(qkey, self._find_in_range_and_delete(qvalue))
if all(
(
(
self.maxs[col] > means[col]
if qkey & 2 ** (self.data.shape[1] - 1 - col)
else self.mins[col] < means[col]
)
for col in range(self.data.shape[1])
)
)
else (qkey, (self.no_indices, qvalue))
)
else (qkey, (self.no_indices, qvalue))
for qkey, qvalue in subtree["quadrants"].items()
)
indices = np.array(
Expand Down
2 changes: 2 additions & 0 deletions histomics_stream/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

import numpy as np
import torch

from . import configure


"""
See: How to load a list of numpy arrays to pytorch dataset loader?
https://stackoverflow.com/questions/44429199/how-to-load-a-list-of-numpy-arrays-to-pytorch-dataset-loader
Expand Down
2 changes: 2 additions & 0 deletions histomics_stream/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"""Whole-slide image streamer for machine learning frameworks."""

import math

import tensorflow as tf

from . import configure


Expand Down