Skip to content

MapTransform for missing keys #1591

Answered by rijobro
jansoe asked this question in Q&A
Feb 16, 2021 · 3 comments · 5 replies
Discussion options

You must be logged in to vote

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 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…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@jansoe
Comment options

@ericspod
Comment options

@jansoe
Comment options

@jansoe
Comment options

@rijobro
Comment options

Answer selected by jansoe
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants