ReflectionPad3d

https://pytorch.org/docs/stable/generated/torch.nn.ReflectionPad3d.html

reflection_pad3d_demo.py
import svetoviz_webgpu as sv

# 1. Prepare 3D volume (e.g., 32 slices)
input_volume = torch.from_numpy(np.stack(slices)).unsqueeze(0).unsqueeze(0)

# 2. Define ReflectionPad3d (Pads 2 voxels across all 6 faces)
pad3d = nn.ReflectionPad3d(padding=2)

def terminal_callback(buffer, message, images, files):
    output = pad3d(input_volume)

    buffer.send_system_message(f"Input Voxel Grid: {input_volume.shape[2:]}")
    buffer.send_system_message(f"Padded Voxel Grid: {output.shape[2:]}")
    buffer.send_system_message("Volumetric mirroring applied to depth, height, and width.")

# 3. Start the interactive session
sv.pytorch_web(module=pad3d, terminal_callback=terminal_callback)
Volumetric Reflection
ReflectionPad3d volumetric visualization
3D reflection padding extends the volume by mirroring voxels across the Depth, Height, and Width planes, ensuring data consistency in volumetric tasks like MRI analysis.