Skip to content
Advertisement

Python: How do I read the data in this multipage TIFF file to produce the desired image?

I am working with TIFF files that represent the readings of detectors in electron microscopy, and I know how this particular image should look, but I’m unsure how to get that result from the raw data in question. The TIFF files in question have several pages corresponding to frames on which data was taken, but when I look at each individual frame, they seem more or less like white noise, so there must be some other way to massage the data to look how it’s meant to. I’ve tried reading each frame into a numpy array and taking the sum over all frames to produce a new image, and it seemed like this almost worked for some of the images in question, though not all. Preferably, I’d like to produce a numpy array representing the new image that looks as it is meant to.

The actual TIFF image itself is too large to attach here, so I’ll link to where it can be downloaded on the EMPIAR database. It is /data/ds1_tifs/20180309_Vn_ribosome_0001.tif on this page, the first image listed under ds1_tifs. You’ll want to unselect everything else and download this image alone, since the full dataset is obviously absurdly large. The result image should look like this.

My posts on cryo-em discussion boards haven’t gained much traction, so any help would be appreciated.

Advertisement

Answer

“produce a numpy array representing the new image that looks as it is meant to.”: The PNG image looks like a thumbnail image, a somewhat arbitrary preview of the data in the TIFF file obtained by binning and scaling:

import tifffile
im = tifffile.imread('20180309_Vn_ribosome_0001.tif', maxworkers=6)
binsize = 25
height = im.shape[1] // binsize
width = im.shape[2] // binsize
im = im[:, :height * binsize, : width * binsize]
im = im.reshape(im.shape[0], height, binsize, width, binsize)
im = im.sum((0, 2, 4), dtype='uint32')

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

enter image description here

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement