o  i@sdZddlmZddlmZmZddlZddlm Z ddl m Z ddl m Z mZGd d d e ZGd d d e ZeZZeZZdS) z A collection of dictionary-based wrappers around the pathology transforms defined in :py:class:`monai.apps.pathology.transforms.array`. Class names are ended with 'd' to denote dictionary-based transforms. ) annotations)HashableMappingN)KeysCollection) MapTransform)ExtractHEStainsNormalizeHEStainscs8eZdZdZ     ddfdd ZdddZZS)ExtractHEStainsdaDictionary-based wrapper of :py:class:`monai.apps.pathology.transforms.ExtractHEStains`. Class to extract a target stain from an image, using stain deconvolution. Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` tli: transmitted light intensity. Defaults to 240. alpha: tolerance in percentile for the pseudo-min (alpha percentile) 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 (1.9705, 1.0308). allow_missing_keys: don't raise exception if key is missing. r333333?gI +?gx $(~?Fkeysrtlifloatalphabetamax_creftuple | np.ndarrayallow_missing_keysboolreturnNonecs$t||t||||d|_dS)N)rrrr)super__init__r extractor)selfrrrrrr __class__r/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/apps/pathology/transforms/stain/dictionary.pyr/s zExtractHEStainsd.__init__dataMapping[Hashable, np.ndarray]dict[Hashable, np.ndarray]cC.t|}||D] }|||||<q |SN)dict key_iteratorrrr!dkeyrrr __call__;zExtractHEStainsd.__call__)r rr r F)rrrrrrrrrrrrrrr!r"rr#__name__ __module__ __qualname____doc__rr+ __classcell__rrrr r s r cs:eZdZdZ      ddfdd ZdddZZS)NormalizeHEStainsda:Dictionary-based wrapper of :py:class:`monai.apps.pathology.transforms.NormalizeHEStains`. Class to normalize patches/images to a reference or target image stain. Performs stain deconvolution of the source image using the ExtractHEStains class, to obtain the stain matrix and calculate the stain concentration matrix for the image. Then, performs the inverse Beer-Lambert transform to recreate the patch using the target H&E stain matrix provided. If no target stain provided, a default reference stain is used. Similarly, if no maximum stain concentrations are provided, a reference maximum stain concentrations matrix is used. Args: keys: keys of the corresponding items to be transformed. See also: :py:class:`monai.transforms.compose.MapTransform` tli: transmitted light intensity. Defaults to 240. alpha: tolerance in percentile for the pseudo-min (alpha percentile) and 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). Defaults to None. allow_missing_keys: don't raise exception if key is missing. r rr )gX?gQkw?)g/' ?g3ı.n?)gH.?g$?r Frrrrrr target_herrrrrrcs&t||t|||||d|_dS)N)rrrr6r)rrr normalizer)rrrrrr6rrrrr r\s zNormalizeHEStainsd.__init__r!r"r#cCr$r%)r&r'r7r(rrr r+ir,zNormalizeHEStainsd.__call__)r rr r5r F)rrrrrrrrr6rrrrrrrr-r.rrrr r4Bs r4)r2 __future__rcollections.abcrrnumpynp monai.configrmonai.transforms.transformrarrayrr r r4ExtractHEStainsDictExtractHEStainsDNormalizeHEStainsDictNormalizeHEStainsDrrrr s   $.