#include <processor.h>
Inheritance diagram for EMAN::CTFSNRWeightProcessor:


Public Member Functions | |
| virtual void | process_inplace (EMData *image) |
| To process an image in-place. | |
| virtual string | get_name () const |
| Get the processor's name. | |
| virtual string | get_desc () const |
| Get the descrition of this specific processor. | |
| virtual TypeDict | get_param_types () const |
| Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
| Processor * | NEW () |
Static Public Attributes | |
| const string | NAME = "ctf.snr.weight" |
Definition at line 5860 of file processor.h.
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 5870 of file processor.h. 05871 {
05872 return "Weight the amplitudes of an image based on radial noise and snr curves ";
05873 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5865 of file processor.h. 05866 {
05867 return NAME;
05868 }
|
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 5880 of file processor.h. References EMAN::TypeDict::put(). 05881 {
05882 TypeDict d;
05883 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05884 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
05885 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
05886 return d;
05887 }
|
|
|
Definition at line 5875 of file processor.h. 05876 {
05877 return new CTFSNRWeightProcessor();
05878 }
|
|
|
To process an image in-place. For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
Implements EMAN::Processor. Definition at line 6780 of file processor.cpp. References EMAN::EMData::ap2ri(), EMAN::EMData::calc_radial_dist(), EMAN::EMData::copy(), EMAN::EMData::depad(), EMAN::EMData::do_fft_inplace(), EMAN::EMData::do_ift_inplace(), EMAN::Dict::end(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), InvalidParameterException, EMAN::EMData::is_complex(), EMAN::length(), nx, EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::ri2inten(), EMAN::Dict::set_default(), sqrt(), x, and y. 06780 {
06781 if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument");
06782 if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument");
06783
06784 float boost = params.set_default("boost",1.0f);
06785
06786 if (!image->is_complex()) {
06787 image->do_fft_inplace();
06788 }
06789 EMData* cpy = image->copy();
06790 cpy->ri2inten();
06791 vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1);
06792 transform(sf.begin(),sf.end(),sf.begin(),sqrtf);
06793 delete cpy;
06794
06795 image->ri2ap();
06796
06797 vector<float> noise = params["noise"];
06798 vector<float> snr = params["snr"];
06799
06800 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06801 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06802
06803 for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){
06804 if ((*it) == 0) *it = 1;
06805 }
06806 for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){
06807 if ((*it) < 0) *it = 0;
06808 }
06809 // Subtract the mean from the data and store it in data_mm
06810 transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>());
06811 transform(snr.begin(),snr.end(),snr.begin(),sqrtf);
06812 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06813 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06814
06815 int i = static_cast<int>(snr.size());
06816
06817 float * d = image->get_data();
06818 int nx = image->get_xsize();
06819 // int ny = image->get_ysize();
06820 int nxy = image->get_ysize()*nx;
06821 int nzon2 = image->get_zsize()/2;
06822 int nyon2 = image->get_ysize()/2;
06823 float rx, ry, rz, amp;
06824 int length;
06825 int twox;
06826 image->process_inplace("xform.fourierorigin.tocenter");
06827 for (int z = 0; z< image->get_zsize(); ++z) {
06828 for (int y = 0; y < image->get_ysize(); ++y) {
06829 for (int x = 0; x < image->get_xsize()/2; ++x) {
06830 rx = (float)x;
06831 ry = (float)nyon2 - (float)y;
06832 rz = (float)nzon2 - (float)z;
06833 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06834
06835 twox = 2*x;
06836 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06837 if (length >= i || length >= (int)sf.size()) {
06838 d[idx1] = 0;
06839 continue;
06840 } else {
06841 amp = boost*snr[length];
06842 // if (amp > 0) amp =sqrtf(amp);
06843 // else amp = 0;
06844 }
06845
06846 if (sf[length] == 0) {
06847 d[idx1] = 0;
06848 continue;
06849 }
06850
06851 // size_t idx2 = idx1 + 1;
06852 // cout << d[idx1] << " " << sf[length] << endl;
06853 d[idx1] /= sf[length];
06854 if (d[idx1] < 0) {
06855 d[idx1] *= amp;
06856 }else {
06857 d[idx1] *= -amp;
06858 }
06859 // d[idx2] = phase;
06860
06861 }
06862 }
06863 }
06864
06865 image->ap2ri();
06866 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06867 image->do_ift_inplace();
06868 image->depad();
06869 }
|
|
|
Definition at line 193 of file processor.cpp. |
1.3.9.1