|
23 | 23 | from monai.data.meta_obj import MetaObj, get_track_meta |
24 | 24 | from monai.data.utils import affine_to_spacing, decollate_batch, list_data_collate, remove_extra_metadata |
25 | 25 | from monai.utils import look_up_option |
26 | | -from monai.utils.enums import MetaKeys, PostFix, SpaceKeys |
27 | | -from monai.utils.type_conversion import convert_data_type, convert_to_tensor |
| 26 | +from monai.utils.enums import LazyAttr, MetaKeys, PostFix, SpaceKeys |
| 27 | +from monai.utils.type_conversion import convert_data_type, convert_to_numpy, convert_to_tensor |
28 | 28 |
|
29 | 29 | __all__ = ["MetaTensor"] |
30 | 30 |
|
@@ -445,6 +445,20 @@ def pixdim(self): |
445 | 445 | return [affine_to_spacing(a) for a in self.affine] |
446 | 446 | return affine_to_spacing(self.affine) |
447 | 447 |
|
| 448 | + def peek_pending_shape(self): |
| 449 | + """Get the currently expected spatial shape as if all the pending operations are executed.""" |
| 450 | + res = None |
| 451 | + if self.pending_operations: |
| 452 | + res = self.pending_operations[-1].get(LazyAttr.SHAPE, None) |
| 453 | + # default to spatial shape (assuming channel-first input) |
| 454 | + return tuple(convert_to_numpy(self.shape, wrap_sequence=True).tolist()[1:]) if res is None else res |
| 455 | + |
| 456 | + def peek_pending_affine(self): |
| 457 | + res = None |
| 458 | + if self.pending_operations: |
| 459 | + res = self.pending_operations[-1].get(LazyAttr.AFFINE, None) |
| 460 | + return self.affine if res is None else res |
| 461 | + |
448 | 462 | def new_empty(self, size, dtype=None, device=None, requires_grad=False): |
449 | 463 | """ |
450 | 464 | must be defined for deepcopy to work |
|
0 commit comments