-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix #8442: pass meta_data to EnsureChannelFirst when track_meta is False #8835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -497,6 +497,16 @@ def test_correct(self, input_param, expected_shape, track_meta): | |||||||||||||||||||||||||||||||||||
| self.assertNotIsInstance(r, MetaTensor) | ||||||||||||||||||||||||||||||||||||
| self.assertFalse(hasattr(r, "affine")) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def test_track_meta_false_ensure_channel_first(self): | ||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||
| set_track_meta(False) | ||||||||||||||||||||||||||||||||||||
| r = LoadImage(image_only=True, ensure_channel_first=True)(self.test_data) | ||||||||||||||||||||||||||||||||||||
| self.assertTupleEqual(r.shape, (1, 128, 128, 128)) | ||||||||||||||||||||||||||||||||||||
| self.assertIsInstance(r, torch.Tensor) | ||||||||||||||||||||||||||||||||||||
| self.assertNotIsInstance(r, MetaTensor) | ||||||||||||||||||||||||||||||||||||
| finally: | ||||||||||||||||||||||||||||||||||||
| set_track_meta(True) | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+501
to
+508
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This ensures the previous state is restored which could be False. This isn't thread-safe by the way but every other usage of these functions isn't either so we will have to accept this for now until that's fixed.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unlikely to be an issue in the tests honestly but we should do this anyway just in case. |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||||
| unittest.main() | ||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.