Conversation
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
| and pseudo-max (100 - alpha percentile). Defaults to 1. | ||
| beta: absorbance threshold for transparent pixels. Defaults to 0.15 | ||
| max_cref: reference maximum stain concentrations for Hematoxylin & Eosin (H&E). | ||
| Defaults to None. |
There was a problem hiding this comment.
the defauts are np.array([1.9705, 1.0308])
| # reshape image and calculate absorbance | ||
| image = image.reshape((-1, 3)) | ||
| image = image.astype(np.float32) + 1.0 | ||
| absorbance = -np.log(image.clip(max=self.tli) / self.tli) |
There was a problem hiding this comment.
do we need some validation of the input of np.log?
There was a problem hiding this comment.
That's a good point! We should check if the input is intensity (0-255) and not any image or other scales. Thanks @wyli!
There was a problem hiding this comment.
Now it checks the image values to be between 0 and 255.
Nic-Ma
left a comment
There was a problem hiding this comment.
Looks good to me except for some minor comments.
I didn't check whether the implementation matches some algorithm theory.
Thanks.
docs/source/apps.rst
Outdated
| :members: | ||
|
|
||
| .. automodule:: monai.apps.pathology.transforms.stain.dictionary | ||
| .. autoclass:: ExtractHEStainsD |
There was a problem hiding this comment.
Suggest to use ExtractHEStainsd to align with other docs, same as NormalizeHEStainsD.
|
|
||
| self.max_cref = max_cref | ||
| if self.max_cref is None: | ||
| self.max_cref = np.array([1.9705, 1.0308]) |
There was a problem hiding this comment.
As @wyli commented, set default to 1.9705, 1.0308 directly.
Thanks.
| """Perform Stain Deconvolution and return stain matrix for the image. | ||
|
|
||
| Args: | ||
| img: uint8 RGB image to perform stain deconvolution of |
| pseudo-max (100 - alpha percentile). Defaults to 1. | ||
| beta: absorbance threshold for transparent pixels. Defaults to 0.15. | ||
| target_he: target stain matrix. Defaults to None. | ||
| max_cref: reference maximum stain concentrations for Hematoxylin & Eosin (H&E). |
There was a problem hiding this comment.
Default values of target_he and max_cref are same as the other comment.
| tli: float = 240, | ||
| alpha: float = 1, | ||
| beta: float = 0.15, | ||
| max_cref: Optional[np.ndarray] = None, |
| tli: float = 240, | ||
| alpha: float = 1, | ||
| beta: float = 0.15, | ||
| target_he: Optional[np.ndarray] = None, |
There was a problem hiding this comment.
same comment for default value.
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Behrooz <[email protected]>
…ain-normalization
* added stain norm and tests Signed-off-by: Neha Srivathsa <[email protected]> * import changes Signed-off-by: Neha Srivathsa <[email protected]> * changed stain extraction tests Signed-off-by: Neha Srivathsa <[email protected]> * edited stain norm tests Signed-off-by: Neha Srivathsa <[email protected]> * convert floats to float32 Signed-off-by: Neha Srivathsa <[email protected]> * added uint8 assumption to docstring Signed-off-by: Neha Srivathsa <[email protected]> * add error case Signed-off-by: Neha Srivathsa <[email protected]> * formatting change Signed-off-by: Neha Srivathsa <[email protected]> * modify tests wrt cupy import Signed-off-by: Neha Srivathsa <[email protected]> * minor change to pass lint test Signed-off-by: Neha Srivathsa <[email protected]> * import changes Signed-off-by: Neha Srivathsa <[email protected]> * refactored classes Signed-off-by: Neha Srivathsa <[email protected]> * Restructure and rename transforms Signed-off-by: Behrooz <[email protected]> * added dict transform Signed-off-by: Neha Srivathsa <[email protected]> * Move stain_extractor to init Signed-off-by: Behrooz <[email protected]> * Exclude pathology transform tests from mini tests Signed-off-by: Behrooz <[email protected]> * Fix type checking for cupy ndarray Signed-off-by: Behrooz <[email protected]> * Include pathology transform tests Signed-off-by: Behrooz <[email protected]> * Update to cupy 9.0.0 Signed-off-by: Behrooz <[email protected]> * Remove exact version for cupy Signed-off-by: Behrooz <[email protected]> * add to docs Signed-off-by: Neha Srivathsa <[email protected]> * Organize into stain dir Signed-off-by: Behrooz <[email protected]> * Add/update init files Signed-off-by: Behrooz <[email protected]> * Transit all from cupy to numpy Signed-off-by: Behrooz <[email protected]> * Update imports Signed-off-by: Behrooz <[email protected]> * Update test cases for numpy Signed-off-by: Behrooz <[email protected]> * Rename to NormalizeHEStains and NormalizeHEStainsD Signed-off-by: Behrooz <[email protected]> * Add dictionary variant names Signed-off-by: Behrooz <[email protected]> * Fix typing and formatting Signed-off-by: Behrooz <[email protected]> * Fix docs Signed-off-by: Behrooz <[email protected]> * Update test cases Signed-off-by: Behrooz <[email protected]> * Fix clip max Signed-off-by: Behrooz <[email protected]> * Fix var typing Signed-off-by: Behrooz <[email protected]> * Fix a typing issue Signed-off-by: Behrooz <[email protected]> * Update default values, and change D to d Signed-off-by: Behrooz <[email protected]> * Update docs Signed-off-by: Behrooz <[email protected]> * Add image value check Signed-off-by: Behrooz <[email protected]> * Add test cases for negative and invalid values Signed-off-by: Behrooz <[email protected]> Co-authored-by: Neha Srivathsa <[email protected]> Co-authored-by: nsrivathsa <[email protected]>
Description
This PR implement an H&E stain normalization for histopathology images, which contains:
Unlike the previous PR (#1998), which was based on
cupy, its purely based onnumpywithout any CUDA dependency. It expectsnumpy.ndarrayas the input image and returnsnumpy.ndarray.Status
Ready
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests.make htmlcommand in thedocs/folder.