54 program->
addParamsLine(
" [ --fourier <filter_type>] : Filter in Fourier space");
56 program->
addParamsLine(
" low_pass <w1> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
57 program->
addParamsLine(
" high_pass <w1> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
58 program->
addParamsLine(
" band_pass <w1> <w2> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
59 program->
addParamsLine(
" stop_band <w1> <w2> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
60 program->
addParamsLine(
" stop_lowbandx <w1> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
61 program->
addParamsLine(
" stop_lowbandy <w1> <raisedw=0.02> : Cutoff freq (<1/2 or A)");
62 program->
addParamsLine(
" wedge <th0> <thF> <rot=0> <tilt=0> <psi=0> : Missing wedge (along y) for data between th0-thF ");
63 program->
addParamsLine(
" : y is rotated by euler angles degrees");
64 program->
addParamsLine(
" cone <th0> : Missing cone for tilt angles up to th0 ");
65 program->
addParamsLine(
" : do not use mask type for wedge or cone filters");
66 program->
addParamsLine(
" real_gaussian <w1> : Gaussian in real space with sigma = w1");
67 program->
addParamsLine(
" gaussian <w1> : Gaussian in Fourier space with sigma = w1");
68 program->
addParamsLine(
" sparsify <p=0.975> : Delete p percent of the smallest Fourier coefficients");
69 program->
addParamsLine(
" ctf <ctfile> : Provide a .ctfparam file");
70 program->
addParamsLine(
" ctfpos <ctfile> : Provide a .ctfparam file");
71 program->
addParamsLine(
" : The CTF phase will be corrected before applying");
72 program->
addParamsLine(
" ctfinv <ctfile> <minCTF=0.05> : Apply the inverse of the CTF. Below the minCTF, the image is not corrected");
73 program->
addParamsLine(
" ctfposinv <ctfile> <minCTF=0.05> : Apply the inverse of the abs(CTF). Below the minCTF, the image is not corrected");
74 program->
addParamsLine(
" ctfdef <kV> <Cs> <Q0> <defocus> : Apply a CTF with this voltage (kV), spherical aberration (mm), Q0 (typically, 0.07), and defocus (A)");
75 program->
addParamsLine(
" ctfdefastig <kV> <Cs> <Q0> <defocusU> <defocusV> <defocusAngle> : Apply a CTF with this voltage (kV), spherical aberration (mm), Q0 (typically, 0.07), defocus (A), and defocusAngle (degrees)");
77 program->
addParamsLine(
" bfactor <B> : Exponential filter (positive values for decay) ");
79 program->
addParamsLine(
" fsc <metadata> : Filter with the FSC profile contained in the metadata");
81 program->
addParamsLine(
" binary_file <file> : Binary file with the filter");
82 program->
addParamsLine(
" :+The filter must be defined in the whole Fourier space (not only the nonredundant part).");
83 program->
addParamsLine(
" :+This filter is produced, for instance, by xmipp_ctf_group");
84 program->
addParamsLine(
" astigmatism <sigma=120> : Filter images according to the astigmatism of their CTF");
85 program->
addParamsLine(
" :+sigma is the standard deviation of a Gaussian in degrees for the CTF phase");
88 program->
addParamsLine(
" [--sampling <sampling_rate>] : If provided pass frequencies are taken in Ang and for the CTF case");
89 program->
addParamsLine(
" : and for the CTF case this is the sampling used to compute the CTF");
92 program->
addParamsLine(
" [--save <filename=\"\"> ] : Do not apply just save the mask");
107 filter_type = program->
getParam(
"--fourier");
110 if (filter_type ==
"low_pass")
117 else if (filter_type ==
"high_pass")
124 else if (filter_type ==
"band_pass")
132 else if (filter_type ==
"stop_band")
140 else if (filter_type ==
"stop_lowbandx")
147 else if (filter_type ==
"stop_lowbandy")
154 else if (filter_type ==
"wedge")
163 else if (filter_type ==
"cone")
168 else if (filter_type ==
"gaussian")
174 else if (filter_type ==
"sparsify")
180 else if (filter_type ==
"real_gaussian")
186 else if (filter_type ==
"ctf" || filter_type ==
"ctfpos" || filter_type ==
"ctfinv" || filter_type ==
"ctfposinv")
189 if (filter_type ==
"ctf")
192 fnCTF=program->
getParam(
"--fourier",
"ctf");
194 else if (filter_type ==
"ctfpos")
197 fnCTF=program->
getParam(
"--fourier",
"ctfpos");
199 else if (filter_type ==
"ctfinv")
202 fnCTF=program->
getParam(
"--fourier",
"ctfinv");
205 else if (filter_type ==
"ctfposinv")
208 fnCTF=program->
getParam(
"--fourier",
"ctfposinv");
215 std::cerr <<
"CTF was obtained at sampling rate: " <<
ctf.
Tm << std::endl;
216 std::cerr <<
"Image sampling rate is: " <<
sampling_rate << std::endl;
221 else if (filter_type ==
"ctfdef")
233 else if (filter_type ==
"ctfdefastig")
246 else if (filter_type ==
"bfactor")
251 else if (filter_type ==
"fsc")
256 else if (filter_type ==
"binary_file")
261 else if (filter_type ==
"astigmatism")
283 std::cout <<
"Filter Band: ";
287 std::cout <<
"Lowpass before " <<
w1 << std::endl;
290 std::cout <<
"Highpass after " <<
w1 << std::endl;
293 std::cout <<
"Bandpass between " <<
w1 <<
" and " <<
w2 << std::endl;
296 std::cout <<
"Stopband between " <<
w1 <<
" and " <<
w2 << std::endl;
299 std::cout <<
"Stop low band X up to " <<
w1 << std::endl;
302 std::cout <<
"Stop low band Y up to " <<
w1 << std::endl;
305 std::cout <<
"CTF\n";
308 std::cout <<
"CTFPOS\n";
311 std::cout <<
"CTFINV minCTF= " <<
minCTF <<
"\n";
314 std::cout <<
"CTFPOSINV minCTF= " << minCTF <<
"\n";
317 std::cout <<
"CTFDEF voltage= " <<
ctf.
kV <<
"\n";
318 std::cout <<
"CTFDEF Cs= " <<
ctf.
Cs <<
"\n";
319 std::cout <<
"CTFDEF Q0= " <<
ctf.
Q0 <<
"\n";
320 std::cout <<
"CTFDEF defocus= " <<
ctf.
DeltafU <<
"\n";
323 std::cout <<
"Bfactor "<<
w1 << std::endl
327 std::cout <<
"Missing wedge keep data between tilting angles of " <<
t1 <<
" and " <<
t2 <<
" deg\n";
330 std::cout <<
"Missing cone for RCT data with tilting angles up to " <<
t1 <<
" deg\n";
333 std::cout <<
"FSC file " <<
fnFSC << std::endl
337 std::cout <<
"Filter file " <<
fnFilter << std::endl;
340 std::cout <<
"Astigmatism sigma " <<
RAD2DEG(
w1) << std::endl;
344 std::cout <<
"Filter Shape: ";
348 std::cout <<
"Raised cosine with " <<
raised_w 349 <<
" raised frequencies\n";
352 std::cout <<
"Gaussian\n";
355 std::cout <<
"Sparsify\n";
358 std::cout <<
"Real Gaussian\n";
361 std::cout <<
"CTF\n" <<
ctf;
364 std::cout <<
"CTFPOS\n" <<
ctf;
367 std::cout <<
"CTFINV\n" <<
ctf;
370 std::cout <<
"CTFPOSINV\n" <<
ctf;
374 std::cout <<
"Save mask in file: " <<
maskFn 375 <<
" disable actual masking"<< std::endl;
381 static bool firstTime =
true;
417 double wx=fabs(
XX(w));
418 double wy=fabs(
YY(w));
435 return 1./
sqrt(2.*
PI*
w1)*exp(-0.5*absw*absw/(w1*w1));
438 return exp(-
PI*
PI*absw*absw*w1*w1);
441 return exp(-2.*
PI*
PI*absw*absw*w1*w1);
444 return (1./(4*
PI*w1*w1))*exp(-
PI*
PI*absw*absw*w1*w1);
473 if (absw>=
w1 && absw<=
w2)
477 else if (absw<w2+raised_w && absw>
w2)
488 if (absw>=
w1 && absw<=
w2)
492 else if (absw<w2+raised_w && absw>
w2)
562 return exp( - (
w1 / 4.) * R * R);
571 for (
size_t i=0;
i<imax; ++
i)
581 double y0=
FSC[idx-1];
583 return y0+(y1-
y0)*(R-x0)/(x1-
x0);
594 double diff=(phaseV-phaseU)*0.5;
595 return exp(-0.5*diff*diff/(
w1*
w1));
664 for (
size_t k=0;
k<
ZSIZE(Fourier);
k++)
667 for (
size_t i=0;
i<
YSIZE(Fourier);
i++)
670 for (
size_t j=0;
j<
XSIZE(Fourier);
j++)
694 for (
size_t k=0;
k<
ZSIZE(Fourier);
k++)
697 for (
size_t i=0;
i<
YSIZE(Fourier);
i++)
700 for (
size_t j=0;
j<
XSIZE(Fourier);
j++)
732 *ptrV++ *= *ptrMask++;
865 " [ --softnegative <mask_file> <fsc> <Ts=1> <K=2>] : Removes strong negative values inside the mask");
866 program->
addParamsLine(
" : Ts is the sampling rate in A/pix");
872 mask.read(program->
getParam(
"--softnegative",0));
888 auto R2max=(double)((
XSIZE(img)/2)*(
XSIZE(img)/2));
905 double stddev=
sqrt(sum2/N-avg*avg);
#define ASTIGMATISMPROFILE
void BinaryConeMask(MultidimArray< int > &mask, double theta, int mode, bool centerOrigin)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
void sort(MultidimArray< T > &result) const
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void readParams(XmippProgram *program)
void BinaryWedgeMask(MultidimArray< int > &mask, double theta0, double thetaF, const Matrix2D< double > &A, bool centerOrigin)
Just for debugging, situation that can't happens.
void sqrt(Image< double > &op)
void gaussianFilter(MultidimArray< double > &img, double w1)
static void defineParams(XmippProgram *program)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
std::vector< double > FSC
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void apply(MultidimArray< double > &img)
MultidimArray< double > vMag
MultidimArray< double > maskFourierd
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
void read(const FileName &fn, bool disable_if_not_K=true)
double DeltafU
Global gain. By default, 1.
void threshold(double *phi, unsigned long nvox, double limit)
#define A3D_ELEM(V, k, i, j)
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
const char * getParam(const char *param, int arg=0)
void apply(MultidimArray< double > &img)
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Incorrect argument received.
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
double Tm
Sampling rate (A/pixel)
#define DIRECT_MULTIDIM_ELEM(v, n)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
#define DIRECT_A3D_ELEM(v, k, i, j)
double maskValue(const Matrix1D< double > &w)
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
std::vector< double > freqContFSC
void bandpassFilter(MultidimArray< double > &img, double w1, double w2, double raised_w)
MultidimArray< double > vMagSorted
void realGaussianFilter(MultidimArray< double > &img, double sigma)
void produceSideInfo()
Produce Side information.
void readParams(XmippProgram *program)
void applyMaskFourierSpace(const MultidimArray< double > &v, MultidimArray< std::complex< double > > &V)
void resizeNoCopy(int Xdim)
bool checkParam(const char *param)
double Q0
Factor for the importance of the Amplitude contrast.
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
MultidimArray< int > maskFourier
double kV
Accelerating Voltage (in KiloVolts)
void initZeros(const MultidimArray< T1 > &op)
bool enable_CTFnoise
Enable CTFnoise part.
void FFT_magnitude(const MultidimArray< std::complex< double > > &v, MultidimArray< double > &mag)
void generateMask(MultidimArray< double > &v)
FourierTransformer transformer
double getPhaseAt() const
Get Phase of the CTF.
void addParamsLine(const String &line)
void applyMaskSpace(MultidimArray< double > &v)
static void defineParams(XmippProgram *program)