def whitener(C, rtol=1e-15):
  e, E = np.linalg.eigh(C)
  return reduce(np.dot, 
    [E, np.diag(np.where(e > np.max(e) * rtol, e, np.inf)**-.5), E.T])
Calculate the whitening transform for signals with covariance C.
dataset/ETHPy150Open breuderink/eegtools/eegtools/spatfilt.py/whitener