ValidationVolumeGridCallback#

class ValidationVolumeGridCallback(*args, **kwargs)#

Bases: Callback

Validation volume grid callback for 3D spatial recall tasks.

Visualizes 3D input volumes as perspective 3D scatter plots with depth on X-axis, alongside 2D prediction and label images. Similar to the dataset visualization.

Parameters:
  • num_samples (int) – Number of samples to visualize.

  • every_n_epochs (int | None) – How often to visualize (in epochs). Set to None to disable.

  • every_n_train_steps (int | None) – How often to visualize (in training steps). Set to None to disable.

  • key (str) – Key to use for the visualization in the logger.

  • show_mask_separately (bool) – If True and input has mask channel, display mask in 3D view.

  • target_size (int) – Size of the target/prediction image (for readout region display).

  • denormalize (bool) – Whether to denormalize the images.

  • mean (float) – Mean of the dataset (for denormalization).

  • std (float) – Standard deviation of the dataset (for denormalization).

__init__(
num_samples=4,
every_n_epochs=1,
every_n_train_steps=None,
key='val/volume_grid',
show_mask_separately=False,
target_size=16,
denormalize=True,
mean=0.1307,
std=0.3081,
)#

Initialize the callback.

Parameters:
  • num_samples (int)

  • every_n_epochs (int | None)

  • every_n_train_steps (int | None)

  • key (str)

  • show_mask_separately (bool)

  • target_size (int)

  • denormalize (bool)

  • mean (float)

  • std (float)

Return type:

None

on_validation_epoch_end(
trainer,
pl_module,
)#

Visualize the validation volumes at the end of the epoch.

Parameters:
  • trainer (pytorch_lightning.Trainer)

  • pl_module (pytorch_lightning.LightningModule)

Return type:

None

on_train_batch_end(
trainer,
pl_module,
outputs,
batch,
batch_idx,
)#

Visualize volumes during training every N steps.

Parameters:
  • trainer (pytorch_lightning.Trainer)

  • pl_module (pytorch_lightning.LightningModule)

  • batch_idx (int)

Return type:

None