-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚸 Handle Multidimensional Features
in WSIReader
#742
Changes from 21 commits
8bd861d
767b640
750c256
c9548fa
574560d
c150968
ae2ad11
30f4f5f
2f0dd1a
1bc132c
75b2902
5419d7c
0575309
112e4e1
112cf1b
15043ea
c962fef
ebf18cf
749be60
04cfee7
531ee98
1e1fbb5
a922ccb
da968ee
cec02a2
28cbb3e
5c8a7ea
1a350c8
63c4655
025c852
9d36e83
41bf21f
43975a8
2df748d
7730642
63251a3
08d7137
9b94024
643118d
167f23f
2309f19
2a6b04f
effb434
96018a6
f422fcb
875fce5
3b0c6e8
ca38fa5
94112fe
7ef908b
ad3a498
b737f0b
5dc5fa1
d13dc3f
418c3ed
e697b1d
670ce45
e2758a3
1e63e3f
0c78b40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2781,8 +2781,14 @@ class VirtualWSIReader(WSIReader): | |
:func:`~tiatoolbox.utils.image.sub_pixel_read`. | ||
|
||
Attributes: | ||
img (:class:`numpy.ndarray`) | ||
mode (str) | ||
img (:class:`numpy.ndarray`): | ||
Input image as :class:`numpy.ndarray`. | ||
mode (str): | ||
Mode of the input image. Default is 'rgb'. Allowed values | ||
are: rgb, bool, feature. "rgb" mode supports bright-field color images. | ||
"bool" mode supports binary masks, | ||
interpolation in this case will be "nearest" instead of "bicubic". | ||
"feature" mode allows multichannel features. | ||
|
||
Args: | ||
input_img (str, :obj:`Path`, :class:`numpy.ndarray`): | ||
|
@@ -2791,7 +2797,10 @@ class VirtualWSIReader(WSIReader): | |
Metadata for the virtual wsi. | ||
mode (str): | ||
Mode of the input image. Default is 'rgb'. Allowed values | ||
are: rgb, bool. | ||
are: rgb, bool, feature. "rgb" mode supports bright-field color images. | ||
"bool" mode supports binary masks, | ||
interpolation in this case will be "nearest" instead of "bicubic". | ||
"feature" mode allows multichannel features. | ||
|
||
""" | ||
|
||
|
@@ -2809,15 +2818,22 @@ def __init__( | |
mpp=mpp, | ||
power=power, | ||
) | ||
if mode.lower() not in ["rgb", "bool"]: | ||
if mode.lower() not in ["rgb", "bool", "feature"]: | ||
msg = "Invalid mode." | ||
raise ValueError(msg) | ||
self.mode = mode.lower() | ||
|
||
if isinstance(input_img, np.ndarray): | ||
self.img = input_img | ||
else: | ||
self.img = utils.imread(self.input_path) | ||
|
||
if mode != "bool" and ( | ||
self.img.ndim == 2 or self.img.shape[2] not in [3, 4] # noqa: PLR2004 | ||
): | ||
mode = "feature" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging would be better option here as background composite would fail in case the input is not rgb or rgba. Also, mode should be bool for a boolean input. |
||
|
||
self.mode = mode.lower() | ||
|
||
if info is not None: | ||
self._m_info = info | ||
|
||
|
@@ -3267,6 +3283,9 @@ class docstrings for more information. | |
if interpolation in [None, "none"]: | ||
interpolation = None | ||
|
||
if interpolation == "optimise" and self.mode == "bool": | ||
shaneahmed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
interpolation = "nearest" | ||
|
||
im_region = utils.image.sub_pixel_read( | ||
self.img, | ||
bounds_at_read, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you assert not only shape but the value as well? and maybe add some edge case to check the interpolation?