Skip to content
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

🐛 Add Warning for VahadaneExtractor Algorithm Instability #871

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
17 changes: 16 additions & 1 deletion tiatoolbox/tools/stainextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from sklearn.decomposition import DictionaryLearning

from tiatoolbox import logger
from tiatoolbox.utils.misc import get_luminosity_tissue_mask
from tiatoolbox.utils.transforms import rgb2od

Expand Down Expand Up @@ -238,6 +239,12 @@ class VahadaneExtractor:
This class contains code inspired by StainTools
[https:/Peter554/StainTools] written by Peter Byfield.

.. warning::
Vahadane stain extraction/normalization algorithms are unstable
after the update to `dictionary learning` algorithm in
scikit-learn > v0.23.0 (see issue #382). Please be advised and
consider using other stain extraction (normalization) algorithms.

Args:
luminosity_threshold (float):
Threshold used for tissue area selection.
Expand All @@ -259,6 +266,14 @@ def __init__(
regularizer: float = 0.1,
) -> None:
"""Initialize :class:`VahadaneExtractor`."""
# Issue a warning about the algorithm's stability
logger.warning(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mostafajahanifar Please can you add links to alternatives as discussed during the meeting?

"Vahadane stain extraction/normalization algorithms are unstable "
"after the update to `dictionary learning` algorithm in "
"scikit-learn > v0.23.0 (see issue #382). Please be advised and "
"consider using other stain extraction (normalization) algorithms.",
stacklevel=2,
)
self.__luminosity_threshold = luminosity_threshold
self.__regularizer = regularizer

Expand All @@ -267,7 +282,7 @@ def get_stain_matrix(self: VahadaneExtractor, img: np.ndarray) -> np.ndarray:

Args:
img (:class:`numpy.ndarray`):
Input image used for stain matrix estimation
Input image used for stain matrix estimation.

Returns:
:class:`numpy.ndarray`:
Expand Down
Loading