#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 5891 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 5901 of file processor.h. 05902 { 05903 return "Weight the amplitudes of an image based on radial noise and snr curves "; 05904 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5896 of file processor.h. 05897 {
05898 return NAME;
05899 }
|
|
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 5911 of file processor.h. References EMAN::TypeDict::put(). 05912 { 05913 TypeDict d; 05914 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute"); 05915 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute"); 05916 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost"); 05917 return d; 05918 }
|
|
Definition at line 5906 of file processor.h. 05907 { 05908 return new CTFSNRWeightProcessor(); 05909 }
|
|
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 6678 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. 06678 { 06679 if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument"); 06680 if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument"); 06681 06682 float boost = params.set_default("boost",1.0f); 06683 06684 if (!image->is_complex()) { 06685 image->do_fft_inplace(); 06686 } 06687 EMData* cpy = image->copy(); 06688 cpy->ri2inten(); 06689 vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1); 06690 transform(sf.begin(),sf.end(),sf.begin(),sqrtf); 06691 delete cpy; 06692 06693 image->ri2ap(); 06694 06695 vector<float> noise = params["noise"]; 06696 vector<float> snr = params["snr"]; 06697 06698 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n")); 06699 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n")); 06700 06701 for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){ 06702 if ((*it) == 0) *it = 1; 06703 } 06704 for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){ 06705 if ((*it) < 0) *it = 0; 06706 } 06707 // Subtract the mean from the data and store it in data_mm 06708 transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>()); 06709 transform(snr.begin(),snr.end(),snr.begin(),sqrtf); 06710 // copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n")); 06711 // copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n")); 06712 06713 int i = static_cast<int>(snr.size()); 06714 06715 float * d = image->get_data(); 06716 int nx = image->get_xsize(); 06717 // int ny = image->get_ysize(); 06718 int nxy = image->get_ysize()*nx; 06719 int nzon2 = image->get_zsize()/2; 06720 int nyon2 = image->get_ysize()/2; 06721 float rx, ry, rz, amp; 06722 int length; 06723 int twox; 06724 image->process_inplace("xform.fourierorigin.tocenter"); 06725 for (int z = 0; z< image->get_zsize(); ++z) { 06726 for (int y = 0; y < image->get_ysize(); ++y) { 06727 for (int x = 0; x < image->get_xsize()/2; ++x) { 06728 rx = (float)x; 06729 ry = (float)nyon2 - (float)y; 06730 rz = (float)nzon2 - (float)z; 06731 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz)); 06732 06733 twox = 2*x; 06734 size_t idx1 = twox + y*nx+z*nxy; 06735 if (length >= i || length >= (int)sf.size()) { 06736 d[idx1] = 0; 06737 continue; 06738 } else { 06739 amp = boost*snr[length]; 06740 // if (amp > 0) amp =sqrtf(amp); 06741 // else amp = 0; 06742 } 06743 06744 if (sf[length] == 0) { 06745 d[idx1] = 0; 06746 continue; 06747 } 06748 06749 // size_t idx2 = idx1 + 1; 06750 // cout << d[idx1] << " " << sf[length] << endl; 06751 d[idx1] /= sf[length]; 06752 if (d[idx1] < 0) { 06753 d[idx1] *= amp; 06754 }else { 06755 d[idx1] *= -amp; 06756 } 06757 // d[idx2] = phase; 06758 06759 } 06760 } 06761 } 06762 06763 image->ap2ri(); 06764 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner"); 06765 image->do_ift_inplace(); 06766 image->depad(); 06767 }
|
|
Definition at line 193 of file processor.cpp. |