85 <<
"Reference volume: " <<
fnVol << std::endl
86 <<
"Max. Shift: " <<
maxShift << std::endl
87 <<
"Max. Scale: " <<
maxScale << std::endl
89 <<
"Max. Resolution: " <<
maxResol << std::endl
91 <<
"Max. Gray Scale: " <<
maxA << std::endl
92 <<
"Max. Gray Shift: " <<
maxB << std::endl
93 <<
"Sampling: " <<
Ts << std::endl
94 <<
"Max. Radius: " <<
Rmax << std::endl
95 <<
"Padding factor: " <<
pad << std::endl
101 <<
"Ignore CTF: " <<
ignoreCTF << std::endl
105 <<
"Force same defocus: " <<
sameDefocus << std::endl
106 <<
"Output residuals: " <<
fnResiduals << std::endl
118 defaultComments[
"-o"].addComment(
"Stack of images prepared for 3D reconstruction");
121 addParamsLine(
" [--max_shift <s=-1>] : Maximum shift allowed in pixels");
122 addParamsLine(
" [--max_scale <s=0.02>] : Maximum scale change");
123 addParamsLine(
" [--max_angular_change <a=5>] : Maximum angular change allowed (in degrees)");
124 addParamsLine(
" [--max_defocus_change <d=500>] : Maximum defocus change allowed (in Angstroms)");
125 addParamsLine(
" [--max_resolution <f=4>] : Maximum resolution (A)");
126 addParamsLine(
" [--max_gray_scale <a=0.05>] : Maximum gray scale change");
127 addParamsLine(
" [--max_gray_shift <b=0.05>] : Maximum gray shift change as a factor of the image standard deviation");
128 addParamsLine(
" [--sampling <Ts=1>] : Sampling rate (A/pixel)");
129 addParamsLine(
" [--Rmax <R=-1>] : Maximum radius (px). -1=Half of volume size");
137 addParamsLine(
" [--applyTo <label=image>] : Which is the source of images to apply the final transformation");
138 addParamsLine(
" [--phaseFlipped] : Input images have been phase flipped");
140 addParamsLine(
" [--sameDefocus] : Force defocusU = defocusV");
141 addParamsLine(
" [--oresiduals <stack=\"\">] : Output stack for the residuals");
142 addParamsLine(
" [--oprojections <stack=\"\">] : Output stack for the projections");
144 addExampleLine(
"xmipp_angular_continuous_assign2 -i anglesFromDiscreteAssignment.xmd --ref reference.vol -o assigned_angles.stk");
164 V().setXmippOrigin();
169 size_t ydim, zdim, ndim;
238 ctfEnvelope = std::make_unique<MultidimArray<double>>();
252 double a,
double b,
const Matrix2D<double> &
A,
double deltaDefocusU,
double deltaDefocusV,
double deltaDefocusAngle,
int degree)
322 std::cout <<
"A=" << A << std::endl;
325 save.
write(
"PPPtheo.xmp");
327 save.
write(
"PPPfilteredp.xmp");
329 save.
write(
"PPPfiltered.xmp");
331 save.
write(
"PPPe.xmp");
337 std::cout <<
"Cost=" << cost << std::endl;
338 std::cout <<
"Press any key" << std::endl;
339 char c; std::cin >>
c;
356 double scaleAngle=x[7];
357 double deltaRot=x[8];
358 double deltaTilt=x[9];
359 double deltaPsi=x[10];
360 double deltaDefocusU=x[11];
361 double deltaDefocusV=x[12];
362 double deltaDefocusAngle=x[13];
366 if (fabs(scalex)>
prm->maxScale || fabs(scaley)>
prm->maxScale)
368 if (fabs(deltaRot)>
prm->maxAngularChange || fabs(deltaTilt)>
prm->maxAngularChange || fabs(deltaPsi)>
prm->maxAngularChange)
370 if (fabs(a-
prm->old_grayA)>
prm->maxA)
372 if (fabs(b)>
prm->maxB*
prm->Istddev)
374 if (fabs(deltaDefocusU)>
prm->maxDefocusChange || fabs(deltaDefocusV)>
prm->maxDefocusChange)
385 double sin2_t=sin(scaleAngle)*sin(scaleAngle);
386 double sin_2t=sin(2*scaleAngle);
387 MAT_ELEM(
prm->A,0,0)=1+scalex+(scaley-scalex)*sin2_t;
390 MAT_ELEM(
prm->A,1,1)=1+scaley-(scaley-scalex)*sin2_t;
408 double corrMask = 0.0;
409 double corrWeight = 0.0;
410 double imedDist = 0.0;
413 std::cout <<
"Processing " << fnImg << std::endl;
415 I().setXmippOrigin();
427 double old_scaleX=0, old_scaleY=0, old_scaleAngle=0;
567 std::cout <<
"I'=" << p(0) <<
"*I" <<
"+" << p(1) <<
" Dshift=(" << p(2) <<
"," << p(3) <<
") " 568 <<
"scale=(" << 1+p(4) <<
"," << 1+p(5) <<
", angle=" << p(6) <<
") Drot=" << p(7) <<
" Dtilt=" << p(8)
569 <<
" Dpsi=" << p(9) <<
" DU=" << p(10) <<
" DV=" << p(11) <<
" Dalpha=" << p(12) << std::endl;
583 double scaleAngle=p(6);
584 double sin2_t=sin(scaleAngle)*sin(scaleAngle);
585 double sin_2t=sin(2*scaleAngle);
586 A(0,0)=1+scalex+(scaley-scalex)*sin2_t;
587 A(0,1)=0.5*(scaley-scalex)*sin_2t;
589 A(1,1)=1+scaley-(scaley-scalex)*sin2_t;
617 std::cerr << XE.what() << std::endl;
618 std::cerr <<
"Warning: Cannot refine " << fnImg << std::endl;
665 std::cout <<
"p=" << p << std::endl;
668 MDaux.
write(
"PPPmd.xmd");
671 save.
write(
"PPPprojection.xmp");
673 save.
write(
"PPPexperimental.xmp");
676 Ip.
write(
"PPPexperimentalp.xmp");
679 E.
write(
"PPPresidual.xmp");
680 std::cout <<
A << std::endl;
681 std::cout << fnImgOut <<
" rewritten\n";
682 std::cout <<
"Press any key" << std::endl;
683 char c; std::cin >>
c;
695 for (
size_t objId : ptrMdOut.
ids())
702 for (
size_t objId : ptrMdOut.
ids())
711 double maxCost=-1e38;
712 for (
size_t objId : ptrMdOut.
ids())
719 for (
size_t objId : ptrMdOut.
ids())
#define FOR_ALL_ELEMENTS_IN_MATRIX2D(m)
#define A2D_ELEM(v, i, j)
double getDoubleParam(const char *param, int arg=0)
static MDLabel str2Label(const String &labelName)
double tranformImage(ProgAngularContinuousAssign2 *prm, double rot, double tilt, double psi, double a, double b, const Matrix2D< double > &A, double deltaDefocusU, double deltaDefocusV, double deltaDefocusAngle, int degree)
void generateEnvelope(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
std::unique_ptr< MultidimArray< double > > ctfEnvelope
ProgAngularContinuousAssign2()
Empty constructor.
FileName replaceExtension(const String &newExt) const
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
void defineParams()
Define parameters.
void resizeNoCopy(const MultidimArray< T1 > &v)
double correlationMasked(const MultidimArray< double > &I1, const MultidimArray< double > &I2)
Image< double > Ifilteredp
MultidimArray< int > mask2D
~ProgAngularContinuousAssign2()
Destructor.
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
#define DIRECT_A2D_ELEM(v, i, j)
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)
constexpr int CONTCOST_L1
void compose(const String &str, const size_t no, const String &ext="")
FourierProjector * projector
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
double DeltafU
Global gain. By default, 1.
#define MAT_ELEM(m, i, j)
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
void readParams()
Read argument from command line.
T & getValue(MDLabel label)
double continuous2cost(double *x, void *_prm)
const char * getParam(const char *param, int arg=0)
Image< double > Ifiltered
FourierTransformer fftTransformer
double correlationWeighted(MultidimArray< double > &I1, MultidimArray< double > &I2)
size_t getPrefixNumber(size_t pos=0) const
double imedDistance(const MultidimArray< double > &I1, const MultidimArray< double > &I2)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
void addExampleLine(const char *example, bool verbatim=true)
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
double maxShift
Maximum shift.
String originalImageLabel
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
void createEmptyFile(const FileName &filename, int xdim, int ydim, int Zdim, size_t select_img, bool isStack, int mode, int _swapWrite, const MDRowVec *md)
int verbose
Verbosity level.
const T & getValueOrDefault(MDLabel label, const T &def) const
void generateCTF(const MultidimArray< T1 > &sample_image, MultidimArray< T2 > &CTF, double Ts=-1)
double K
Global gain. By default, 1.
void setValue(MDLabel label, const T &d, bool addLabel=true)
void generate_mask(bool apply_geo=false)
virtual bool containsLabel(MDLabel label) const =0
#define BINARY_CIRCULAR_MASK
void produceSideInfo()
Produce Side information.
double psi(const double x)
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)
const MultidimArray< int > & get_binary_mask() const
int getIntParam(const char *param, int arg=0)
MultidimArray< double > * ctfImage
MultidimArray< std::complex< double > > fftE
void addParamsLine(const String &line)
void updateCTFImage(double defocusU, double defocusV, double angle)
void applyMaskSpace(MultidimArray< double > &v)
void covarianceMatrix(const MultidimArray< double > &I, Matrix2D< double > &C)
constexpr int CONTCOST_CORR
std::map< String, CommentList > defaultComments