Skip to content
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
addce62
DEV: Add Tiffile Dependencies
John-P May 19, 2021
14a2a8c
NEW: Add Reader For TIFF File Using tiffile + zarr
John-P May 21, 2021
f9ec2ab
ENH: Add Check For Supported TIFF WSI Formats
John-P May 21, 2021
cccc151
BUG: Remove Brackets from Property Access
John-P May 21, 2021
eddd98a
WIP: Basic OME-TIFF Support with YX Indexing
John-P May 24, 2021
f9da0bd
MAINT: Typo Fixes
John-P May 28, 2021
1c30415
BUG: Swap Axes Order When Reading SYX OME-TIFFs
John-P Jul 9, 2021
7653d7d
DOC: Add Docstring
John-P Aug 31, 2021
b94a821
BUG: Fix Inability To Deepcopy tiffile Tags Attribute
John-P Sep 1, 2021
0e49a39
TST: Add Sample OME-TIFF Download & Test
John-P Sep 1, 2021
426566b
Merge branch 'develop' into feature-tiffreader
John-P Sep 17, 2021
8928c7f
MAINT: Move Axes Information To WSIMeta
John-P Sep 17, 2021
cf3df3c
TST: Add Parameterised TIFFWSIReader Tests
John-P Oct 5, 2021
7eaf125
TST: Resolve Unused Import
John-P Oct 5, 2021
f613ca8
TST: Remove Unecessary Test
John-P Oct 5, 2021
7441874
Autofix issues in 1 file
deepsource-autofix[bot] Oct 5, 2021
aa8a878
STY: Make Args Consistent for `read_rect/bounds`
John-P Oct 5, 2021
4b82174
Merge branch 'feature-tiffreader' of https://github.com/TIA-Lab/tiato…
John-P Oct 5, 2021
76b452e
STY: Remove Unnecessary Dict Comprehension
John-P Oct 5, 2021
ac1c794
ENH: Swap To Using defusedxml For Parsing OME-XML
John-P Oct 5, 2021
1745049
TST: Add skipcq For Test
John-P Oct 5, 2021
a8bd386
ENH: Add TIFFWSIReader Support For `coord_space`
John-P Oct 5, 2021
6893554
DOC: Add Docstring Line Breaks
John-P Oct 5, 2021
162f00a
Merge branch 'develop' into feature-tiffreader
tialab Oct 5, 2021
cbf3031
TST: Avoid Testing Very Small JP2 Levels
John-P Oct 7, 2021
4926f38
DOC: Add Line Breaks To Docstrings
John-P Oct 7, 2021
c502b3c
Merge branch 'feature-tiffreader' of https://github.com/TIA-Lab/tiato…
John-P Oct 7, 2021
2a5f50c
TST: Avoid Testing Very Small Levels (e.g. in JP2)
John-P Oct 7, 2021
eceafef
TST: Add Test For Invalid TIFFFile Axes
John-P Oct 7, 2021
af6bc4a
TST: Add Tests To Increase TIFFWSIReader Coverage
John-P Oct 7, 2021
fe3a037
TST: Remove Unused Variable In Test
John-P Oct 7, 2021
64c4844
TST: Add TIFFWSIReader Tests To Improve Coverage
John-P Oct 8, 2021
9fab706
TST: Add Test For Unsupported Axes in _shape_channels_last
John-P Oct 12, 2021
7733b61
BUG: Fix Bug In ArrayView.__getitem__
John-P Oct 12, 2021
ff3d13c
Merge branch 'develop' into feature-tiffreader
John-P Oct 14, 2021
86291df
TST: Add Missing Arguments for WSIMeta
John-P Oct 14, 2021
70196d2
BUG: Add Missing axes Argument
John-P Oct 14, 2021
7f8d30c
TST: Remove Tmp Test Used For Debugging
John-P Oct 15, 2021
f7210ba
TST: Add Test For TIFFWSIReader For Coverage
John-P Oct 15, 2021
e9ed29f
TST: Add Tests To Improve Coverage
John-P Oct 15, 2021
cc46eaa
TST: Change test_behavior_tissue_mask to use svs-1-small
shaneahmed Oct 15, 2021
a18c7f3
BUG: Fix flake8 bug
shaneahmed Oct 18, 2021
019ae76
DOC: Minor Docstring Edits & Type Hints
John-P Oct 18, 2021
3369468
EHN: Add OME-TIFF To get_wsireader
John-P Oct 20, 2021
6cd2b47
Merge branch 'develop' into feature-tiffreader
shaneahmed Oct 20, 2021
a67253c
DEV: Run black on tiatoolbox/models/dataset/classification
shaneahmed Oct 20, 2021
a7b3dc0
BUG: Fix bug due to changes in split_path_name_ext
shaneahmed Oct 20, 2021
cc9dd23
DEV: Updated requirements and requirements_dev
shaneahmed Oct 20, 2021
e2b0f1c
BUG: Fix get_wsireader JP2 reader
shaneahmed Oct 21, 2021
eb4bc63
BUG: Handle Case For TIFF with No Series
John-P Oct 21, 2021
cbd77d5
TST: Add Test For get_wsireadre with OME-TIFF
John-P Oct 21, 2021
b7b1eed
Merge branch 'feature-tiffreader' of https://github.com/TIA-Lab/tiato…
John-P Oct 21, 2021
dbb13d9
MAINT: Minor Refactor (Extract Variable)
John-P Oct 21, 2021
9b4eac1
BUG: Fix Wrong Line Causing Invalid Syntax
John-P Oct 21, 2021
e4eaf99
ENH: Add Check For None Series In TIFF
John-P Oct 21, 2021
df2b90c
MAINT: Add skipqc For Non-Iterable PYL-e133
John-P Oct 21, 2021
abda2cc
BUG: Handle Special Case of 1x1 Resize
John-P Oct 22, 2021
bf27c33
ENH: Simplify Check For 1x1
John-P Oct 22, 2021
d283823
STY: Sort Imports
John-P Oct 22, 2021
ac40e38
EHN: Move get_wsireader To WSIReader.open
John-P Oct 22, 2021
4d2f9f8
BUG: Add Missing Argument to WSIReader.open
John-P Oct 22, 2021
13c1b55
BUG: Fix Deprecation Warning
John-P Oct 22, 2021
f0afc34
Merge branch 'develop' into feature-wsireader-open
John-P Oct 25, 2021
3aa90fe
MAINT: Remove cv2 1x1 Special Case
John-P Oct 25, 2021
90addc0
REV: Revert bug fix for cv2 v4.5.4
shaneahmed Oct 27, 2021
3c605f3
BUG: Fix a bug which was ignoring npy files.
shaneahmed Oct 27, 2021
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
92 changes: 60 additions & 32 deletions tiatoolbox/wsicore/wsireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,61 @@ class WSIReader:

"""

@staticmethod
def open(input_img):
"""Return an appropriate :class:`.WSIReader` object.

Args:
input_img (str, pathlib.Path, :class:`numpy.ndarray`, or :obj:WSIReader):
Input to create a WSI object from.
Supported types of input are: `str` and `pathlib.Path` which point to
the location on the disk where image is stored, :class:`numpy.ndarray`
in which the input image in the form of numpy array (HxWxC) is stored,
or :obj:WSIReader which is an already created tiatoolbox WSI handler.
In the latter case, the function directly passes the input_imge to the
output.

Returns:
WSIReader: an object with base :class:`.WSIReader` as base class.

Examples:
>>> from tiatoolbox.wsicore.wsireader import get_wsireader
>>> wsi = get_wsireader(input_img="./sample.svs")

"""
if isinstance(input_img, (str, pathlib.Path)):
_, _, suffixes = utils.misc.split_path_name_ext(input_img)

if suffixes[-1] in (".npy",):
input_img = np.load(input_img)
wsi = VirtualWSIReader(input_img)

elif suffixes[-2:] in ([".ome", ".tiff"],):
wsi = TIFFWSIReader(input_img)

elif suffixes[-1] in (".jpg", ".png", ".tif"):
wsi = VirtualWSIReader(input_img)

elif suffixes[-1] in (".svs", ".ndpi", ".mrxs"):
wsi = OpenSlideWSIReader(input_img)

elif suffixes[-1] == (".jp2"):
wsi = OmnyxJP2WSIReader(input_img)

else:
raise FileNotSupported("Filetype not supported.")
elif isinstance(input_img, np.ndarray):
wsi = VirtualWSIReader(input_img)
elif isinstance(
input_img, (VirtualWSIReader, OpenSlideWSIReader, OmnyxJP2WSIReader)
):
# input is already a tiatoolbox wsi handler
wsi = input_img
else:
raise TypeError("Please input correct image path or an ndarray image.")

return wsi

def __init__(self, input_img):
if isinstance(input_img, np.ndarray):
self.input_path = None
Expand Down Expand Up @@ -2187,35 +2242,8 @@ def get_wsireader(input_img):
>>> wsi = get_wsireader(input_img="./sample.svs")

"""
if isinstance(input_img, (str, pathlib.Path)):
_, _, suffixes = utils.misc.split_path_name_ext(input_img)

if suffixes[-1] in (".npy",):
input_img = np.load(input_img)
wsi = VirtualWSIReader(input_img)

elif suffixes[-2:] in ([".ome", ".tiff"],):
wsi = TIFFWSIReader(input_img)

elif suffixes[-1] in (".jpg", ".png", ".tif"):
wsi = VirtualWSIReader(input_img)

elif suffixes[-1] in (".svs", ".ndpi", ".mrxs"):
wsi = OpenSlideWSIReader(input_img)

elif suffixes[-1] == (".jp2"):
wsi = OmnyxJP2WSIReader(input_img)

else:
raise FileNotSupported("Filetype not supported.")
elif isinstance(input_img, np.ndarray):
wsi = VirtualWSIReader(input_img)
elif isinstance(
input_img, (VirtualWSIReader, OpenSlideWSIReader, OmnyxJP2WSIReader)
):
# input is already a tiatoolbox wsi handler
wsi = input_img
else:
raise TypeError("Please input correct image path or an ndarray image.")

return wsi
warnings.warn(
"get_wsireader is deprecated. Please use WSIReader.open instead",
DeprecationWarning,
)
return WSIReader.open(input_img)