@@ -67,16 +67,10 @@ class TraceableTransform(Transform):
6767 The information in the stack of applied transforms must be compatible with the
6868 default collate, by only storing strings, numbers and arrays.
6969
70- `tracing` could be enabled by `self.set_tracing ` or setting
70+ `tracing` could be enabled by assigning to `self.tracing ` or setting
7171 `MONAI_TRACE_TRANSFORM` when initializing the class.
7272 """
7373
74- # tracing = MONAIEnvVars.trace_transform() != "0"
75-
76- # def set_tracing(self, tracing: bool) -> None:
77- # """Set whether to trace transforms."""
78- # self.tracing = tracing
79-
8074 def _init_trace_threadlocal (self ):
8175 # needed since this class is meant to be a trait with no constructor
8276 if not hasattr (self , "_tracing" ):
@@ -345,13 +339,11 @@ def get_most_recent_transform(self, data, key: Hashable = None, check: bool = Tr
345339 # Find the last transform whose name matches that of this class, this allows Invertd to ignore applied
346340 # operations added by transforms it is not trying to invert, ie. those added in postprocessing.
347341 idx = - 1
348- # for i in reversed(range(len(all_transforms))):
349- # xform_name = all_transforms[i].get(TraceKeys.CLASS_NAME, "")
350- # if xform_name == self.__class__.__name__:
351- # idx=i # if nothing found, idx remains -1 so replicating previous behaviour
352- # break
353-
354- # print(f"get_most_recent_transform {id(data):x} {type(data).__name__} {pop} {id(all_transforms):x} {len(all_transforms)}")
342+ for i in reversed (range (len (all_transforms ))):
343+ xform_name = all_transforms [i ].get (TraceKeys .CLASS_NAME , "" )
344+ if xform_name == self .__class__ .__name__ :
345+ idx = i # if nothing found, idx remains -1 so replicating previous behaviour
346+ break
355347
356348 if not all_transforms :
357349 raise ValueError (f"Item of type { type (data )} (key: { key } , pop: { pop } ) has empty 'applied_operations'" )
0 commit comments