82 <<
"Output directory: " <<
fnOutDir << std::endl
83 <<
"Reference volume: " <<
fnVolR << std::endl
84 <<
"Reference mask: " <<
fnMaskR << std::endl
85 <<
"Max. Shift: " <<
maxShift << std::endl
87 <<
"Max. Resolution: " <<
maxResol << std::endl
88 <<
"Sampling: " <<
Ts << std::endl
89 <<
"Max. Radius: " <<
Rmax << std::endl
90 <<
"Max. Radius Deform. " <<
RmaxDef << std::endl
91 <<
"Zernike Degree: " <<
L1 << std::endl
92 <<
"SH Degree: " <<
L2 << std::endl
94 <<
"Correct CTF: " <<
useCTF << std::endl
99 <<
"Regularization: " <<
lambda << std::endl
100 <<
"Blob radius: " <<
blob_r << std::endl
107 addUsageLine(
"Make a continuous angular assignment with deformations");
111 defaultComments[
"-o"].addComment(
"Metadata with the angular alignment and deformation parameters");
115 addParamsLine(
" [--odir <outputDir=\".\">] : Output directory");
116 addParamsLine(
" [--max_shift <s=-1>] : Maximum shift allowed in pixels");
117 addParamsLine(
" [--max_angular_change <a=5>] : Maximum angular change allowed (in degrees)");
118 addParamsLine(
" [--max_resolution <f=4>] : Maximum resolution (A)");
119 addParamsLine(
" [--sampling <Ts=1>] : Sampling rate (A/pixel)");
120 addParamsLine(
" [--Rmax <R=-1>] : Maximum radius (px). -1=Half of volume size");
121 addParamsLine(
" [--RDef <r=-1>] : Maximum radius of the deformation (px). -1=Half of volume size");
122 addParamsLine(
" [--l1 <l1=3>] : Degree Zernike Polynomials=1,2,3,...");
123 addParamsLine(
" [--l2 <l2=2>] : Harmonical depth of the deformation=1,2,3,...");
126 addParamsLine(
" [--optimizeAlignment] : Optimize alignment");
127 addParamsLine(
" [--optimizeDeformation] : Optimize deformation");
129 addParamsLine(
" [--phaseFlipped] : Input images have been phase flipped");
130 addParamsLine(
" [--regularization <l=0.01>] : Regularization weight");
131 addParamsLine(
" [--blobr <b=4>] : Blob radius for forward mapping splatting");
136 addExampleLine(
"xmipp_forward_zernike_subtomos -i anglesFromContinuousAssignment.xmd --ref reference.vol -o assigned_anglesAndDeformations.xmd --optimizeAlignment --optimizeDeformation --depth 1");
142 V().setXmippOrigin();
270 double deformation=0.0;
274 P().setXmippOrigin();
278 deformVol(
P(), mV, deformation, currentRot, currentTilt, currentPsi);
295 xmipp_transformation::IS_NOT_INV,xmipp_transformation::DONT_WRAP,0.);
334 std::cout <<
"A=" <<
A << std::endl;
337 save.
write(
"PPPtheo.xmp");
339 save.
write(
"PPPfilteredp.xmp");
341 save.
write(
"PPPfiltered.xmp");
343 std::cout <<
"Cost=" << cost <<
" deformation=" << deformation << std::endl;
344 std::cout <<
"Press any key" << std::endl;
345 char c; std::cin >>
c;
350 std::cout <<
"A=" <<
A << std::endl;
353 save.
write(
"PPPtheo.mrc");
355 save.
write(
"PPPfilteredp.mrc");
357 save.
write(
"PPPfiltered.mrc");
360 std::cout <<
"Press any key" << std::endl;
361 char c; std::cin >>
c;
368 std::cout << cost <<
" " << deformation <<
" " <<
lambda*deformation <<
" " <<
sumV <<
" " << retval << std::endl;
439 I().setXmippOrigin();
445 std::cout <<
"Processing Image (" <<
fnImage <<
")" << std::endl;
455 std::vector<double> vectortemp;
495 std::cout<<std::endl;
496 std::cout<<
"------------------------------ Basis Degrees: ("<<
L1<<
","<<h<<
") ----------------------------"<<std::endl;
511 int end = steps.
size() - 3;
512 for (
int i = init;
i < end;
i++)
518 int end = steps.
size();
519 for (
int i = init;
i < end;
i++)
545 std::cout<<std::endl;
546 for (
int j=1;
j<4;
j++)
551 std::cout <<
"X Coefficients=(";
554 std::cout <<
"Y Coefficients=(";
557 std::cout <<
"Z Coefficients=(";
566 std::cout <<
")" << std::endl;
568 std::cout <<
"Radius=" <<
RmaxDef << std::endl;
569 std::cout <<
" Dshift=(" <<
p(totalSize-5) <<
"," <<
p(totalSize-4) <<
") " 570 <<
"Drot=" <<
p(totalSize-3) <<
" Dtilt=" <<
p(totalSize-2)
571 <<
" Dpsi=" <<
p(totalSize-1) << std::endl;
573 std::cout<<std::endl;
578 std::cerr << XE.what() << std::endl;
579 std::cerr <<
"Warning: Cannot refine " << fnImg << std::endl;
613 std::vector<double> vectortemp;
615 for (
int j = 0;
j < end_clnm;
j++) {
616 vectortemp.push_back(
clnm(
j));
626 checkPoint.
addRow(rowAppend);
632 for (
int h=0; h<=l2; h++)
636 int numEven=(count>>1)+(count&1 && !(h&1));
638 vecSize += numSPH*numEven;
641 vecSize += numSPH*(l1-h+1-numEven);
652 int totalSize = (steps.
size()-9)/3;
655 for (
int idx = prevSize; idx < size; idx++)
658 VEC_ELEM(steps, idx + totalSize) = 1.;
659 VEC_ELEM(steps, idx + 2 * totalSize) = 1.;
664 for (
int idx = 0; idx < size; idx++)
667 VEC_ELEM(steps, idx + totalSize) = 1.;
668 VEC_ELEM(steps, idx + 2 * totalSize) = 1.;
681 for (
int h=0; h<=l2; h++) {
682 int totalSPH = 2*h+1;
684 for (
int l=h;
l<=l1;
l+=2) {
685 for (
int m=0;
m<totalSPH;
m++) {
705 template<ProgForwardZernikeSubtomos::Direction DIRECTION>
709 size_t idxZ0=2*idxY0;
722 for (
size_t idx=0; idx<idxY0; idx++) {
730 double rot,
double tilt,
double psi)
738 size_t idxZ0=2*idxY0;
741 double RmaxF2=RmaxF*RmaxF;
742 double iRmaxF=1.0/RmaxF;
779 for (
auto j=0;
j<sz;
j++)
782 if (idx >= idxY0 && idx < idxZ0)
784 else if (idx >= idxZ0)
870 const auto &mVpos =
vpos;
887 for (
auto j = 0;
j < sz;
j++)
900 if (rr > 0 || aux_l2 == 0)
902 gx += diff_c_x * (zsph);
903 gy += diff_c_y * (zsph);
904 gz += diff_c_z * (zsph);
913 auto pos = std::array<double, 3>{};
921 modg += gx * gx + gy * gy + gz * gz;
926 def =
sqrt(modg/Ncount);
1002 double x_pos = r[0];
1003 double y_pos = r[1];
1004 double z_pos = r[2];
1013 for (
int k = k0;
k <= kF;
k++)
1015 double z_val = 1. - m *
ABS(
k - z_pos);
1016 for (
int i = i0;
i <= iF;
i++)
1018 double y_val = 1. - m *
ABS(
i - y_pos);
1019 for (
int j = j0;
j <= jF;
j++)
1021 double x_val = 1. - m *
ABS(
j - x_pos);
1022 A3D_ELEM(mP,
k,
i,
j) += weight * x_val * y_val * z_val;
1075 size_t idxZ0=2*idxY0;
1077 const auto &mVpos =
vpos;
1094 for (
int idx = 0; idx < idxY0; idx++)
1105 if (rr > 0 || aux_l2 == 0)
ProgForwardZernikeSubtomos()
Empty constructor.
#define A2D_ELEM(v, i, j)
double alpha
Smoothness parameter.
std::vector< double > z_clnm_diff
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
double continuousZernikeSubtomoCost(double *x, void *_prm)
~ProgForwardZernikeSubtomos()
Destructor.
void defineParams()
Define parameters.
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void rotatePositions(double rot, double tilt, double psi)
MultidimArray< int > V_mask
void sqrt(Image< double > &op)
void updateCTFImage(double defocusU, double defocusV, double angle)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
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)
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
void inv(Matrix2D< T > &result) const
void abs(Image< double > &op)
Image< double > Vdeformed
void setFileName(const FileName &fn)
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
MultidimArray< double > df
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
double DeltafU
Global gain. By default, 1.
#define MAT_ELEM(m, i, j)
#define A3D_ELEM(V, k, i, j)
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
const FileName & getFileName() const
T & getValue(MDLabel label)
const char * getParam(const char *param, int arg=0)
MultidimArray< int > mask3D
double transformImageSph(double *pclnm)
std::vector< size_t > idx_z_clnm
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
Image< double > Ifilteredp
double Tm
Sampling rate (A/pixel)
MultidimArray< double > vpos
void addExampleLine(const char *example, bool verbatim=true)
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
void deformVol(MultidimArray< double > &mVD, const MultidimArray< double > &mV, double &def, double rot, double tilt, double psi)
Deform a volumen using Zernike-Spherical harmonic basis.
int verbose
Verbosity level.
virtual void checkPoint()
For very long programs, it may be needed to write checkpoints.
Matrix1D< double > prev_clnm
FileName fnOutDir
Output directory.
const T & getValueOrDefault(MDLabel label, const T &def) const
double K
Global gain. By default, 1.
virtual void finishProcessing()
virtual void writeImageParameters(MDRow &row)
void setValue(MDLabel label, const T &d, bool addLabel=true)
void generate_mask(bool apply_geo=false)
void minimizepos(int L1, int l2, Matrix1D< double > &steps)
Determine the positions to be minimize of a vector containing spherical harmonic coefficients.
virtual bool containsLabel(MDLabel label) const =0
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
#define BINARY_CIRCULAR_MASK
void produceSideInfo()
Produce Side information.
double psi(const double x)
int order
Derivation order and Bessel function order.
Image< double > Ifiltered
void splattingAtPos(std::array< double, 3 > r, double weight, MultidimArray< double > &mP, const MultidimArray< double > &mV)
bool checkParam(const char *param)
void fillVectorTerms(int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
Zernike and SPH coefficients allocation.
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void readParams()
Read argument from command line.
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
bool enable_CTFnoise
Enable CTFnoise part.
const MultidimArray< int > & get_binary_mask() const
void rotateCoefficients()
T * adaptForNumericalRecipes() const
int getIntParam(const char *param, int arg=0)
void generateMask(MultidimArray< double > &v)
double radius
Spatial radius in Universal System units.
Matrix1D< double > weightsInterpolation3D(double x, double y, double z)
void addParamsLine(const String &line)
void applyMaskSpace(MultidimArray< double > &v)
Matrix1D< double > steps_cp
std::map< String, CommentList > defaultComments