Xmipp  v3.23.11-Nereus
Functions | Variables
reconstruct_art_pseudo.cpp File Reference
#include <fstream>
#include "reconstruct_art_pseudo.h"
#include "core/histogram.h"
#include "core/geometry.h"
#include "core/xmipp_image.h"
#include "core/xmipp_funcs.h"
Include dependency graph for reconstruct_art_pseudo.cpp:

Go to the source code of this file.

Functions

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)
 

Variables

constexpr int FORWARD = 1
 
constexpr int BACKWARD = -1
 

Function Documentation

◆ project_Pseudo()

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 
)

Projection of a pseudoatom volume

Definition at line 38 of file reconstruct_art_pseudo.cpp.

46 {
47  // Project all pseudo atoms ............................................
48  int nmax=atomPosition.size();
49  Matrix1D<double> actprj(3);
50  double sigma4=4*sigma;
51  Matrix1D<double> actualAtomPosition;
52  int lambdaSize=lambda.size();
53  for (int n=0; n<nmax; n++)
54  {
55  actualAtomPosition=atomPosition[n];
56  double weight=atomWeight[n];
57  for (int mode=0; mode<lambdaSize; mode++)
58  {
59  const Matrix2D<double> &NMAmode=NMA[mode];
60  double lambdam=lambda[mode];
61  FOR_ALL_ELEMENTS_IN_MATRIX1D(actualAtomPosition)
62  VEC_ELEM(actualAtomPosition,i)+=
63  lambdam*MAT_ELEM(NMAmode,n,i);
64  }
65 
66  Uproject_to_plane(actualAtomPosition, Euler, actprj);
67  XX(actprj)+=shiftX;
68  YY(actprj)+=shiftY;
69 #ifdef DEBUG
70 
71  bool condition = true;
72  if (condition)
73  {
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;
77  }
78 #endif
79 
80  // Search for integer corners for this basis
81  int XX_corner1 = CEIL(XMIPP_MAX(STARTINGX(proj), XX(actprj) - sigma4));
82  int YY_corner1 = CEIL(XMIPP_MAX(STARTINGY(proj), YY(actprj) - sigma4));
83  int XX_corner2 = FLOOR(XMIPP_MIN(FINISHINGX(proj), XX(actprj) + sigma4));
84  int YY_corner2 = FLOOR(XMIPP_MIN(FINISHINGY(proj), YY(actprj) + sigma4));
85 
86 #ifdef DEBUG
87 
88  if (condition)
89  {
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;
94  }
95 #endif
96 
97  // Check if the basis falls outside the projection plane
98  if (XX_corner1 <= XX_corner2 && YY_corner1 <= YY_corner2)
99  {
100  double vol_corr=0;
101 
102  // Effectively project this basis
103  for (int y = YY_corner1; y <= YY_corner2; y++)
104  {
105  double y_diff2=y-YY(actprj);
106  y_diff2=y_diff2*y_diff2;
107  for (int x = XX_corner1; x <= XX_corner2; x++)
108  {
109  double x_diff2=x-XX(actprj);
110  x_diff2=x_diff2*x_diff2;
111  double r=sqrt(x_diff2+y_diff2);
112  double didx=r*1000;
113  int idx=ROUND(didx);
114  double a = VEC_ELEM(gaussianProjectionTable,idx);
115  double a2 = VEC_ELEM(gaussianProjectionTable2,idx);
116 #ifdef DEBUG
117 
118  if (condition)
119  std::cout << "=" << a << " , " << a2;
120 #endif
121 
122  if (direction==FORWARD)
123  {
124  A2D_ELEM(proj, y, x) += weight * a;
125  A2D_ELEM(norm_proj, y, x) += a2;
126 #ifdef DEBUG
127 
128  if (condition)
129  {
130  std::cout << " proj= " << A2D_ELEM(proj, y, x)
131  << " norm_proj=" << A2D_ELEM(norm_proj, y, x) << std::endl;
132  std::cout.flush();
133  }
134 #endif
135 
136  }
137  else
138  {
139  vol_corr += A2D_ELEM(norm_proj, y, x) * a;
140 #ifdef DEBUG
141 
142  if (condition)
143  {
144  std::cout << " corr_img= " << A2D_ELEM(norm_proj, y, x)
145  << " correction=" << vol_corr << std::endl;
146  std::cout.flush();
147  }
148 #endif
149 
150  }
151  }
152  }
153 
154  if (direction==BACKWARD)
155  {
156  atomWeight[n] += vol_corr;
157 #ifdef DEBUG
158 
159  if (condition)
160  {
161  std::cout << "\nFinal value at ( " << n << ") = "
162  << atomWeight[n] << std::endl;
163  }
164 #endif
165 
166  }
167  } // If not collapsed
168  }
169 }
int * nmax
#define A2D_ELEM(v, i, j)
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
constexpr int BACKWARD
#define FINISHINGX(v)
void sqrt(Image< double > &op)
static double * y
constexpr int FORWARD
#define STARTINGX(v)
doublereal * x
#define i
#define STARTINGY(v)
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
#define FLOOR(x)
Definition: xmipp_macros.h:240
double * lambda
#define XX(v)
Definition: matrix1d.h:85
#define CEIL(x)
Definition: xmipp_macros.h:225
#define ROUND(x)
Definition: xmipp_macros.h:210
void direction(const MultidimArray< double > &orMap, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &dirMap, int x, int y)
void mode
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define YY(v)
Definition: matrix1d.h:93
#define FINISHINGY(v)
void Uproject_to_plane(const Matrix1D< double > &point, const Matrix1D< double > &direction, double distance, Matrix1D< double > &result)
Definition: geometry.cpp:39
int * n
doublereal * a

Variable Documentation

◆ BACKWARD

constexpr int BACKWARD = -1

Definition at line 35 of file reconstruct_art_pseudo.cpp.

◆ FORWARD

constexpr int FORWARD = 1

Definition at line 34 of file reconstruct_art_pseudo.cpp.