-
The documentation for the abstract MapTransform MONAI/monai/transforms/compose.py Lines 251 to 257 in 8084394 states that MapTransform should "do nothing" for missing keys. But all implemented MapTransform will fail if for example the label key is not availableMONAI/monai/transforms/spatial/dictionary.py Lines 272 to 274 in 8084394 Is there a rational for this? Is there an elegant way to deal with missing labels e.g. in some mixed supervised and unsupervised training |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
If you wanted to update the MONAI source code to do nothing for extra keys (it would require replacing all dictionary for loops), finding the intersection between the desired keys and the data's keys should work: for key in set(self.keys) & set(data.keys()):
d[key] = self.rotator(d[key])
return d If you wanted a solution that would work without modifying MONAI's code, perhaps you could create a dummy variable? For example, if |
Beta Was this translation helpful? Give feedback.
-
this is a good point, perhaps we need to update the dict transforms to have an |
Beta Was this translation helpful? Give feedback.
-
@jansoe This should be merged with #1676. Give it a go and let us know if you have any problems! The misleading documentation has also been updated: https://github.com/Project-MONAI/MONAI/blob/master/monai/transforms/transform.py#L176-L182. |
Beta Was this translation helpful? Give feedback.
If you wanted to update the MONAI source code to do nothing for extra keys (it would require replacing all dictionary for loops), finding the intersection between the desired keys and the data's keys should work:
If you wanted a solution that would work without modifying MONAI's code, perhaps you could create a dummy variable? For example, if
label
is missing, then create a small numpy image. You'd also want to record whether a dummy variable needed to be created (probably under another key e.g.,data["label_is_dummy"]=True
). You could do all that by creating your own callable transform. It sounds…