U
    ‚PÓh©  ã                	   @  s¦   d dl mZ d dlmZ d dlmZ ddlmZ ddlm	Z	m
Z
mZ dd	d
ddddddg	ZG dd„ deƒZG dd„ deƒZG dd„ deƒZe ZZe ZZe ZZdS )é    )Úannotations)ÚKeysCollection)Úensure_tupleé   )ÚMapTransformé   )ÚCutMixÚCutOutÚMixUpÚMixUpdÚMixUpDÚ	MixUpDictÚCutMixdÚCutMixDÚ
CutMixDictÚCutOutdÚCutOutDÚ
CutOutDictc                      s8   e Zd ZdZddddddd	œ‡ fd
d„Zdd„ Z‡  ZS )r   zã
    Dictionary-based version :py:class:`monai.transforms.MixUp`.

    Notice that the mixup transformation will be the same for all entries
    for consistency, i.e. images and labels must be applied the same augmenation.
    ç      ð?Fr   ÚintÚfloatÚboolÚNone)ÚkeysÚ
batch_sizeÚalphaÚallow_missing_keysÚreturnc                   s   t ƒ  ||¡ t||ƒ| _d S ©N)ÚsuperÚ__init__r
   Úmixup)Úselfr   r   r   r   ©Ú	__class__© ú_/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/transforms/regularization/dictionary.pyr       s    zMixUpd.__init__c                 C  s6   | j  ¡  t|ƒ}| jD ]}| j  || ¡||< q|S r   )r!   Ú	randomizeÚdictr   Úapply©r"   ÚdataÚresultÚkr%   r%   r&   Ú__call__%   s
    

zMixUpd.__call__)r   F©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r.   Ú__classcell__r%   r%   r#   r&   r      s
      ÿc                      s:   e Zd ZdZdddddd	d
dœ‡ fdd„Zdd„ Z‡  ZS )r   a  
    Dictionary-based version :py:class:`monai.transforms.CutMix`.

    Notice that the mixture weights will be the same for all entries
    for consistency, i.e. images and labels must be aggregated with the same weights,
    but the random crops are not.
    Nr   Fr   r   zKeysCollection | Noner   r   r   )r   r   Ú
label_keysr   r   r   c                   s4   t ƒ  ||¡ t||ƒ| _|d k	r*t|ƒng | _d S r   )r   r    r   Úmixerr   r5   )r"   r   r   r5   r   r   r#   r%   r&   r    6   s    zCutMixd.__init__c                 C  sV   | j  ¡  t|ƒ}| jD ]}| j  || ¡||< q| jD ]}| j  || ¡||< q8|S r   )r6   r'   r(   r   r)   r5   Úapply_on_labelsr*   r%   r%   r&   r.   B   s    


zCutMixd.__call__)Nr   Fr/   r%   r%   r#   r&   r   -   s      úc                      s6   e Zd ZdZddddddœ‡ fdd	„Zd
d„ Z‡  ZS )r   z“
    Dictionary-based version :py:class:`monai.transforms.CutOut`.

    Notice that the cutout is different for every entry in the dictionary.
    Fr   r   r   r   )r   r   r   r   c                   s   t ƒ  ||¡ t|ƒ| _d S r   )r   r    r	   Úcutout)r"   r   r   r   r#   r%   r&   r    S   s    zCutOutd.__init__c                 C  s4   t |ƒ}| j ¡  | jD ]}|  || ¡||< q|S r   )r(   r8   r'   r   r*   r%   r%   r&   r.   W   s
    

zCutOutd.__call__)Fr/   r%   r%   r#   r&   r   L   s   N)Ú
__future__r   Úmonai.configr   Úmonai.utils.miscr   Ú	transformr   Úarrayr   r	   r
   Ú__all__r   r   r   r   r   r   r   r   r   r%   r%   r%   r&   Ú<module>   s   