Skip to content

Denoising of tiff/tif files #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
annwhoorma opened this issue Nov 14, 2024 · 2 comments
Open

Denoising of tiff/tif files #211

annwhoorma opened this issue Nov 14, 2024 · 2 comments

Comments

@annwhoorma
Copy link

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?

@DarnellGranberry
Copy link
Collaborator

@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()

@annwhoorma
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants