synthbold.visualize

Visualization utilities for synthBOLD outputs.

synthbold.visualize.make_gif(fname: Path, data: Tensor, cmap: str = 'tab20', mip: bool = False, fps: int = 2) None

Make a GIF animation from the middle axial slice of a batch of 3D volumes.

Each batch element becomes one frame. The slice is taken at the midpoint of the last (z) axis.

Parameters:
  • fname – Output file path for the saved GIF.

  • data – Batch of 3D volumes with shape (N, X, Y, Z).

  • cmap – Matplotlib colormap name.

  • mip – Whether to display a maximum intensity projection.

  • fps – Frames per second for the output GIF.

synthbold.visualize.render_3d(fname: Path, mask: Tensor, color: str = 'steelblue', alpha: float = 0.7, elev: float = 30.0, azim: float = -60.0) None

Render a 3D binary mask as a surface mesh and save as PNG.

Uses marching cubes to extract an isosurface from the binary mask, then renders it as a shaded polygon mesh from a configurable viewpoint.

Parameters:
  • fname – Output file path for the saved PNG.

  • mask – 3D binary mask tensor of shape (X, Y, Z).

  • color – Face color for the surface mesh.

  • alpha – Opacity of the surface mesh.

  • elev – Elevation angle of the 3D view in degrees.

  • azim – Azimuth angle of the 3D view in degrees.

Raises:

ValueError – If mask is not a 3D tensor.