#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 5719 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 5729 of file processor.h. 05730 { 05731 return "Weight the amplitudes of an image based on radial noise and snr curves "; 05732 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5724 of file processor.h. 05725 {
05726 return NAME;
05727 }
|
|
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 5739 of file processor.h. References EMAN::TypeDict::put(). 05740 { 05741 TypeDict d; 05742 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute"); 05743 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute"); 05744 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost"); 05745 return d; 05746 }
|
|
Definition at line 5734 of file processor.h. 05735 { 05736 return new CTFSNRWeightProcessor(); 05737 }
|
|
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 6714 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. 06714 { 06715 if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument"); 06716 if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument"); 06717 06718 float boost = params.set_default("boost",1.0f); 06719 06720 if (!image->is_complex()) { 06721 image->do_fft_inplace(); 06722 } 06723 EMData* cpy = image->copy(); 06724 cpy->ri2inten(); 06725 vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1); 06726 transform(sf.begin(),sf.end(),sf.begin(),sqrtf); 06727 delete cpy; 06728 06729 image->ri2ap(); 06730 06731 vector<float> noise = params["noise"]; 06732 vector<float> snr = params["snr"]; 06733 06734 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n")); 06735 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n")); 06736 06737 for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){ 06738 if ((*it) == 0) *it = 1; 06739 } 06740 for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){ 06741 if ((*it) < 0) *it = 0; 06742 } 06743 // Subtract the mean from the data and store it in data_mm 06744 transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>()); 06745 transform(snr.begin(),snr.end(),snr.begin(),sqrtf); 06746 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n")); 06747 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n")); 06748 06749 int i = static_cast<int>(snr.size()); 06750 06751 float * d = image->get_data(); 06752 int nx = image->get_xsize(); 06753 // int ny = image->get_ysize(); 06754 int nxy = image->get_ysize()*nx; 06755 int nzon2 = image->get_zsize()/2; 06756 int nyon2 = image->get_ysize()/2; 06757 float rx, ry, rz, amp; 06758 int length; 06759 int twox; 06760 image->process_inplace("xform.fourierorigin.tocenter"); 06761 for (int z = 0; z< image->get_zsize(); ++z) { 06762 for (int y = 0; y < image->get_ysize(); ++y) { 06763 for (int x = 0; x < image->get_xsize()/2; ++x) { 06764 rx = (float)x; 06765 ry = (float)nyon2 - (float)y; 06766 rz = (float)nzon2 - (float)z; 06767 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz)); 06768 06769 twox = 2*x; 06770 size_t idx1 = twox + y*nx+z*nxy; 06771 if (length >= i || length >= (int)sf.size()) { 06772 d[idx1] = 0; 06773 continue; 06774 } else { 06775 amp = boost*snr[length]; 06776 // if (amp > 0) amp =sqrtf(amp); 06777 // else amp = 0; 06778 } 06779 06780 if (sf[length] == 0) { 06781 d[idx1] = 0; 06782 continue; 06783 } 06784 06785 // size_t idx2 = idx1 + 1; 06786 // cout << d[idx1] << " " << sf[length] << endl; 06787 d[idx1] /= sf[length]; 06788 if (d[idx1] < 0) { 06789 d[idx1] *= amp; 06790 }else { 06791 d[idx1] *= -amp; 06792 } 06793 // d[idx2] = phase; 06794 06795 } 06796 } 06797 } 06798 06799 image->ap2ri(); 06800 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 06801 image->do_ift_inplace(); 06802 image->depad(); 06803 }
|
|
Definition at line 188 of file processor.cpp. |