denoise.data
- class denoise.data.PatchIndex(d_idx: int, top: int, left: int)[source]
Bases:
objectOne patch address within the volume. d_idx: center slice index for 2.5D stack top,left: spatial location within padded H/W coordinates
- d_idx: int
- left: int
- top: int
- class denoise.data.TilingMeta(D: int, H_in: int, W_in: int, H_pad: int, W_pad: int, ph: int, pw: int, stride_h: int, stride_w: int, n_rows: int, n_cols: int, P_per_slice: int, pad_bottom: int, pad_right: int, neighbors: int, edge_mode: str, pad_mode: str)[source]
Bases:
objectMetadata needed for stitching (later) and sanity checks.
- D: int
- H_in: int
- H_pad: int
- P_per_slice: int
- W_in: int
- W_pad: int
- edge_mode: str
- n_cols: int
- n_rows: int
- neighbors: int
- pad_bottom: int
- pad_mode: str
- pad_right: int
- ph: int
- pw: int
- stride_h: int
- stride_w: int
- class denoise.data.TomoDatasetInfer(*args: Any, **kwargs: Any)[source]
Bases:
DatasetDataset that yields overlapping patches from a CT volume (NumPy) with 2.5D channels.
Input volume: vol [D, H, W] (NumPy array)
Each item returns:
x_patch: torch.FloatTensor [C, ph, pw]
info: dict with patch coordinates and indices (for stitching later)
- stitch_predictions(pred_patches: numpy.ndarray, *, window: Literal['uniform', 'hann', 'cosine'] = 'hann', output_size: Tuple[int, int] | None = None, keep_k_dim: bool = True, eps: float = 1e-06) numpy.ndarray[source]
Stitch patch predictions back into a (sub)volume using overlap-add blending.
- Parameters:
pred_patches –
- Patch predictions in dataset order (same order as self.index):
[T, ph, pw] regression (implicit K=1)
[T, 1, ph, pw] regression (explicit K=1)
[T, K, ph, pw] segmentation logits/probs
where T must equal len(self.index) == total_patches.
window – Blending window: ‘uniform’ (avg) or ‘hann’/’cosine’ (recommended).
output_size – (H, W) to crop final result. If None, uses (H_in, W_in).
keep_k_dim –
- If pred_patches was [T, ph, pw], output can be:
keep_k_dim=True -> [D_sel, 1, H, W]
keep_k_dim=False -> [D_sel, H, W]
If pred_patches already has K dim, output keeps it.
eps – Small constant to avoid divide-by-zero in normalization.
- Returns:
- out – - [D_sel, K, H, W] (typical)
or [D_sel, H, W] if K==1 and keep_k_dim=False
where D_sel = (d_end - d_start), i.e., only the slices this dataset processed. These correspond to the center slice predictions in your 2.5D setup.
- class denoise.data.TomoDatasetTrain(*args: Any, **kwargs: Any)[source]
Bases:
DatasetTraining class for 2.5D N2I.
This class loads in two lists corresponding to the two sub reconstructions (saved as .tiffs) and normalizes them.
- params:
params (obj) yaml object, essentially a dictionary
config_file (str) location of the configuration file
- denoise.data.save_normalization_value(config_file, mean, std)[source]
This functin saves the mean and standard deviation back to the yaml file which is then used during inferencing
- params:
config_file (str) location of the config file
mean (float) mean used for normalization
std (float) standard deviation used for normalization