MLI-lab / DeepDeWedge

Self-supervised deep learning for denoising and missing wedge reconstruction of cryo-ET tomograms
BSD 2-Clause "Simplified" License
34 stars 8 forks source link

How to obtain the SNR of the reconstructed tomogram after model correction? #16

Open DIGGORER opened 1 month ago

DIGGORER commented 1 month ago

In the paper, I saw the term "CC SNR." Could the authors provide the code related to SNR? Alternatively, can you share the approach used to evaluate SNR? Is it based on Fourier transform, ROI selection where regions of tissue or target structures are chosen in the image to calculate the mean signal, or any other methods?

SimWdm commented 1 month ago

Hi @DIGGORER,

thanks for reaching out!

In the paper, we evaluated the quality of reconstructed tomograms with respect to their clean ground truth using the cross correlation coefficient (CC), which is defined in Equation (7) here. We only computed CC values for reconstructions based on synthetic data where ground truth tomograms are available.

We used the term SNR only to measure the "noisiness" of the input tilt series. Again, we only discussed concrete SNR values for synthetic data (see Section "Experiments on synthetic data"), where clean ground truth is available. For a given synthetic clean tilt series $t{clean}$, we simulated a noisy tilt series $t{noisy}$ by adding pixel wise independent noise. The SNR of the noisy tilt series $t{noisy}$ with respect to its clean ground truth $t{clean}$ is defined as

$SNR = \frac{\text{var}(t{clean})}{\text{var}(t{clean})}$

where $\text{var}$ means pixel-wise variance. Note that here, we assume that $\text{mean}(t_{clean}) = 0$.

I hope this helps. Let me know if there is still anything unclear.

Best, Simon

DIGGORER commented 3 weeks ago

Hi Simon, "Thank you for your answer. I understand the meaning of SNR and CC in your research. You found complete, noise-free MRC samples, and then added Gaussian noise of varying intensity before inputting them into your model. You compared the output of the model with the perfect samples using the CC metric and compared it to other models. I would like to know what software or programming language libraries you used to add the Gaussian noise? Was it added to a 2D image sequence or was the Gaussian noise directly added to the 3D MRC file? "Is the file '.\shrec21_contest_dataset\model_0\grandmodel.mrc' used as the complete, noise-free sample in your research?" Lastly, can the CC metric be replaced with PSNR and SSIM metrics?" I look forward to receiving your reply. best, Diggorer

SimWdm commented 3 weeks ago

Hi @DIGGORER,

here are my answers to your questions:


Q1: I would like to know what software or programming language libraries you used to add the Gaussian noise? Was it added to a 2D image sequence or was the Gaussian noise directly added to the 3D MRC file?

A1: I used PyTorch to add the Gaussian noise directly onto the 2D tilt series images. I produced the tilt series images with tomosipo. Maybe this code snippet makes things clearer:

import torch
import tomosipo as ts

def get_tilt_series(vol, tilt_angles):
    A = ts.operator(
            volume_geometry=ts.volume(shape=vol.swapaxes(0, 1).shape),  # swapaxes shape due to tomosipo conventions
            projection_geometry=ts.parallel(angles=torch.deg2rad(tilt_angles), shape=vol.shape[1:])
        )
    # swapaxes is needed because tomosipo wants (x, n_projections, y) coordinates for projections
    tilt_series = A(vol.swapaxes(0, 1)).swapaxes(0, 1)
    return tilt_series

def get_noisy_tilt_series(vol, noise_var, tilt_angles, seed=0):
    ts = get_tilt_series(vol=vol, tilt_angles=tilt_angles)
    mean = ts.mean(dim=(-1, -2), keepdim=True)
    std = ts.std(dim=(-1, -2), keepdim=True)
    ts = (ts - mean) / std
    noise = math.sqrt(noise_var) * torch.randn(ts.shape, device=ts.device, generator=torch.Generator().manual_seed(seed))
    noisy_ts = (ts + noise) * std + mean
    return noisy_ts

The vol input to both functions above is a (clean) 3D torch tensor. Setting noise_var to, e.g., 2 produces a tilt series with SNR = 1/2.


Q2: Is the file '.\shrec21_contest_dataset\model_0\grandmodel.mrc' used as the complete, noise-free sample in your research?

A2: Figure 7 in the paper shows model_0 but the model I used to produce this Figure (and Figure 6) was fitted on model_0, model_1 and model_2 simultaneously. Fitting only on model_0 gave very similar results (see also Supplementary Information 5).


Q3: Lastly, can the CC metric be replaced with PSNR and SSIM metrics?

A3: Yes, you can use any image metric. I chose CC because it is closer to the common Fourier shell correlation (FSC) metric than PSNR or SSIM.


I hope this helps, please let me know if there is still anything unclear.

Best, Simon

DIGGORER commented 1 week ago

Hi Simon

Thank you very much for answering my question in detail once again, but I still have some doubts regarding question 3. Here’s how you

A3: Yes, you can use any image metric. I chose CC because it is closer to the common Fourier shell correlation (FSC) metric than PSNR or SSIM.

The FSC metric is calculated in reciprocal space, which means performing a Fourier transform on the 3D MRC file before calculation. Since the CC metric is similar to the FSC metric in calculation. does it also require performing a Fourier transform on the 3D MRC file before calculation, or can it be calculated directly in real space?

Thank you very much for your response once again! best, Diggorer

SimWdm commented 1 week ago

Hi @DIGGORER,

calculating the CC in real or reciprocal space (Fourier space) should give the same results because the Fourier transform preserves norms and inner products.

Best, Simon