FRCCmp returns a quality factor based on FRC between images.
Fourier ring correlation (FRC) is a measure of statistical dependency between two averages, computed by comparison of rings in Fourier space. 1 means prefect agreement. 0 means no correlation.
Definition at line 681 of file cmp.h.
To compare 'image' with another image passed in through its parameters.
An optional transformation may be used to transform the 2 images.
- Parameters
-
image | The first image to be compared. |
with | The second image to be comppared. |
- Returns
- The comparison result. Smaller better by default
Implements EMAN::Cmp.
Definition at line 1417 of file cmp.cpp.
1430 vector < float >fsc;
1431 bool use_cpu =
true;
1435 image=image->copy();
1438 int sz=image->get_xsize()*image->get_ysize()*image->get_zsize();
1439 float *d1=image->get_data();
1440 float *d2=with->get_data();
1442 for (
int i=0; i<sz; i++) {
1443 if (d1[i]==0.0 || d2[i]==0.0) { d1[i]=0.0; d2[i]=0.0; }
1448 image->do_fft_inplace();
1449 with->do_fft_inplace();
1450 image->set_attr(
"free_me",1);
1451 with->set_attr(
"free_me",1);
1455 if (!image->is_complex()) {
1456 image=image->do_fft();
1457 image->set_attr(
"free_me",1);
1459 if (!with->is_complex()) {
1460 with=with->do_fft();
1461 with->set_attr(
"free_me",1);
1464 fsc = image->calc_fourier_shell_correlation(with,1);
1467 int ny = image->get_ysize();
1506 if (!image->has_attr(
"ctf")) {
1508 ctf=with->get_attr(
"ctf");
1510 else ctf=image->get_attr(
"ctf");
1512 float ds=1.0f/(ctf->
apix*ny);
1514 for (
int i=0; i<snr.size(); i++) {
1515 if (snr[i]<=0) snr[i]=0.001;
1517 if(ctf) {
delete ctf; ctf=0;}
1527 if (pmin==0 && minres>0)
1528 pmin=((float)image->get_attr(
"apix_x")*image->get_ysize())/minres;
1530 if (pmax==0 && maxres>0)
1531 pmax=((float)image->get_attr(
"apix_x")*image->get_ysize())/maxres;
1534 double sum=0.0, norm=0.0;
1536 for (
int i=0; i<ny/2; i++) {
1538 if (sweight) weight*=fsc[(ny2)*2+i];
1539 if (ampweight) weight*=amp[i];
1540 if (snrweight) weight*=snr[i];
1546 if (pmin>0) weight*=(tanh(5.0*(i-pmin)/pmin)+1.0)/2.0;
1547 if (pmax>0) weight*=(1.0-tanh(i-pmax))/2.0;
1549 sum+=weight*fsc[ny2+i];
1556 if (nweight && with->get_attr_default(
"ptcl_repr",0) && sum>=0 && sum<1.0) {
1558 sum/=(float)with->get_attr_default(
"ptcl_repr",0);
1562 if (image->has_attr(
"free_me"))
delete image;
1563 if (with->has_attr(
"free_me"))
delete with;
void validate_input_args(const EMData *image, const EMData *with) const
Ctf is the base class for all CTF model.
virtual vector< float > compute_1d(int size, float ds, CtfType t, XYData *struct_factor=0)=0
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
static int goodf(const float *p_f)
Check whether a number is a good float.
#define InvalidCallException(desc)
References EMAN::Ctf::apix, EMAN::EMData::calc_radial_dist(), EMAN::Ctf::compute_1d(), EMAN::Ctf::CTF_SNR, ENTERFUNC, EXITFUNC, EMAN::Util::goodf(), InvalidCallException, EMAN::Cmp::params, EMAN::Dict::set_default(), and EMAN::Cmp::validate_input_args().
TypeDict EMAN::FRCCmp::get_param_types |
( |
| ) |
const |
|
inlinevirtual |
Get Cmp parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
- Returns
- A dictionary containing the parameter info.
Implements EMAN::Cmp.
Definition at line 701 of file cmp.h.
704 d.put(
"snrweight",
EMObject::INT,
"If set, the SNR of 'this' will be used to weight the result. If 'this' lacks CTF info, it will check 'with'. (default=0)");
705 d.put(
"ampweight",
EMObject::INT,
"If set, the amplitude of 'this' will be used to weight the result (default=0)");
706 d.put(
"sweight",
EMObject::INT,
"If set, weight the (1-D) average by the number of pixels in each ring (default=1)");
707 d.put(
"nweight",
EMObject::INT,
"Downweight similarity based on number of particles in reference (default=0)");
708 d.put(
"zeromask",
EMObject::INT,
"Treat regions in either image that are zero as a mask (default=0)");
709 d.put(
"minres",
EMObject::FLOAT,
"Lowest resolution to use in comparison (soft cutoff). Requires accurate A/pix in image. <0 disables. Default=500");
710 d.put(
"maxres",
EMObject::FLOAT,
"Highest resolution to use in comparison (soft cutoff). Requires accurate A/pix in image. <0 disables. Default=10");
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().