U Ph@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)ExtractHEStainsNormalizeHEStainsc sDeZdZdZdddddd d d d fd d ZdddddZZS)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 $(~?Frfloattuple | np.ndarrayboolNone)keystlialphabetamax_crefallow_missing_keysreturncs$t||t||||d|_dS)N)rrrr)super__init__r extractor)selfrrrrrr __class__e/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/apps/pathology/transforms/stain/dictionary.pyr/s zExtractHEStainsd.__init__Mapping[Hashable, np.ndarray]dict[Hashable, np.ndarray]datarcCs.t|}||D]}|||||<q|SN)dict key_iteratorrrr$dkeyrrr __call__;szExtractHEStainsd.__call__)r rr r F__name__ __module__ __qualname____doc__rr+ __classcell__rrrr r s r c sFeZdZdZddd d d d d d d d fdd ZdddddZZS)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 Frrrrr)rrrr target_herrrcs&t||t|||||d|_dS)N)rrrr4r)rrr normalizer)rrrrrr4rrrrr r\s zNormalizeHEStainsd.__init__r!r"r#cCs.t|}||D]}|||||<q|Sr%)r&r'r5r(rrr r+iszNormalizeHEStainsd.__call__)r rr r3r Fr,rrrr r2Bs" r2)r0 __future__rcollections.abcrrnumpynp monai.configrmonai.transforms.transformrarrayrr r r2ExtractHEStainsDictExtractHEStainsDNormalizeHEStainsDictNormalizeHEStainsDrrrr  s   $.