tools.whiten#
- bartorch.tools.whiten()#
Noise prewhitening of multi-channel data with a noise-only measurement.
Multiplies the channels of
inputby \(W = L^{-1}\), where \(L\) is the lower triangular Cholesky factor of the channel noise covariance \(\Psi = L L^H\) estimated fromndata, 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 azaxis 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
whitenoptions, by name.oandctake a whitening matrix and a noise covariance in the layout returned here, to use in place of the ones estimated fromndata;nnormalizes the variance to one usingndata.
- 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 thatndatais 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)