decomposition#
- voxel.pca(volumes, n_components=3, mask=None, center=True, standardize=False, whiten=False, normalize='quantile', quantile=0.01, return_basis=False) Volume | list[Volume] | tuple#
Project the feature channels of one or more volumes onto their principal components using PCA.
Given a list of volumes, a single shared basis is fit across all of them so the resulting colormaps are comparable.
- Parameters:
n_components (int, optional) – Number of components to keep, i.e. the output channel count. Defaults to 3 (RGB).
mask (Volume or list[Volume], optional) – Foreground mask(s) restricting which voxels are used to fit the basis and normalization. The basis is still applied to every voxel. A single mask is applied to all inputs, a list must match the number of inputs.
center (bool, optional) – Subtract the per-channel mean before fitting.
standardize (bool, optional) – Scale each input channel to unit variance before fitting (correlation-based PCA).
whiten (bool, optional) – Scale each output component to unit variance, balancing their contribution to the colormap.
normalize (str, optional) – Per-component output normalization: ‘minmax’ (rescale to \([0, 1]\)), ‘quantile’ (robust rescaling that clips the
quantiletails), or None. Stats are computed from foreground voxels. Defaults to ‘quantile’.quantile (float, optional) – Tail fraction clipped when using ‘quantile` normalization. Defaults to 0.01.
return_basis (bool, optional) – If True, also return the fit basis dict.
- Returns:
Volume or list[Volume] –
- The projected volume(s) with
n_components channels, matching the single-vs-list structure of the input. If
return_basisis True, an(output, basis)tuple is returned instead.
- The projected volume(s) with