Skip to content

Commit

Permalink
Removed dead code (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
adefazio authored Sep 1, 2022
1 parent 37ffc89 commit ce9a8ef
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions banding_removal/fastmri/data/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,31 +488,6 @@ def complex_planar_to_packed(data):
imaginary = data[..., 1, :, :]
return torch.stack([real, imaginary], dim=-1)


def complex_whiten(complex_image, eps=1e-10):
real = complex_image[:, :, 0]
imag = complex_image[:, :, 1]

# Center around mean.
centered_complex_image = complex_image - complex_image.mean()

# Determine covariance between real and imaginary.
n = real.nelement()
real_real = (real.mul(real).sum() - real.mean().mul(real.mean())) / n
real_imag = (real.mul(imag).sum() - real.mean().mul(imag.mean())) / n
imag_imag = (imag.mul(imag).sum() - imag.mean().mul(imag.mean())) / n
V = torch.Tensor([[real_real, real_imag], [real_imag, imag_imag]])

# Remove correlation by rotating around covariance eigenvectors.
eig_values, eig_vecs = torch.eig(V, eigenvectors=True)
whitened_image = torch.matmul(centered_complex_image, eig_vecs)

# Scale by eigenvalues for unit variance.
whitened_image[:, :, 0] = whitened_image[:, :, 0] / (eig_values[0, 0] + eps).sqrt()
whitened_image[:, :, 1] = whitened_image[:, :, 1] / (eig_values[1, 0] + eps).sqrt()
return whitened_image


# Helper functions

def roll(x, shift, dim):
Expand Down

0 comments on commit ce9a8ef

Please sign in to comment.