@@ -556,7 +556,7 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = No
556556 roi_end = self ._resolve_roi_param (self ._roi_end , d )
557557
558558 lazy_ = self .lazy if lazy is None else lazy
559- self . cropper = SpatialCrop (
559+ cropper = SpatialCrop (
560560 roi_center = roi_center ,
561561 roi_size = roi_size ,
562562 roi_start = roi_start ,
@@ -565,25 +565,25 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor], lazy: bool | None = No
565565 lazy = lazy_ ,
566566 )
567567 for key in self .key_iterator (d ):
568- d [key ] = self . cropper (d [key ], lazy = lazy_ )
568+ d [key ] = cropper (d [key ], lazy = lazy_ )
569569 return d
570570
571571 def inverse (self , data : Mapping [Hashable , MetaTensor ]) -> dict [Hashable , MetaTensor ]:
572572 """
573573 Inverse of the crop transform, restoring the original spatial dimensions via padding.
574574
575- For the string-key path, ``self. cropper`` is recreated on each ``__call__``, so its
576- ``id()`` won't match the one stored in the MetaTensor's transform stack. This override
577- bypasses the ID check and applies the inverse directly using the crop info stored in the
578- MetaTensor.
575+ For the string-key path, the cropper used in ``__call__`` is a per-invocation local
576+ instance, so its ``id()`` won't match the one stored in the MetaTensor's transform stack.
577+ This override bypasses the ID check and applies the inverse directly using the crop info
578+ stored in the MetaTensor.
579579
580580 Args:
581581 data: dictionary of cropped ``MetaTensor`` items.
582582
583583 Returns:
584584 Dictionary with inverse-transformed (padded) data for each key.
585585 """
586- if not self ._has_str_roi :
586+ if not self .requires_current_data :
587587 return super ().inverse (data )
588588 d = dict (data )
589589 for key in self .key_iterator (d ):
0 commit comments