58 <<
" =================================================================" 60 std::cerr <<
" Weighted-back projection (arbitrary geometry) " 63 <<
" =================================================================" 65 std::cerr <<
" Input selfile : " <<
fn_sel << std::endl;
66 std::cerr <<
" Output volume : " <<
fn_out << std::endl;
68 std::cerr <<
" Reconstruction radius : " <<
diameter / 2
70 std::cerr <<
" Relative filter threshold : " <<
threshold << std::endl;
72 std::cerr <<
" Symmetry file: : " <<
fn_sym << std::endl;
75 <<
" --> Use all projection directions in arbitrary geometry filter" 78 std::cerr <<
" --> Use sampled directions for filter, sampling = " 81 std::cerr <<
" --> Use weights stored in the image headers" 84 <<
" -----------------------------------------------------------------" 94 "Generate 3D reconstruction from projections using the Weighted BackProjection algorithm.");
96 "+This program allows you to generate 3D reconstructions from projections ");
98 "+using the Weighted BackProjection algorithm with arbitrary geometry as ");
100 "+described by Radermacher, M. (1992) Weighted back-projection methods. ");
101 addUsageLine(
"+Electron Tomography, ed. by J. Frank, Plenum Press.");
103 "angular_projection_matching, angular_discrete_assign, angular_continuous_assign");
105 " -i <input_selfile> : selection file with input images and Euler angles");
107 " [ -o <name=\"wbp.vol\"> ] : filename for output volume ");
109 " [ --doc <docfile=\"\"> ] : Ignore headers and get angles from this docfile ");
111 " [ --radius <int=-1> ] : Reconstruction radius. int=-1 means radius=dim/2 ");
113 " : The volume will be zero outside this radius");
116 " :+A symmetry file or point-group description.");
118 " :+Valid point-group descriptions are: C1, Ci, Cs, Cn ");
120 " :+(from here on n must be an integer number with no ");
122 " :+more than 2 digits) Cnv, Cnh, Sn, Dn, Dnv, Dnh, T, ");
124 " :+Td, Th, O, Oh I, I1, I2, I3, I4, I5, Ih. For a full ");
126 " :+description of symmetries look at http://xmipp.cnb.csic.es/twiki/bin/view/Xmipp/Symmetry");
128 " [ --threshold+ <float=0.005> ] : Lower (relative) threshold for filter values ");
130 " :+This is to avoid divisions by zero and consequent ");
132 " :+enhancement of noise. The threshold is given as a relative ");
134 " :+value with respect to the total number of images. The absolute");
136 " :+threshold will be calculated internally as the relative threshold");
138 " :+multiplied by the total number of (symmetry generated) projections.");
140 " [ --filsam+ <float=5>] : Angular sampling rate for geometry filter ");
142 " :+Instead of summing over all experimental images to calculate ");
144 " :+the arbitrary geometry filter, we bin all images in representative ");
146 " :+projection directions, which are sampled every filsam degrees.");
148 " [ --use_each_image+] : Use each image instead of sampled representatives for filter ");
150 " :+If this option is given, all experimental images will be used ");
152 " :+in the summation to calculate the arbitrary geometry filter. For ");
154 " :+large datasets this may be considerably slower than the default ");
156 " :+option of using representative projection directions");
158 " [ --weight] : Use weights stored in image headers or the input metadata");
159 addExampleLine(
"xmipp_reconstruct_wbp -i images.sel -o reconstruction.vol");
175 std::cerr <<
"Fourier pixels for which the threshold was not reached: " 196 "there is no input file with weight!=0");
218 double &
psi,
double &xoff,
double &yoff,
bool &flip,
double &weight)
236 double newrot, newtilt, newpsi, rot, tilt, dum, weight, totimgs = 0.;
240 std::vector<double> count_imgs;
243 std::cerr <<
"--> Sampling the filter ..." << std::endl;
246 std::vector<double> rotList, tiltList;
248 size_t NN = rotList.size();
249 count_imgs.resize(NN);
252 for (
size_t objId : SF.
ids())
259 count_imgs[idx] += weight;
261 count_imgs[idx] += 1.;
267 int SL_SymsNo_1 = SL_SymsNo + 1;
268 for (
size_t i = 0;
i < NN;
i++)
269 if (count_imgs[
i] > 0.)
274 for (
size_t i = 0;
i < NN;
i++)
276 auto count_i = (int)count_imgs[
i];
288 for (
int j = 0;
j < SL_SymsNo;
j++)
312 double rot, tilt,
psi, weight, dum, newrot, newtilt, newpsi, totimgs = 0.;
323 for (
size_t objId : SF.
ids())
368 double dim2,
x,
y,
z, xp, yp;
369 double value1, value2, scalex, scaley, value;
370 double radius2, x2, y2, z2, z2_plus_y2;
376 radius2 = diameter / 2.;
377 radius2 = radius2 * radius2;
386 double dim1 =
dim - 1;
390 for (i = 0; i < idim; i++)
396 double xpz = z * a20 + dim2;
397 double ypz = z * a21 + dim2;
398 for (j = 0; j < idim; j++)
402 z2_plus_y2 = z2 + y2;
403 if (z2_plus_y2 > radius2)
406 xp = x * a00 + y * a10 + xpz;
407 yp = x * a01 + y * a11 + ypz;
408 if (yp >= dim1 || yp < 0.0)
412 double scale1y = 1. - scaley;
413 for (k = 0; k < idim; k++, xp += a00, yp += a01, x++)
416 if (x2 + z2_plus_y2 > radius2)
418 if (xp >= dim1 || xp < 0.0)
424 double scale1x = 1. - scalex;
425 value1 = scalex *
dAij(mImg, l, m + 1)
426 + scale1x *
dAij(mImg, l, m);
427 value2 = scalex *
dAij(mImg, l + 1, m + 1)
428 + scale1x *
dAij(mImg, l + 1, m);
429 value = scaley * value2 + scale1y * value1;
430 dAkij(vol, i, j, k) += value;
441 double factor, argum, weight,
x,
y;
485 A2D_ELEM(IMG, i, j) /= (weight * factor);
519 double rot, tilt,
psi, xoff, yoff, weight;
533 std::cerr <<
"--> Back-projecting ..." << std::endl;
544 proj.
read(fn_img,
false);
557 proj().setXmippOrigin();
570 Vaux.
resize(mReconstructedVolume);
572 mReconstructedVolume = Vaux;
578 mask_prm.
apply_mask(mReconstructedVolume, mReconstructedVolume, 0.);
void filterOneImage(Projection &proj, Tabsinc &TSINC)
Image< double > reconstructedVolume
Reconstructed volume.
void init_progress_bar(long total)
virtual void produceSideInfo()
Fill arrays with relevant transformation matrices.
void setRot(double rot, const size_t n=0)
#define A2D_ELEM(v, i, j)
virtual void showProgress()
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
double getDoubleParam(const char *param, int arg=0)
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
#define REPORT_ERROR(nerr, ErrormMsg)
double psi(const size_t n=0) const
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void make_even_distribution(std::vector< double > &rotList, std::vector< double > &tiltList, double sampling, SymList &SL, bool include_mirror)
Make even distribution, taking symmetry into account.
void symmetrizeVolume(const SymList &SL, const MultidimArray< double > &V_in, MultidimArray< double > &V_out, int spline, bool wrap, bool do_outside_avg, bool sum, bool helical, bool dihedral, bool helicalDihedral, double rotHelical, double rotPhaseHelical, double zHelical, double heightFraction, const MultidimArray< double > *mask, int Cn)
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
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)
void simpleBackprojection(Projection &img, MultidimArray< double > &vol, int diameter)
void inv(Matrix2D< T > &result) const
void getSampledMatrices(MetaData &SF)
size_t time_bar_step
Time bar variables.
void InverseFourierTransform(const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out)
double rot(const size_t n=0) const
void setPsi(double psi, const size_t n=0)
double weight(const size_t n=0) const
void getAnglesForImage(size_t id, double &rot, double &tilt, double &psi, double &xoff, double &yoff, bool &flip, double &weight)
Get angles (either from reading the header or from a docfile)
void Euler_apply_transf(const Matrix2D< double > &L, const Matrix2D< double > &R, double rot, double tilt, double psi, double &newrot, double &newtilt, double &newpsi)
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
Incorrect number of objects in Metadata.
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void addSeeAlsoLine(const char *seeAlso)
double tilt(const size_t n=0) const
void readParams()
Read arguments from command line.
#define MAT_ELEM(m, i, j)
void CenterFFT(MultidimArray< T > &v, bool forward)
void defineParams()
Define parameters.
void setShifts(double xoff, double yoff, double zoff=0., const size_t n=0)
void apply_mask(const MultidimArray< T > &I, MultidimArray< T > &result, T subs_val=0, bool apply_geo=false)
std::unique_ptr< MetaDataVec::id_iterator > iter
Iterator over input metadata.
void apply2DFilterArbitraryGeometry()
const char * getParam(const char *param, int arg=0)
int find_nearest_direction(double rot1, double tilt1, std::vector< double > &rotList, std::vector< double > &tiltList, SymList &SL, Matrix2D< double > &Laux, Matrix2D< double > &Raux)
Determine which of the entries in DFlib is closest to [rot1,tilt1].
void getAllMatrices(MetaData &SF)
Fill array with transformation matrices needed for arbitrary geometry filter.
void setFlip(bool flip, const size_t n=0)
virtual bool getImageToProcess(size_t &objId)
Get 1 image to process.
void setIO(const FileName &fn_in, const FileName &fn_out)
void progress_bar(long rlen)
#define TSINCVALUE(Tsinc, x, y)
#define dAkij(V, k, i, j)
void addExampleLine(const char *example, bool verbatim=true)
int verbose
Verbosity level.
void FourierTransform(const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out)
void generate_mask(bool apply_geo=false)
void setTilt(double tilt, const size_t n=0)
#define BINARY_CIRCULAR_MASK
double psi(const double x)
bool checkParam(const char *param)
void read(const FileName &fn, const bool only_apply_shifts=false, DataMode datamode=DATA, MDRow *row=nullptr)
void getTransformationMatrix(Matrix2D< double > &A, bool only_apply_shifts=false, const size_t n=0)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
void setWeight(double weight, const size_t n=0)
int getIntParam(const char *param, int arg=0)
virtual void finishProcessing()
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
void addParamsLine(const String &line)