denoise.data3d

3D dataset classes for Noise2Inverse volumetric denoising (–mode 3d).

TrainingTomoDataset3DTrain — random cubic patch sampling with full 3D

geometric augmentation (24 rotational symmetries of a cube + random flip).

InferenceTomoDataset3DInfer — sliding-window 3D grid extraction with

overlap-add stitching back to full volume.

Augmentation strategy adapted from SSD_3D (Laugros et al., bioRxiv 2025).

class denoise.data3d.TomoDataset3DInfer(*args: Any, **kwargs: Any)[source]

Bases: Dataset

Inference dataset for 3D Noise2Inverse.

Loads a TIFF stack [D, H, W] and yields overlapping cubic patches for model inference. After all patches are predicted, call stitch_predictions() to blend them back into the full volume.

Parameters:
  • params (dict) – Parsed YAML config.

  • start_slice (str) – First slice index (empty string = first slice).

  • end_slice (str or None) – Last slice index (None = last slice).

stitch_predictions(pred_patches: numpy.ndarray, window: Literal['uniform', 'hann'] = 'hann', eps: float = 1e-06) numpy.ndarray[source]

Overlap-add stitching of 3D patch predictions.

Parameters:
  • pred_patches (np.ndarray, shape [T, psz, psz, psz]) – Model outputs in the same order as dataset iteration.

  • window (str) – Blending window: ‘hann’ (recommended) or ‘uniform’.

  • eps (float) – Denominator safety term.

Returns:

vol (np.ndarray, shape [D, H, W] (original unpadded size))

class denoise.data3d.TomoDataset3DTrain(*args: Any, **kwargs: Any)[source]

Bases: Dataset

Training dataset for 3D Noise2Inverse.

Loads two TIFF stacks (split0 / split1) into CPU memory as 3D NumPy arrays [D, H, W], normalises them, and serves random cubic patches of size psz_3d with 3D geometric augmentation.

Parameters:
  • params (dict) – Parsed YAML config (same structure as 2.5D).

  • config_file (str) – Path to the YAML, used to save normalisation stats.

denoise.data3d.geom_transform_3d(vol0: torch.Tensor, vol1: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Apply one of the 24 rotational symmetries of a cube, then optionally flip horizontally. The same transform is applied to both volumes so the N2I pairing is preserved.

Parameters:

vol0, vol1 (torch.Tensor, shape [1, D, H, W])

Returns:

vol0, vol1 (torch.Tensor, shape [1, D, H, W] (transformed))

denoise.data3d.save_normalization_value_3d(config_file, mean, std)[source]

Write mean4norm / std4norm into the YAML config (reuses data.py’s version).