Fourier ring correlation (FCR) between two images

560 views
Skip to first unread message

Victor Movileanu

unread,
Apr 10, 2018, 5:27:39 AM4/10/18
to EMAN2
Hello,

I would like to calculate the FRC between two images with eman2, is this possible?

Until now I found two possibilities, but both do not work. I tried:
$ e2proc2d.py --process frc image1.mrc image2.mrc
NotExistingObjectException at /build/co/eman2.daily/libEM/emobject.h:841: error with 'frc': 'No such an instance existing' caught


$ e2fsc.py image1.mrc image2.mrc
RuntimeError: InvalidValueException at /build/co/eman2.daily/libEM/emdata_metadata.cpp:845: error with '0': 'z size <= 0' caught


Do I type in something wrong, or is it not possible with eman2? I often have problems to type in the
e2???.py --process
commands correctly, maybe that is the problem...
I have found some imageJ plugin, but before that, I would prefer to use eman.

Any help or advice is appreciated. Is there any other software out there to perform FRC computation?
Thank you in advance,

Greets,
Victor


Victor Movileanu

unread,
Apr 10, 2018, 9:05:19 AM4/10/18
to EMAN2
I have found some nice python scripts for doing this: https://github.com/s-sajid-ali/FRC
I will use those.
Still I am interested if EMAN also has a script for doing this.

PS @Steve: Can you please edit the title of the post to 'FRC' instead of 'FCR'? :) This is an embarrassing typo..

Steve Ludtke

unread,
Apr 10, 2018, 10:30:19 AM4/10/18
to em...@googlegroups.com
Hi,
I've never come up with many good use-cases for command-line access to FRC calculation?  3-D FSC makes sense, as you need to compare 3-D reconstructions with other 3-D reconstructions or models vs maps, but when would you use it in 2-D? Are you after the curve, or just an integrated FSC as a quality metric? 

The reason your command fails is that --process works with "processors" (e2help.py processors), which modify images, rather than comparing them. There is another class of operations, comparators, which is designed to compute similarity metrics between images as single values (e2help.py cmps). 

If you know just a little Python, this is a trivial task to do,

im1=EMData(filename1,N)
im2=EMData(filename2,N)
fsc=im1.calc_fourier_shell_correlation(im2) # works in 2-D and 3-D, returns a single array with s,FSC,nvoxels
third=len(fsc)/3
saxis=fsc[0:third] # spatial frequencies
fscval=fsc[third:third*2] # FSC/FRC values
nvox=fsc[third*2:third*3] # number of voxels used for each value
Util.save_data(saxis[1],saxis[1]-saxis[0],fsc[1:-1],output_filename) # skips the value at the origin

If you can describe your use-case, we can certainly add an option to e2proc2d.py to do this sort of thing.

--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D. <slu...@bcm.edu>                      Baylor College of Medicine 
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Academic Director, CryoEM Core                                        (cryoem.bcm.edu)
Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)
Co-Director National Center For Macromolecular Imaging                  (ncmi.bcm.edu)



--
--
----------------------------------------------------------------------------------------------
You received this message because you are subscribed to the Google
Groups "EMAN2" group.
To post to this group, send email to em...@googlegroups.com
To unsubscribe from this group, send email to eman2+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eman2

---
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Victor Movileanu

unread,
Apr 10, 2018, 1:44:20 PM4/10/18
to EMAN2
The reason why I try to do this is to calculate the spectral signal to noise ratio (SSNR = FSC/(1-FSC) ) between two images, e.g. image pairs from two exposures of the same imaging field, as described in Baxter et al. 2009 "Determination of Signal-to-Noise Ratios and Spectral SNRs in Cryo-EM Low-dose Imaging of Molecules. :)

And while we are on this subject, is there also a command to calculate the cross correlation coefficient between two images? With eventual pre alignment?

Steve Ludtke

unread,
Apr 11, 2018, 9:00:25 AM4/11/18
to em...@googlegroups.com
You'd likely want to align the images (integer shift only) first, then, if you're talking about whole micrographs, pull out tiles from the image pairs, compute the FSC between the tiles, and average. If you compute the FSC on the whole frame, you will have more samples in the FSC, but the FSC curve itself will be much noisier. By tiling, similar to how the power spectrum is computed for whole micrographs, you will get less noisy FSC curves. While it's unlikely to be an issue between a pair of micrographs, note that the FSC/(1-FSC) approximation dramatically magnifies the SNR uncertainty as you approach 1 (high SNR domain). In some situations this can have some unfortunate side-effects.


# UNTESTED CODE, may need debugging
from numpy import array
im1=EMData(filename1,N)
im2=EMData(filename2,N).align("translational",im1)

fsca=None
tilesize=512
n=0
for x in xrange(tilesize/2,im1["nx"]-tilesize,tilesize):
for y in yrange(tilesize/2,im1["ny"]-tilesize,tilesize):
cl1=im1.get_clip(Region(x,y,tilesize,tilesize))
cl2=im2.get_clip(Region(x,y,tilesize,tilesize))
fsc=array(cl1.calc_fourier_shell_correlation(cl2))
if fsca==None : fsca=fsc
else: fsca+=fsc
n+=1

fsca/=n
third=len(fscn)/3
saxis=fscn[0:third] # spatial frequencies
fscval=fscn[third:third*2] # FSC/FRC values
nvox=fscn[third*2:third*3] # number of voxels used for each value
Util.save_data(saxis[1],saxis[1]-saxis[0],fscn[1:-1],output_filename) # skips the value at the origin

--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D. <slu...@bcm.edu>                      Baylor College of Medicine 
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Academic Director, CryoEM Core                                        (cryoem.bcm.edu)
Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)
Co-Director National Center For Macromolecular Imaging                  (ncmi.bcm.edu)


On Apr 10, 2018, at 1:44 PM, 'Victor Movileanu' via EMAN2 <em...@googlegroups.com> wrote:

The reason why I try to do this is to calculate the spectral signal to noise ratio (SSNR = FSC/(1-FSC) ) between two images, e.g. image pairs from two exposures of the same imaging field, as described in Baxter et al. 2009 "Determination of Signal-to-Noise Ratios and Spectral SNRs in Cryo-EM Low-dose Imaging of Molecules. :)

And while we are on this subject, is there also a command to calculate the cross correlation coefficient between two images? With eventual pre alignment?

Reply all
Reply to author
Forward
0 new messages