NormalizeCoord#
- class NormalizeCoord(center=None, scale=None)[source]#
Bases:
objectRecenter and rescale
coordinto a normalized frame.Computes
coord = (coord - center) / scalein place. WhencenterisNonethe per-sample centroid (mean ofcoord) is used; whenscaleisNonethe max point norm after centering is used, mapping the cloud into the unit ball. The same shift/scale is applied to v3vertexmetadata and to opt-inaux_position_keysso position targets stay aligned; direction keys are left untouched (isotropic scale + translation preserve orientation). Requirescoord; a no-op ifcoordis absent. Registered asNormalizeCoord– use this string as thetypein atransform=[...]config list.- Parameters:
center (Sequence[float], optional) – fixed center to subtract. If
None, the per-sample centroid is used. Defaults toNone.scale (float, optional) – fixed divisor applied after centering. If
None, the max post-centering point norm is used (unit ball). Defaults toNone.
Note
NormalizeCoord(scale=X)computes(coord - center) / scale– it divides byX, it does not multiply. For PILArNet the standard fixed values arecenter=[384, 384, 384]andscale = 768 * sqrt(3) / 2 approx 665.1076(the half-diagonal of the768^3volume), mapping the detector into roughly[-1, 1]^3.Example
>>> import numpy as np >>> from pimm.datasets.transform import NormalizeCoord >>> data = {"coord": np.array([[0., 0., 0.], [1000., 0., 0.]], dtype="f4"), ... "energy": np.array([[1.], [5.]], dtype="f4")} >>> out = NormalizeCoord(center=[500., 0., 0.], scale=500.)(data) >>> out["coord"] # (coord - center) / scale: [0,1000] -> [-1,1] array([[-1., 0., 0.], [ 1., 0., 0.]], dtype=float32)