Mean Std Normalization
Zero-mean and unit-variance normalization.
MeanStdNormalization
Bases: Normalization
Zero-mean and unit-variance normalization.
The normalization expects arrays of dimensions C(Z)YX.
Parameters:
-
input_means(list[float]) –Mean values (length 1 for global, multiple values for per channel).
-
input_stds(list[float]) –Standard deviation values (length 1 for global, multiple values for per channel).
-
target_means(list[float] | None, default:None) –Target mean values (length 1 for global, multiple values for per channel), by default None.
-
target_stds(list[float] | None, default:None) –Target standard deviation values (length 1 for global, multiple values for per channel), by default None.
-
skip_target(bool, defaut=False, default:False) –When True, target normalization is skipped and the target is returned unchanged.
__call__(patch, target=None)
Apply the transform to the source patch and the target (optional).
Parameters:
-
patch(ndarray) –Patch, 2D or 3D, shape C(Z)YX.
-
target(ndarray, default:None) –Target for the patch, by default None.
Returns:
-
tuple of numpy.ndarray–Transformed patch and target, the target can be returned as
None.
__init__(input_means, input_stds, target_means=None, target_stds=None, skip_target=False)
Constructor.
Parameters:
-
input_means(list[float]) –Mean values (length 1 for global, multiple values for per channel).
-
input_stds(list[float]) –Standard deviation values (length 1 for global, multiple values for per channel).
-
target_means(list[float] | None, default:None) –Target mean values (length 1 for global, multiple values for per channel), by default None.
-
target_stds(list[float] | None, default:None) –Target standard deviation values (length 1 for global, multiple values for per channel), by default None.
-
skip_target(bool, defaut=False, default:False) –When True, target normalization is skipped and the target is returned unchanged.
denormalize(patch)
Reverse the normalization operation for a batch of patches.
The data is denormalized using the target statistics, when available. When no target statistics are available, which is the case for self-supervised algorithms such as N2V, the data is denormalized using the input statistics.
If self.skip_target is True, then this method returns patch.
Parameters:
-
patch(Tensor) –Patch, 2D or 3D, shape BC(Z)YX.
Returns:
-
Tensor–Denormalized array.