topaz icon indicating copy to clipboard operation
topaz copied to clipboard

Denoising of tiff/tif files

Open annwhoorma opened this issue 1 year ago • 2 comments

I'd like to denoise frames saved as tiff. While I had no problem training a denoiser and using it with mrc files, I did run into issues with tiff, specifically with EMPIAR-10673.

Where I am at:

  • I am confused about this: in this dataset, each frame of each micrograph contains integers (moreover, each pixel of each frame is either 0 or 1), which is not the case for mrc that I am used to. Is it normal for tiff data?
  • Summing even/odd/all frames yields a black image because many final pixels have low values, and then even scaling all values between 0 and 255 doesn't help either.
  • Since topaz doesn't support reading multi-frame tiff files, I found this advice on how to read them. However, they apply binning which leads to downscaling but also allows to see some particles, and binning also helped in my case. But my understanding is that topaz denoise should be trained on raw data, not downscaled or binned.

Do you have any advice on how to prepare tiff multi-frame data for denoiser training?

annwhoorma avatar Nov 14 '24 12:11 annwhoorma

@tbepler is probably more sure, but your first two bullets do sound strange.

I looked at the code you linked to and if the only problem with it is the height and width binning, then you can just remove the binning lines. It would then look like:

import tifffile
im = tifffile.imread('20180309_Vn_ribosome_0001.tif', maxworkers=6)
im = im.sum(axis=0, dtype='uint32') # if it's a numpy array

from matplotlib import pyplot
pyplot.imshow(im, cmap='gray')
pyplot.show()

DarnellGranberry avatar Nov 18 '24 17:11 DarnellGranberry

Thanks for your reply! Applying binning makes the image have some contrast. If I don't apply binning to a tiff image that contains 1s and 0s, it just stays mostly dark with no notion of particles. For example, take GLP-1 dataset from EMPIAR, I took image "PS0829.GLP-GLP1_105-10_0000_Aug31_11.58.07.tif"

Here is that tiff size read with binsize 25: image Same image with binsize 1 as you suggested: image You can also see what I meant about each frame containing only integers: image

Attaching a link to google colab with an example: https://colab.research.google.com/drive/1Q2PEZ99-mb3uQPsrFppXGIRJ6V0c3Ajs?usp=sharing

annwhoorma avatar Nov 19 '24 19:11 annwhoorma