mmv_im2im.preprocessing package

Submodules

mmv_im2im.preprocessing.transforms module

mmv_im2im.preprocessing.transforms.norm_around_center(img, z_center: int | None = None, min_z: int | None = 32)[source]

Returns normalized version of input img. img will be normalized with respect to the mean, std pixel intensity of the sub-array of length 32 in the z-dimension centered around the img’s “z_center”. :Parameters: * img – Input 4D torch.Tensor or numpy array to be normalized.

  • z_center – Z-index of cell centers.

Returns:

Normalized image

Return type:

4D numpy array or tensor

mmv_im2im.preprocessing.transforms.normalize_staining(img, Io=240, alpha=1, beta=0.15, return_unmix_results: bool = False)[source]

Normalize staining appearence of H&E stained images

Input:

I: RGB input image (we assume channel order CYX), numpy array or torch.tensor Io: (optional) transmitted light intensity alpha: parameter from paper (see Reference) beta: parameter from paper (see Reference) return_unmix_results: whether to return unmixed H and E channel for debugging

Output:

Inorm: normalized image H: (optional, only when return_unmix_results=True) hematoxylin image E: (optional, only when return_unmix_results=True) eosin image

Reference:

A method for normalizing histology slides for quantitative analysis. M. Macenko et al., ISBI 2009

mmv_im2im.preprocessing.transforms.pad_to_multiple(img, multiple_base: int | Tuple[int] | List[int] = 8, pad_value: str | float | int = 0)[source]

Returns padded image. img will be padded to the size of multiple of “multiple_base”.

Parameters:
  • img – Input 4D torch.Tensor or numpy array to be padded, C x X x Y x Z

  • multiple_base – int or a sequence of int

Returns:

padded image

Return type:

4D numpy array or tensor

mmv_im2im.preprocessing.transforms.pad_z(img, target_size: int = 64, pad_value: str | float | int = 0)[source]

Returns padded image. img will be padded along z to the size of “target_size”.

Parameters:
  • img – Input 4D torch.Tensor or numpy array to be padded, C x Z x Y x X

  • target_size – int

Returns:

padded image

Return type:

4D numpy array or tensor

Module contents