RandAffined fails with KeyError when allow_missing_keys and key at index 0 is missing
See original GitHub issueDescribe the bug
We have a pipeline in which not all samples have the same keys.
The RandAffined
transform accesses fallback data via index 0.
If index 0 is a missing key, then this transform will fail with a KeyError
.
805 sp_size = fall_back_tuple(self.rand_affine.spatial_size, data[self.keys[0]].shape[1:])
806 # change image size or do random transform
807 do_resampling = self._do_transform or (sp_size != ensure_tuple(data[self.keys[0]].shape[1:]))
Expected behavior
If the option allow_missing_keys
is set, I would expect the RandAffined
transform to take the first element of the existing keys as fallback.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
KeyError Pandas – How To Fix - Data Independent
Pandas KeyError - This annoying error means that Pandas can not find your column name in your dataframe. Here's how to fix this...
Read more >Pandas KeyError: value not in index - python - Stack Overflow
Use reindex to get all columns you need. It'll preserve the ones that are already there and put in empty columns otherwise.
Read more >Add option for transforms to skip missing keys instead ... - GitHub
Successfully merging a pull request may close this issue. [1662] Allow missing keys rijobro/MONAI. 2 participants.
Read more >Transforms — MONAI 1.1.0 Documentation
If key is missing, exception is raised if allow_missing_keys==False (default). ... detailed information of data and applied transform when error happened, ...
Read more >KeyError Pandas: How To Fix - YouTube
Pandas KeyError is frustrating. This error happens because Pandas cannot find what you're looking ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Spenhouet ,
Thanks for your feedback. I am already working on a PR to address this issue, will submit for review soon.
Thanks.
Hi @Nic-Ma,
looks good to me! Thanks you!