39 std::vector<double> &atomWeight,
double sigma,
42 const std::vector<double> &
lambda,
48 int nmax=atomPosition.size();
50 double sigma4=4*sigma;
52 int lambdaSize=lambda.
size();
55 actualAtomPosition=atomPosition[
n];
56 double weight=atomWeight[
n];
60 double lambdam=lambda[
mode];
71 bool condition =
true;
74 std::cout <<
"Projecting point " << atomPositions[
n].transpose() << std::endl;
75 std::cout <<
"Vol there = " << atomWeight[
n] << std::endl;
76 std::cout <<
" Center of the basis proj (2D) " <<
XX(actprj) <<
"," <<
YY(actprj) << std::endl;
90 std::cout <<
"Clipped and rounded Corner 1 " << XX_corner1
91 <<
" " << YY_corner1 <<
" " << std::endl;
92 std::cout <<
"Clipped and rounded Corner 2 " << XX_corner2
93 <<
" " << YY_corner2 <<
" " << std::endl;
98 if (XX_corner1 <= XX_corner2 && YY_corner1 <= YY_corner2)
103 for (
int y = YY_corner1;
y <= YY_corner2;
y++)
105 double y_diff2=
y-
YY(actprj);
106 y_diff2=y_diff2*y_diff2;
107 for (
int x = XX_corner1;
x <= XX_corner2;
x++)
109 double x_diff2=
x-
XX(actprj);
110 x_diff2=x_diff2*x_diff2;
111 double r=
sqrt(x_diff2+y_diff2);
114 double a =
VEC_ELEM(gaussianProjectionTable,idx);
115 double a2 =
VEC_ELEM(gaussianProjectionTable2,idx);
119 std::cout <<
"=" << a <<
" , " << a2;
130 std::cout <<
" proj= " <<
A2D_ELEM(proj,
y,
x)
131 <<
" norm_proj=" <<
A2D_ELEM(norm_proj,
y,
x) << std::endl;
144 std::cout <<
" corr_img= " <<
A2D_ELEM(norm_proj,
y,
x)
145 <<
" correction=" << vol_corr << std::endl;
156 atomWeight[
n] += vol_corr;
161 std::cout <<
"\nFinal value at ( " <<
n <<
") = " 162 << atomWeight[
n] << std::endl;
175 std::cout <<
" =======================================================" << std::endl;
176 std::cout <<
" ART reconstruction method using pseudo atomic structure" << std::endl;
177 std::cout <<
" =======================================================" << std::endl;
178 std::cout <<
"Input images: " <<
fnDoc << std::endl;
179 std::cout <<
"Pseudoatoms: " <<
fnPseudo << std::endl;
180 std::cout <<
"Sigma: " <<
sigma << std::endl;
181 std::cout <<
"Sampling rate: " <<
sampling << std::endl;
183 std::cout <<
"NMA: " <<
fnNMA << std::endl;
184 std::cout <<
"Output rootname: " <<
fnRoot << std::endl;
185 std::cout <<
"Lambda ART: " <<
lambdaART << std::endl;
186 std::cout <<
"N. Iterations: " <<
Nit << std::endl;
187 std::cout <<
"\n -----------------------------------------------------" << std::endl;
193 addUsageLine(
"Generate 3D reconstructions from projections using ART on pseudoatoms.");
194 addUsageLine(
"+This program reconstructs based on irregular grids given by pseudo atomic structures. ");
195 addUsageLine(
"+In case of regular grids, please refer to other programs as reconstruct_art ");
196 addUsageLine(
"+or reconstruct_fourier. Optionally, a deformation file generated by Nodal Mode ");
197 addUsageLine(
"+Alignment (NMA) can be passed with --nma parameter.");
201 addParamsLine(
" -i <md_file> : Metadata file with input projections");
204 addParamsLine(
" --pseudo <pseudofile> : Pseudo atomic structure (PDB format)");
206 addParamsLine(
" [--sigma <s=-1>] : Pseudoatom sigma. By default, from pseudo file");
207 addParamsLine(
" [--sampling_rate <Ts=1>] : Pixel size (Angstrom)");
213 addExampleLine(
"Reconstruct with NMA file and relaxation factor of 0.2:",
false);
214 addExampleLine(
"xmipp_reconstruct_art_pseudo -i projections.xmd -o art_rec --nma nmafile.xmd -l 0.2");
232 std::ifstream fhPseudo;
236 while (!fhPseudo.eof())
239 getline(fhPseudo, line);
240 if (line.length() == 0)
242 if (line.substr(7,13)==
"fixedGaussian" &&
sigma<0)
244 std::vector < std::string> results;
249 else if (line.substr(0,4)==
"ATOM")
262 double sigma4=4*
sigma;
275 for (
size_t objId : DFNMA.
ids())
292 for (
int it=0; it<
Nit; it++)
295 for (
size_t objId :
DF.
ids())
309 std::vector<double>
lambda;
314 Iexp().setXmippOrigin();
319 std::cerr <<
"Error at iteration " << it <<
" = " << itError << std::endl;
334 V().setXmippOrigin();
337 double sigma4=4*
sigma;
346 if (XX_corner1 <= XX_corner2 && YY_corner1 <= YY_corner2 &&
347 ZZ_corner1 <= ZZ_corner2)
349 for (
int z = ZZ_corner1;
z <= ZZ_corner2;
z++)
350 for (
int y = YY_corner1;
y <= YY_corner2;
y++)
351 for (
int x = XX_corner1;
x <= XX_corner2;
x++)
368 double rot,
double tilt,
double psi,
double shiftX,
double shiftY,
369 const std::vector<double> &
lambda)
393 mean_error /=
YXSIZE(Iexp);
#define A2D_ELEM(v, i, j)
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void sqrt(Image< double > &op)
#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)
Matrix1D< double > gaussianProjectionTable
int Nit
Number of iterations.
void project_Pseudo(const std::vector< Matrix1D< double > > &atomPosition, std::vector< double > &atomWeight, double sigma, MultidimArray< double > &proj, MultidimArray< double > &norm_proj, Matrix2D< double > &Euler, double shiftX, double shiftY, const std::vector< double > &lambda, const std::vector< Matrix2D< double > > &NMA, int direction, const Matrix1D< double > &gaussianProjectionTable, const Matrix1D< double > &gaussianProjectionTable2)
double sigma
Sigma of atoms.
void addSeeAlsoLine(const char *seeAlso)
#define MAT_ELEM(m, i, j)
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
const char * getParam(const char *param, int arg=0)
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
float textToFloat(const char *str)
std::vector< double > atomWeight
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
double sampling
Sampling rate.
void resize(size_t Xdim, bool copy=true)
void addExampleLine(const char *example, bool verbatim=true)
File or directory does not exist.
std::vector< Matrix2D< double > > NMA
void direction(const MultidimArray< double > &orMap, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &dirMap, int x, int y)
int verbose
Verbosity level.
Matrix1D< double > gaussianProjectionTable2
FileName fnRoot
Output filename.
FileName fnDoc
Selfile with the input images.
void read(const FileName &fn)
double psi(const double x)
void write(const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT)
FileName fnPseudo
Pseudoatom filename.
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)
int getIntParam(const char *param, int arg=0)
void Uproject_to_plane(const Matrix1D< double > &point, const Matrix1D< double > &direction, double distance, Matrix1D< double > &result)
FileName fnNMA
Selfile with the input NMAs.
std::vector< Matrix1D< double > > atomPosition
void addParamsLine(const String &line)
double ART_single_step(const MultidimArray< double > &Iexp, double rot, double tilt, double psi, double shiftX, double shiftY, const std::vector< double > &lambda)
double gaussian1D(double x, double sigma, double mu)