MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

Make more (random) transforms traceable

Open johnzielke opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. Knowing which transforms were applied to a sample can be very helpful in debugging the current transform pipeline and odd samples. Unfortunately it seems like currently only spatial transforms implement the TraceableTransform. This makes it hard to debug samples with overly agressive noise settings for example. Describe the solution you'd like Implement the TraceableTransform for more/most monai transforms

Additional context The transforms might often not record all information (e.g. the complete noise tensor of a GaussianNoise transform), but just whether they were applied or which scalars were sampled for the final noise in the iteration is already very useful (e.g. the standard deviation of the noise)

In case it's useful later, this is a small script I used to get an overview of what implements TraceableTransform

from monai import transforms
import pandas as pd
data = []

for item in dir(transforms):
    cls = getattr(transforms, item)
    if not isinstance(cls, type):
        continue
    is_transform = issubclass(cls, transforms.Transform)
    if not is_transform:
        continue
    if item.endswith('Dict') or item.endswith('D'):
        continue
    is_dict_transform = issubclass(cls, transforms.MapTransform)
    is_randomizable = issubclass(cls, transforms.RandomizableTransform)
    is_traceable = issubclass(cls, transforms.TraceableTransform)
    is_invertible = issubclass(cls, transforms.InvertibleTransform)
    data.append({
        'name': item,
        'is_dict_transform': is_dict_transform,
        'is_randomizable': is_randomizable,
        'is_traceable': is_traceable,
        'is_invertible': is_invertible,
    })

df = pd.DataFrame(data)
df.to_excel('transform_list.xlsx', index=False)

johnzielke avatar Apr 11 '24 22:04 johnzielke