62 addUsageLine(
"+Symmetry axis (rot,tilt)= 10 20 --> 0.33682 0.059391 0.93969",
true);
63 addUsageLine(
"+The angles represent the rot and tilt angles of the symmetry axis ");
64 addUsageLine(
"+see [[http://xmipp.cnb.csic.es/twiki/bin/view/Xmipp/Conventions#Euler_Angles][the note on Euler angles]] ");
65 addUsageLine(
"+convention in Xmipp). The rest of the numbers is the axis itself in X, Y, Z ");
66 addUsageLine(
"+coordinates. In this way, the symmetry axis is a line that passes through the ");
67 addUsageLine(
"+center of the volume and whose direction is this vector.");
68 addUsageLine(
"+It is important that the volume is correctly centered.");
71 addParamsLine(
"[-o+ <file=\"\">] : Metadata with the orientation of the symmetry axis");
72 addParamsLine(
" : In helical mode, there is a file called output.xmp ");
73 addParamsLine(
" : with the correlation map (vertical axis is the rotation, ");
80 addParamsLine(
" helicalDihedral : Helical-Dihedral symmetry.");
81 addParamsLine(
"[--sym2 <Cn=C1>] : Additional Cn symmetry. Only for helical and helicalDihedral");
83 addParamsLine(
"[--rot <rot0=0> <rotF=355> <step=5>]: Limits for rotational angle search");
84 addParamsLine(
"[--tilt <tilt0=0> <tiltF=90> <step=5>]: Limits for tilt angle search");
85 addParamsLine(
"[--localRot <rot0> <tilt0>] : Perform a local search around this angle");
86 addParamsLine(
"[--useSplines+] : Use cubic B-Splines for the interpolations");
88 addParamsLine(
"[-z <z0=1> <zF=10> <zstep=0.5>] : Search space for the shift in Z (in Angstroms)");
90 addParamsLine(
"[--rotHelical <rot0=-357> <rotF=357> <step=3>]: Search space for rotation around Z");
91 addParamsLine(
"[--localHelical <z> <rot>] : Perform a local search around this angle and shift");
92 addParamsLine(
"[--heightFraction <f=1>] : Use this fraction of the volume");
94 addExampleLine(
"A typical application for a rotational symmetry axis is ",
false);
96 addExampleLine(
"xmipp_volume_find_symmetry -i volume.vol --sym rot 3");
97 addExampleLine(
"Presume the symmetry axis is in rot=20, tilt=10. To align vertically the axis use",
false);
98 addExampleLine(
"xmipp_transform_geometry -i volume.vol --rotate_volume euler 20 10 0");
100 addExampleLine(
"xmipp_volume_find_symmetry -i volume --sym helical -z 0 6 1 --mask circular -32 --thr 2 -o parameters.xmd");
112 else if (mode==
"helicalDihedral")
113 helicalDihedral=
true;
117 helicalDihedral=
false;
121 if (helical || helicalDihedral)
138 Cn=std::stoi(sym2.substr(1));
169 if (helical || helicalDihedral)
178 for (
size_t i=first;
i<=last;
i++)
181 if (helical || helicalDihedral)
186 if (helical || helicalDihedral)
192 if (helical || helicalDihedral)
209 volume().setXmippOrigin();
211 double best_corr, best_rot, best_tilt, best_z;
214 if (!helical && !helicalDihedral)
220 std::cerr <<
"Searching symmetry axis ...\n";
251 fitness,iter,steps,
true);
258 Euler.
getRow(2, sym_axis);
260 std::cout <<
"Symmetry axis (rot,tilt)= " << best_rot <<
" " 261 << best_tilt <<
" --> " << sym_axis << std::endl;
265 direction.push_back(
XX(sym_axis));
266 direction.push_back(
YY(sym_axis));
267 direction.push_back(
ZZ(sym_axis));
280 if (heightFraction<=1.0)
286 if (k<zFirst || k>zLast)
330 fitness,iter,steps,
true);
337 std::cout <<
"Symmetry parameters (z,rot)= " << best_z*Ts <<
" " << best_rot <<
" correlation=" << best_corr << std::endl;
364 if (!helical && !helicalDihedral)
374 Euler.
getRow(2, sym_axis);
384 xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP);
387 xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP);
388 volume_sym += volume_aux;
394 double rotHelical=p[1];
395 double zHelical=p[2];
396 if (zHelical<0 || zHelical>
ZSIZE(mVolume)*0.4)
398 if (zHelical<z0 || zHelical>zF || rotHelical<rot0 || rotHelical>rotF)
407 save.
write(
"PPPvol.vol");
409 save.
write(
"PPPvolsym.vol");
411 save.write(
"PPPmask.vol");
412 std::cout << p[1] <<
" " << p[2] <<
" " << p[3] <<
" -> " << corr << std::endl;
std::vector< double > zVector
void init_progress_bar(long total)
double getDoubleParam(const char *param, int arg=0)
void threadEvaluateSymmetry(int thrId)
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
MultidimArray< double > vbest_z
void resizeNoCopy(const MultidimArray< T1 > &v)
bool getTasks(size_t &first, size_t &last)
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)
MultidimArray< double > vbest_rot
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
FileName removeAllExtensions() const
std::vector< double > rotVector
MultidimArray< double > vbest_tilt
double evaluateSymmetryWrapper(double *p, void *prm)
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 addSeeAlsoLine(const char *seeAlso)
static void defineParams(XmippProgram *program, int allowed_data_types=ALL_KINDS, const char *prefix=nullptr, const char *comment=nullptr, bool moreOptions=false)
#define A3D_ELEM(V, k, i, j)
#define DIRECT_A1D_ELEM(v, i)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
std::vector< double > tiltVector
double evaluateSymmetry(double *p)
const char * getParam(const char *param, int arg=0)
void progress_bar(long rlen)
void symmetry_Helical(MultidimArray< double > &Vout, const MultidimArray< double > &Vin, double zHelical, double rotHelical, double rot0, MultidimArray< int > *mask, bool dihedral, double heightFraction, int Cn)
void write(const FileName &fn) const
#define DIRECT_MULTIDIM_ELEM(v, n)
void addExampleLine(const char *example, bool verbatim=true)
ThreadTaskDistributor * td
void readParams(XmippProgram *program)
MultidimArray< double > vbest_corr
void direction(const MultidimArray< double > &orMap, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &dirMap, int x, int y)
int verbose
Verbosity level.
void * workClass
The class in which threads will be working.
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void generate_mask(bool apply_geo=false)
#define MATRIX1D_ARRAY(v)
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
#define FIRST_XMIPP_INDEX(size)
void globalThreadEvaluateSymmetry(ThreadArgument &thArg)
int thread_id
The thread id.
Image< double > helicalCorrelation
bool checkParam(const char *param)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
#define LAST_XMIPP_INDEX(size)
const MultidimArray< int > & get_binary_mask() const
int getIntParam(const char *param, int arg=0)
void getRow(size_t i, Matrix1D< T > &v) const
double fitness(double *p)
void addParamsLine(const String &line)