Xmipp  v3.23.11-Nereus
movie_alignment_correlation_base.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar Sanchez Sorzano coss@cnb.csic.es
4  * David Strelak (davidstrelak@gmail.com)
5  *
6  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307 USA
22  *
23  * All comments concerning this program package may be sent to the
24  * e-mail address 'xmipp@cnb.csic.es'
25  ***************************************************************************/
26 
27 #include <algorithm>
28 #include <limits>
31 
32 template<typename T>
34  fnMovie = getParam("-i");
35  fnOut = getParam("-o");
36  fnInitialAvg = getParam("--oavgInitial");
37  fnDark = getParam("--dark");
38  fnGain = getParam("--gain");
39  binning = getFloatParam("--bin");
40  if (binning < 1.0)
41  REPORT_ERROR(ERR_ARG_INCORRECT, "Binning must be >= 1");
42  Ts = getFloatParam("--sampling") * binning;
43  maxShift = getFloatParam("--maxShift") / Ts;
44  maxResForCorrelation = getFloatParam("--maxResForCorrelation");
45  fnAligned = getParam("--oaligned");
46  fnAvg = getParam("--oavg");
47  nfirst = getIntParam("--frameRange", 0);
48  nlast = getIntParam("--frameRange", 1);
49  nfirstSum = getIntParam("--frameRangeSum", 0);
50  nlastSum = getIntParam("--frameRangeSum", 1);
51  skipLocalAlignment = checkParam("--skipLocalAlignment");
52  minLocalRes = getIntParam("--minLocalRes");
53 
54  // read control points
55  Dimensions cPoints(
56  this->getIntParam("--controlPoints", 0),
57  this->getIntParam("--controlPoints", 1),
58  1,
59  this->getIntParam("--controlPoints", 2));
60  if ((cPoints.x() < 3) || (cPoints.y() < 3) || (cPoints.n() < 3))
62  "All control points has to be bigger than 2");
63  localAlignmentControlPoints = cPoints;
64 
65 }
66 
67 template<typename T>
69  if ((nfirstSum < nfirst) || (nlastSum > nlast)) {
70  REPORT_ERROR(ERR_ARG_INCORRECT, "Summing frames that were not aligned is not allowed. "
71  "Check the intervals of the alignment and summation "
72  "(--frameRange and --frameRangeSum).");
73  }
74  if (getScaleFactor() >= 1) {
75  REPORT_ERROR(ERR_LOGIC_ERROR, "The correlation scale factor is bigger than one. "
76  "Check that the sampling rate (--sampling) and maximal resolution to align "
77  "(--maxResForCorrelation) are correctly set. For current sampling, you can "
78  "use maximal resolution of " + std::to_string(this->Ts * 8 * getC()) + " or higher.");
79  }
80  if (!skipLocalAlignment) {
81  if (this->localAlignPatches.first <= this->localAlignmentControlPoints.x()
82  || this->localAlignPatches.second <= this->localAlignmentControlPoints.y()) {
83  REPORT_ERROR(ERR_LOGIC_ERROR, "More control points than patches. Decrease the number of control points.");
84  }
85  }
86 }
87 
88 template<typename T>
90  if (!verbose)
91  return;
92  std::cout
93  << "Input movie: " << fnMovie << std::endl
94  << "Output metadata: " << fnOut << std::endl
95  << "Dark image: " << fnDark << std::endl
96  << "Gain image: " << fnGain << std::endl
97  << "Max. Shift (A / px): " << (maxShift * Ts) << " / " << maxShift << std::endl
98  << "Max resolution (A): " << maxResForCorrelation << std::endl
99  << "Sampling: " << Ts << std::endl
100  << "Aligned movie: " << fnAligned << std::endl
101  << "Aligned micrograph: " << fnAvg << std::endl
102  << "Unaligned micrograph: " << fnInitialAvg << std::endl
103  << "Frame range alignment: " << nfirst << " " << nlast << std::endl
104  << "Frame range sum: " << nfirstSum << " " << nlastSum << std::endl
105  << "Binning factor: " << binning << std::endl
106  << "Skip local alignment: " << (skipLocalAlignment ? "yes" : "no") << std::endl
107  << "Control points: " << this->localAlignmentControlPoints << std::endl
108  << "No of patches: " << this->localAlignPatches.first << " * " << localAlignPatches.second << std::endl;
109 }
110 
111 template<typename T>
113  addUsageLine("Align a set of frames by cross-correlation of the frames");
114  addParamsLine(
115  " -i <metadata> : Metadata with the list of frames to align");
116  addParamsLine(
117  " [-o <fn=\"out.xmd\">] : Metadata with the shifts of each frame.");
118  addParamsLine(
119  " : If no filename is given, the input is rewritten");
120  addParamsLine(
121  " [--bin <s=1>] : Binning factor, it may be any floating number > 1.");
122  addParamsLine(
123  " : Binning is applied during the data loading, i.e. the program will processed and store binned data.");
124  addParamsLine(
125  " [--maxShift <s=50>] : Maximum shift allowed in A");
126  addParamsLine(
127  " [--maxResForCorrelation <R=30>]: Maximum resolution to align (in Angstroms)");
128  addParamsLine(
129  " [--sampling <Ts=1>] : Sampling rate (A/pixel)");
130  addParamsLine(
131  " [--oaligned <fn=\"\">] : Aligned movie consists of aligned frames used for micrograph generation");
132  addParamsLine(
133  " [--oavgInitial <fn=\"\">] : Give the name of a micrograph to generate an unaligned (initial) micrograph");
134  addParamsLine(
135  " [--oavg <fn=\"\">] : Give the name of a micrograph to generate an aligned micrograph");
136  addParamsLine(
137  " [--frameRange <n0=-1> <nF=-1>] : First and last frame to align, frame numbers start at 0");
138  addParamsLine(
139  " [--frameRangeSum <n0=-1> <nF=-1>] : First and last frame to sum, frame numbers start at 0");
140  addParamsLine(" [--dark <fn=\"\">] : Dark correction image");
141  addParamsLine(" [--gain <fn=\"\">] : Gain correction image (we will multiply by it)");
142  addParamsLine(
143  " [--skipLocalAlignment] : If used, only global alignment will be performed. It's faster, but gives worse results.");
144  addParamsLine(
145  " [--controlPoints <x=6> <y=6> <t=5>]: Number of control points (including end points) used for defining the BSpline");
146  addParamsLine(
147  " [--patches <x=7> <y=7>]: Number of patches used for local alignment");
148  addParamsLine(
149  " [--minLocalRes <R=500>] : Minimal resolution (in A) of patches during local alignment");
150  addExampleLine("A typical example", false);
151  addSeeAlsoLine("xmipp_movie_optical_alignment_cpu");
152 }
153 
154 template<typename T>
156  const Image<T> &dark, const Image<T> &igain, size_t objId,
157  Image<T> &out) const {
158  FileName fnFrame;
159  movie.getValue(MDL_IMAGE, fnFrame, objId);
160  out.read(fnFrame);
161  if (XSIZE(dark()) > 0) {
162  if ((XSIZE(dark()) != XSIZE(out()))
163  || (YSIZE(dark()) != YSIZE(out()))) {
165  "The dark image size does not match the movie frame size.");
166  }
167  out() -= dark();
168  }
169  if (XSIZE(igain()) > 0) {
170  if ((XSIZE(igain()) != XSIZE(out()))
171  || (YSIZE(igain()) != YSIZE(out()))) {
173  "The gain image size does not match the movie frame size.");
174  }
175  out() *= igain();
176  }
177 }
178 
179 template<typename T>
181  return this->Ts / scaleFactor;
182 }
183 
184 template<typename T>
186  assert(Ts >= this->Ts);
187 
188  // Construct 1D profile of the lowpass filter
189  MultidimArray<T> lpf(dims.x());
190  createLPF(Ts, lpf);
191 
192  // scale 1D filter to 2D
193  MultidimArray<T> result;
194  result.initZeros(dims.y(), (dims.x() / 2) + 1);
195  scaleLPF(lpf, dims, result);
196  return result;
197 }
198 
199 template<typename T>
201  // from formula
202  // e^(-1/2 * (omega^2 / sigma^2)) = 1/2; omega = Ts / max_resolution
203  // sigma = Ts / max_resolution * sqrt(1/-2log(1/2))
204  // c = sqrt(1/-2log(1/2))
205  // sigma = Ts / max_resolution * c
206  const size_t length = filter.xdim;
207  T iX = 1 / (T)length;
208  T sigma = (Ts * getC()) / maxResForCorrelation;
209  for (size_t x = 0; x < length; ++x) {
210  T w = x * iX;
211  filter.data[x] = (exp(-0.5*(w*w)/(sigma*sigma)));
212  }
213 }
214 
215 template<typename T>
217  const Dimensions &dims, MultidimArray<T>& result) {
218  Matrix1D<T> w(2);
220  {
221  FFT_IDX2DIGFREQ(i, dims.y(), YY(w));
222  FFT_IDX2DIGFREQ(j, dims.x(), XX(w));
223  T wabs = w.module();
224  A2D_ELEM(result, i, j) = lpf.interpolatedElement1D(wabs * dims.x());
225  }
226 }
227 
228 template<typename T>
230  const Matrix1D<T> &shiftX, const Matrix1D<T> &shiftY, T &totalShiftX,
231  T &totalShiftY) {
232  totalShiftX = totalShiftY = 0;
233  if (iref < j) {
234  for (int jj = j - 1; jj >= iref; --jj) {
235  totalShiftX -= shiftX(jj);
236  totalShiftY -= shiftY(jj);
237  }
238  } else if (iref > j) {
239  for (int jj = j; jj <= iref - 1; ++jj) {
240  totalShiftX += shiftX(jj);
241  totalShiftY += shiftY(jj);
242  }
243  }
244 }
245 
246 template<typename T>
248  const Matrix1D<T>& shiftX, const Matrix1D<T>& shiftY) {
249  int bestIref = -1;
250  // Choose reference image as the minimax of shifts
251  T worstShiftEver = std::numeric_limits<T>::max();
252  for (int iref = 0; iref < N; ++iref) {
253  T worstShift = -1;
254  for (int j = 0; j < N; ++j) {
255  T totalShiftX, totalShiftY;
256  computeTotalShift(iref, j, shiftX, shiftY, totalShiftX,
257  totalShiftY);
258  if (fabs(totalShiftX) > worstShift)
259  worstShift = fabs(totalShiftX);
260  }
261  if (worstShift < worstShiftEver) {
262  worstShiftEver = worstShift;
263  bestIref = iref;
264  }
265  }
266  return bestIref;
267 }
268 
269 template<typename T>
271  if (fnDark.isEmpty())
272  return;
273  dark.read(fnDark);
274 }
275 
276 template<typename T>
278  if (fnGain.isEmpty())
279  return;
280  igain.read(fnGain);
281  T avg = igain().computeAvg();
282  if (std::isinf(avg) || std::isnan(avg))
284  "The input gain image is incorrect, it contains infinite or nan");
285 }
286 
287 template<typename T>
289  // from formula
290  // e^(-1/2 * (omega^2 / sigma^2)) = 1/2; omega = Ts / max_resolution
291  // sigma = Ts / max_resolution * sqrt(1/-2log(1/2))
292  constexpr float c = std::sqrt(-1.f / (2.f * std::log(0.5f)));
293  return c;
294 }
295 
296 template<typename T>
298  // from formula
299  // e^(-1/2 * (omega^2 / sigma^2)) = 1/2; omega = Ts / max_resolution
300  // sigma = Ts / max_resolution * sqrt(1/-2log(1/2))
301  // c = sqrt(1/-2log(1/2))
302  // sigma = Ts / max_resolution * c
303  // then we want to find a resolution at 4 sigma (because values there will be almost zero anyway)
304  // omega4 = 4 * sigma -> Ts/R4 = 4 Ts / max_resolution * c
305  // R4 = max_resolution / (4 * c)
306  // new pixel size Ts' = R4 / 2 (to preserve Nyquist frequency)
307  return maxResForCorrelation / (8.f * getC());
308 }
309 
310 template<typename T>
312  // scale is ration between original pixel size and new pixel size
313  return Ts / getTsPrime();
314 }
315 
316 template<typename T>
318  //if input is an stack create a metadata.
319  if (fnMovie.isMetaData())
320  movie.read(fnMovie);
321  else {
322  ImageGeneric movieStack;
323  movieStack.read(fnMovie, HEADER);
324  size_t Xdim, Ydim, Zdim, Ndim;
325  movieStack.getDimensions(Xdim, Ydim, Zdim, Ndim);
326  if (fnMovie.getExtension() == "mrc" and Ndim == 1)
327  Ndim = Zdim;
328  size_t id;
329  FileName fn;
330  for (size_t i = 0; i < Ndim; i++) {
331  id = movie.addObject();
332  fn.compose(i + FIRST_IMAGE, fnMovie);
333  movie.setValue(MDL_IMAGE, fn, id);
334  }
335  }
336 }
337 
338 template<typename T>
340  if (this->movieSizeRaw) return movieSizeRaw.value();
341  int noOfImgs = this->nlast - this->nfirst + 1;
342  auto fn = fnMovie;
343  if (fnMovie.isMetaData()) {
344  MetaDataVec md;
345  md.read(fnMovie);
346  md.getValue(MDL_IMAGE, fn, md.firstRowId()); // assuming all frames have the same resolution
347  }
348  ImageGeneric movieStack;
349  movieStack.read(fn, HEADER);
350  size_t xdim, ydim, zdim, ndim;
351  movieStack.getDimensions(xdim, ydim, zdim, ndim);
352  this->movieSizeRaw = Dimensions(xdim, ydim, 1, noOfImgs);
353  return movieSizeRaw.value();
354 }
355 
356 template<typename T>
358  if (movieSize) return movieSize.value();
359  auto full = getMovieSizeRaw();
360  if (applyBinning()) {
361  // to make FFT fast, we want the size to be a multiple of 2
362  auto x = ((static_cast<float>(full.x()) / binning) / 2.f) * 2.f;
363  auto y = ((static_cast<float>(full.y()) / binning) / 2.f) * 2.f;
364  movieSize = Dimensions(static_cast<size_t>(x), static_cast<size_t>(y), 1L, full.n());
365  } else {
366  movieSize = full;
367  }
368  return movieSize.value();
369 }
370 
371 template<typename T>
373  const AlignmentResult<T> &alignment, MetaData &movie) {
374  int j = 0;
375  int n = 0;
376  auto negateToDouble = [binning=binning] (T v) {return (double) (v * -1) * binning;};
377  for (size_t objId : movie.ids())
378  {
379  if (n >= nfirst && n <= nlast) {
380  auto shift = alignment.shifts.at(j);
381  // we should store shift that should be applied
382  movie.setValue(MDL_SHIFT_X, negateToDouble(shift.x), objId);
383  movie.setValue(MDL_SHIFT_Y, negateToDouble(shift.y), objId);
384  j++;
385  movie.setValue(MDL_ENABLED, 1, objId);
386  } else {
387  movie.setValue(MDL_ENABLED, -1, objId);
388  movie.setValue(MDL_SHIFT_X, 0.0, objId);
389  movie.setValue(MDL_SHIFT_Y, 0.0, objId);
390  }
391  movie.setValue(MDL_WEIGHT, 1.0, objId);
392  n++;
393  }
394  MetaDataVec mdIref;
395  mdIref.setValue(MDL_REF, (int)(nfirst + alignment.refFrame), mdIref.addObject());
396  mdIref.write((FileName) "referenceFrame@" + fnOut, MD_APPEND);
397 }
398 
399 template<typename T>
401  Matrix1D<T> &bX, Matrix1D<T> &bY, Matrix2D<T> &A,
402  const core::optional<size_t> &refFrame, size_t N, int verbose) {
403  // now get the estimated shift (from the equation system)
404  // from each frame to successive frame
405  Matrix1D<T> shiftX, shiftY;
406  EquationSystemSolver::solve(bX, bY, A, shiftX, shiftY, verbose, solverIterations);
407  // prepare result
408  AlignmentResult<T> result {.refFrame = refFrame ?
409  refFrame.value() :
410  this->findReferenceImage(N, shiftX, shiftY)};
411  result.shifts.reserve(N);
412  // compute total shift in respect to reference frame
413  for (size_t i = 0; i < N; ++i) {
414  T x, y;
415  this->computeTotalShift(result.refFrame, i, shiftX, shiftY, x, y);
416  result.shifts.emplace_back(x, y);
417  }
418  return result;
419 }
420 
421 template<typename T>
423  size_t Ninitial, Image<T>& averageMicrograph, size_t N,
424  const MetaData& movie, int bestIref) {
425  if (fnInitialAvg != "") {
426  initialMic() /= Ninitial;
427  initialMic.write(fnInitialAvg);
428  }
429  if (fnAvg != "") {
430  averageMicrograph() /= N;
431  averageMicrograph.write(fnAvg);
432  }
433  movie.write((FileName) "frameShifts@" + fnOut, MD_APPEND);
434 }
435 
436 template<typename T>
438  const MetaData& movie) {
439  nfirst = std::max(nfirst, 0);
440  nfirstSum = std::max(nfirstSum, 0);
441  if (nlast < 0)
442  nlast = movie.size() - 1;
443 
444  if (nlastSum < 0)
445  nlastSum = movie.size() - 1;
446 }
447 
448 template<typename T>
450  const AlignmentResult<T> &globAlignment) {
451  std::cout << "Reference frame: " << globAlignment.refFrame << "\n";
452  std::cout << "Estimated global shifts (in px, from the reference frame";
453  std::cout << (applyBinning() ? ", ignoring binning" : "");
454  std::cout << "):\n";
455  for (auto &s : globAlignment.shifts) {
456  printf("X: %07.4f Y: %07.4f\n", s.x * binning, s.y * binning);
457  }
458  std::cout << std::endl;
459 }
460 
461 template<typename T>
463  const LocalAlignmentResult<T> &alignment) {
464  if (fnOut.isEmpty()) {
465  return;
466  }
467  if ( ! alignment.bsplineRep) {
469  "Missing BSpline representation. This should not happen. Please contact developers.");
470  }
471  // Store average
472  std::vector<double> shifts;
473  for (auto &&p : alignment.shifts) {
474  int tileCenterX = p.first.rec.getCenter().x;
475  int tileCenterY = p.first.rec.getCenter().y;
476  int tileIdxT = p.first.id_t;
477  auto shift = BSplineHelper::getShift(
478  alignment.bsplineRep.value(), alignment.movieDim,
479  tileCenterX, tileCenterY, tileIdxT);
480  auto globalShift = alignment.globalHint.shifts.at(tileIdxT);
481  shifts.emplace_back(hypot(shift.first - globalShift.x, shift.second - globalShift.y));
482  }
483  MetaDataVec mdIref;
484  size_t id = mdIref.addObject();
485  // Store confidence interval
486  std::sort(shifts.begin(), shifts.end(), std::less<double>());
487  size_t indexL = shifts.size() * 0.025;
488  size_t indexU = shifts.size() * 0.975;
489  mdIref.setValue(MDL_LOCAL_ALIGNMENT_CONF_2_5_PERC, shifts.at(indexL), id);
490  mdIref.setValue(MDL_LOCAL_ALIGNMENT_CONF_97_5_PERC, shifts.at(indexU), id);
491  // Store patches
493  std::vector<size_t>{localAlignPatches.first, localAlignPatches.second}, id);
494  // Store coefficients
495  std::vector<double> tmpX;
496  std::vector<double> tmpY;
497  size_t size = alignment.bsplineRep.value().getCoeffsX().size();
498  for (int i = 0; i < size; ++i) {
499  tmpX.push_back(alignment.bsplineRep.value().getCoeffsX()(i));
500  tmpY.push_back(alignment.bsplineRep.value().getCoeffsY()(i));
501  }
502  mdIref.setValue(MDL_LOCAL_ALIGNMENT_COEFFS_X, tmpX, id);
503  mdIref.setValue(MDL_LOCAL_ALIGNMENT_COEFFS_Y, tmpY, id);
504  // Store control points
506  std::vector<size_t>{
507  localAlignmentControlPoints.x(),
508  localAlignmentControlPoints.y(),
509  localAlignmentControlPoints.n()},
510  id);
511  // Safe to file
512  mdIref.write("localAlignment@" + fnOut, MD_APPEND);
513 }
514 
515 template<typename T>
517  // set number of patches
518  if (checkParam("--patches")) {
519  localAlignPatches = {getIntParam("--patches", 0), getIntParam("--patches", 1)};
520  } else {
521  const auto &movieDim = getMovieSize();
522  auto patchDim = getRequestedPatchSize();
523  localAlignPatches = {
524  std::ceil(static_cast<float>(movieDim.x()) / static_cast<float>(patchDim.first)),
525  std::ceil(static_cast<float>(movieDim.y()) / static_cast<float>(patchDim.second))};
526  }
527 }
528 
529 template<typename T>
531  // preprocess input data
532  MetaDataVec movie;
533  readMovie(movie);
534  correctLoopIndices(movie);
535 
536  setNoOfPatches();
537  show();
538  checkSettings();
539 
540  Image<T> dark, igain;
541  loadDarkCorrection(dark);
542  loadGainCorrection(igain);
543 
544  auto globalAlignment = AlignmentResult<T>();
545  std::cout << "Computing global alignment ...\n";
546  globalAlignment = computeGlobalAlignment(movie, dark, igain);
547 
548  if ( ! fnOut.isEmpty()) {
549  storeGlobalShifts(globalAlignment, movie);
550  }
551 
552  if (verbose) printGlobalShift(globalAlignment);
553 
554  size_t N, Ninitial;
555  Image<T> initialMic, averageMicrograph;
556  // Apply shifts and compute average
557  if (skipLocalAlignment) {
558  applyShiftsComputeAverage(movie, dark, igain, initialMic, Ninitial,
559  averageMicrograph, N, globalAlignment);
560  } else {
561  std::cout << "Computing local alignment ...\n";
562  auto localAlignment = computeLocalAlignment(movie, dark, igain, globalAlignment);
563  applyShiftsComputeAverage(movie, dark, igain, initialMic, Ninitial,
564  averageMicrograph, N, localAlignment);
565  storeResults(localAlignment);
566  }
567 
568  storeResults(initialMic, Ninitial, averageMicrograph, N, movie, globalAlignment.refFrame);
569 
570  releaseAll();
571 }
572 
int findReferenceImage(size_t N, const Matrix1D< T > &shiftX, const Matrix1D< T > &shiftY)
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
virtual size_t addObject()=0
static std::pair< T, T > getShift(const BSplineGrid< T > &grid, Dimensions dim, size_t x, size_t y, size_t n)
double module() const
Definition: matrix1d.h:983
std::vector< Point2D< T > > shifts
AlignmentResult< T > computeAlignment(Matrix1D< T > &bX, Matrix1D< T > &bY, Matrix2D< T > &A, const core::optional< size_t > &refFrame, size_t N, int verbose)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
doublereal * c
void sqrt(Image< double > &op)
BSpline coefficient in Y dim.
virtual void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const =0
std::vector< std::pair< FramePatchMeta< T >, Point2D< T > > > shifts
static double * y
void computeTotalShift(int iref, int j, const Matrix1D< T > &shiftX, const Matrix1D< T > &shiftY, T &totalShiftX, T &totalShiftY)
const AlignmentResult< T > & globalHint
T & value() const
Definition: optional.h:67
Shift for the image in the X axis (double)
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 loadFrame(const MetaData &movie, const Image< T > &dark, const Image< T > &igain, size_t objId, Image< T > &out) const
void compose(const String &str, const size_t no, const String &ext="")
doublereal * w
A shift amount at confidence level of 2.5%.
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
void storeResults(const LocalAlignmentResult< T > &alignment)
virtual IdIteratorProxy< false > ids()
virtual bool getValue(MDObject &mdValueOut, size_t id) const =0
doublereal * x
#define i
Is this image enabled? (int [-1 or 1])
Three values representing number of control points used for local alignment (X, Y, N)
Definition: mask.h:36
CUDA_HD constexpr size_t x() const
Definition: dimensions.h:51
void log(Image< double > &op)
#define XX(v)
Definition: matrix1d.h:85
Two values representing number of patches used for local alignment (X, Y)
A shift amount at confidence level of 95.5%.
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
double * f
float getPixelResolution(float scaleFactor) const
MultidimArray< T > createLPF(T Ts, const Dimensions &dims)
Incorrect argument received.
Definition: xmipp_error.h:113
size_t firstRowId() const override
FileName fnOut
static void solve(Matrix1D< T > &bXt, Matrix1D< T > &bYt, Matrix2D< T > &At, Matrix1D< T > &shiftXt, Matrix1D< T > &shiftYt, int verbosity, int iterations)
core::optional< BSplineGrid< T > > bsplineRep
#define XSIZE(v)
void max(Image< double > &op1, const Image< double > &op2)
CUDA_HD constexpr size_t y() const
Definition: dimensions.h:60
__host__ __device__ float length(float2 v)
virtual size_t size() const =0
BSpline coefficient in X dim.
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
CUDA_HD constexpr size_t n() const
Definition: dimensions.h:78
#define j
#define YY(v)
Definition: matrix1d.h:93
bool getValue(MDObject &mdValueOut, size_t id) const override
bool setValue(const MDLabel label, const T &valueIn, size_t id)
Class to which the image belongs (int)
virtual void defineParams()
Define parameters.
bool isEmpty() const
Definition: ctf.h:38
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
#define FIRST_IMAGE
std::string to_string(bond_type bondType)
Definition: compound.cpp:43
Shift for the image in the Y axis (double)
void initZeros(const MultidimArray< T1 > &op)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false)
T interpolatedElement1D(double x, T outside_value=(T) 0) const
Incorrect value received.
Definition: xmipp_error.h:195
int * n
Name of an image (std::string)
virtual void readParams()
Read argument from command line.
virtual void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true)=0
< Score 4 for volumes
Some logical error in the pipeline.
Definition: xmipp_error.h:147