|
17 | 17 |
|
18 | 18 | import copy
|
19 | 19 | import logging
|
20 |
| -from typing import Callable, Dict, Hashable, List, Mapping, Optional, Sequence, Tuple, Union |
| 20 | +from typing import Any, Callable, Dict, Hashable, List, Mapping, Optional, Sequence, Tuple, Union |
21 | 21 |
|
22 | 22 | import numpy as np
|
23 | 23 | import torch
|
|
64 | 64 | "CopyItemsd",
|
65 | 65 | "ConcatItemsd",
|
66 | 66 | "Lambdad",
|
| 67 | + "RandLambdad", |
67 | 68 | "LabelToMaskd",
|
68 | 69 | "FgBgToIndicesd",
|
69 | 70 | "ConvertToMultiChannelBasedOnBratsClassesd",
|
70 | 71 | "AddExtremePointsChanneld",
|
| 72 | + "TorchVisiond", |
71 | 73 | "IdentityD",
|
72 | 74 | "IdentityDict",
|
73 | 75 | "AsChannelFirstD",
|
|
76 | 78 | "AsChannelLastDict",
|
77 | 79 | "AddChannelD",
|
78 | 80 | "AddChannelDict",
|
| 81 | + "RandLambdaD", |
| 82 | + "RandLambdaDict", |
79 | 83 | "RepeatChannelD",
|
80 | 84 | "RepeatChannelDict",
|
81 | 85 | "SplitChannelD",
|
|
106 | 110 | "ConvertToMultiChannelBasedOnBratsClassesDict",
|
107 | 111 | "AddExtremePointsChannelD",
|
108 | 112 | "AddExtremePointsChannelDict",
|
109 |
| - "TorchVisiond", |
110 | 113 | "TorchVisionD",
|
111 | 114 | "TorchVisionDict",
|
112 | 115 | ]
|
@@ -621,6 +624,27 @@ def __call__(self, data):
|
621 | 624 | return d
|
622 | 625 |
|
623 | 626 |
|
| 627 | +class RandLambdad(Lambdad, Randomizable): |
| 628 | + """ |
| 629 | + Randomizable version :py:class:`monai.transforms.Lambdad`, the input `func` contains random logic. |
| 630 | + It's a randomizable transform so `CacheDataset` will not execute it and cache the results. |
| 631 | +
|
| 632 | + Args: |
| 633 | + keys: keys of the corresponding items to be transformed. |
| 634 | + See also: :py:class:`monai.transforms.compose.MapTransform` |
| 635 | + func: Lambda/function to be applied. It also can be a sequence of Callable, |
| 636 | + each element corresponds to a key in ``keys``. |
| 637 | + overwrite: whether to overwrite the original data in the input dictionary with lamdbda function output. |
| 638 | + default to True. it also can be a sequence of bool, each element corresponds to a key in ``keys``. |
| 639 | +
|
| 640 | + For more details, please check :py:class:`monai.transforms.Lambdad`. |
| 641 | +
|
| 642 | + """ |
| 643 | + |
| 644 | + def randomize(self, data: Any) -> None: |
| 645 | + pass |
| 646 | + |
| 647 | + |
624 | 648 | class LabelToMaskd(MapTransform):
|
625 | 649 | """
|
626 | 650 | Dictionary-based wrapper of :py:class:`monai.transforms.LabelToMask`.
|
@@ -830,3 +854,4 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> Dict[Hashable, torc
|
830 | 854 | ) = ConvertToMultiChannelBasedOnBratsClassesd
|
831 | 855 | AddExtremePointsChannelD = AddExtremePointsChannelDict = AddExtremePointsChanneld
|
832 | 856 | TorchVisionD = TorchVisionDict = TorchVisiond
|
| 857 | +RandLambdaD = RandLambdaDict = RandLambdad |
0 commit comments