question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RandAffined fails with KeyError when allow_missing_keys and key at index 0 is missing

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
Nic-Macommented, Nov 10, 2021

Hi @Spenhouet ,

Thanks for your feedback. I am already working on a PR to address this issue, will submit for review soon.

Thanks.

1reaction
Spenhouetcommented, Nov 12, 2021

Hi @Nic-Ma,

looks good to me! Thanks you!

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found