diffuse: Diffuseness around centre of mass#

hypercoil.functional.cmass.diffuse(X: Tensor, coor: Tensor, norm: Any = 2, floor: float = 0, radius: float | None = None) Tensor[source]#

Compute a compactness score for a weight.

The compactness is defined as

\(\mathbf{1}^\intercal\left(A \circ \left\|C - \frac{AC}{A\mathbf{1}} \right\|_{cols} \right)\mathbf{1}\)

Dimension:
Input : \((*, W, L)\)

* denotes any number of preceding dimensions, W denotes number of weights (e.g., regions of an atlas), and L denotes number of locations (e.g., voxels).

coor : \((*, D, L)\)

D denotes the dimension of the embedding space of the locations.

Parameters:
XTensor

Weight for which the compactness score is to be computed.

coorTensor

Coordinates corresponding to each column (location/voxel) in X.

norm

Indicator of the type of norm to use for the distance function.

floorfloat (default 0)

Any points closer to the centre of mass than the floor are assigned a compactness score of 0.

radiusfloat or None (default None)

If this is not None, then the centre of mass and distances are computed on a sphere with the specified radius.

Returns:
float

Measure of each weight’s compactness about its centre of mass.