tools.whiten

tools.whiten#

bartorch.tools.whiten()#

Noise prewhitening of multi-channel data with a noise-only measurement.

Multiplies the channels of input by \(W = L^{-1}\), where \(L\) is the lower triangular Cholesky factor of the channel noise covariance \(\Psi = L L^H\) estimated from ndata, so that \(W \Psi W^H = I\).

Parameters:
  • input (torch.Tensor) – Data to whiten, (coils, z, y, x): the channels are axis -4, and one slice has a z axis of length one.

  • ndata (torch.Tensor) – Noise-only measurement of the same channels in the same layout. Every axis but the channel axis indexes noise samples.

  • return_matrix (bool, default=False) – Also return the whitening matrix \(W\), BART’s optional second output.

  • return_covariance (bool, default=False) – Also return the noise covariance, BART’s optional third output.

  • **extra – Further BART whiten options, by name. o and c take a whitening matrix and a noise covariance in the layout returned here, to use in place of the ones estimated from ndata; n normalizes the variance to one using ndata.

Returns:

The whitened data, in the shape of input; then, when asked for, the whitening matrix and the noise covariance, in that order, each (coils, coils, 1, 1, 1).

Return type:

torch.Tensor or tuple of torch.Tensor

Notes

The covariance is \(\Psi = (K - 1)^{-1} \sum_k n_k n_k^H\) over the \(K\) samples of ndata, \(n_k\) being the channel vector of the \(k\)-th, with no mean removed, so that ndata is taken to be zero-mean. The returned matrix is \(W\), acting on the channel vector from the left, and the returned covariance is the transpose \(\Psi^T = \overline{\Psi}\).

Examples

>>> white = whiten(data, noise)
>>> white, matrix = whiten(data, noise, return_matrix=True)
>>> other = whiten(more_data, noise, o=matrix)

Examples using whiten#

Noise prewhitening

Noise prewhitening