34 "xmipp_movie_alignment_correlation -i movie.xmd --oaligned alignedMovie.stk --oavg alignedMicrograph.mrc");
35 this->addSeeAlsoLine(
"xmipp_cuda_movie_alignment_correlation");
41 if (this->getBinning() != 1.0)
48 loadData(movie, dark, igain);
49 size_t N = this->nlast - this->nfirst + 1;
51 Matrix1D<T> bX(N * (N - 1) / 2), bY(N * (N - 1) / 2);
54 std::cout <<
"Computing shifts between frames ..." << std::endl;
56 computeShifts(N, bX, bY, A);
60 return this->computeAlignment(bX, bY, A, ref, N, this->verbose);
68 throw std::logic_error(
"Not implemented");
75 throw std::logic_error(
"Not implemented");
81 sizeFactor = this->getScaleFactor();
84 bool firstImage =
true;
90 std::cout <<
"Computing Fourier transform of frames ..." << std::endl;
94 for (
size_t objId : movie.
ids())
97 if (n >= this->nfirst && n <= this->nlast) {
98 this->loadFrame(movie, dark, igain, objId, croppedFrame);
102 newXdim = croppedFrame().xdim * sizeFactor;
103 newYdim = croppedFrame().ydim * sizeFactor;
104 filter = this->createLPF(this->getPixelResolution(sizeFactor),
Dimensions(newXdim,
113 auto *reducedFrameFourier =
121 frameFourier.push_back(reducedFrameFourier);
134 assert(frameFourier.size() > 0);
137 Mcorr.setXmippOrigin();
139 for (
size_t i = 0;
i < N - 1; ++
i) {
140 for (
size_t j =
i + 1;
j < N; ++
j) {
141 bestShift(*frameFourier[
i], *frameFourier[
j], Mcorr, bX(idx),
142 bY(idx), aux,
nullptr, this->maxShift * sizeFactor);
143 bX(idx) /= sizeFactor;
144 bY(idx) /= sizeFactor;
146 std::cerr <<
"Frame " << i + this->nfirst <<
" to Frame " 147 << j + this->nfirst <<
" -> (" 150 for (
int ij = i; ij <
j; ij++)
164 Image<T> frame, croppedFrame, reducedFrame, shiftedFrame;
170 for (
size_t objId : movie.
ids())
173 if ((frameIndex >= this->nfirstSum) && (frameIndex <= this->nlastSum)) {
176 int frameOffset = frameIndex - this->nfirst;
178 XX(shift) = -globAlignment.
shifts.at(frameOffset).x;
179 YY(shift) = -globAlignment.
shifts.at(frameOffset).y;
180 bool isZeroShift = (
XX(shift) ==
YY(shift))
181 && (
XX(shift) == (T)0);
184 this->loadFrame(movie, dark, igain, objId, croppedFrame);
186 if ( ! this->fnInitialAvg.isEmpty()) {
187 if (frameIndex == this->nfirstSum)
188 initialMic() = croppedFrame();
190 initialMic() += croppedFrame();
194 if (this->fnAligned !=
"" || this->fnAvg !=
"") {
197 if (
nullptr == shiftedFrame().data) {
198 shiftedFrame().resizeNoCopy(croppedFrame());
200 std::swap(shiftedFrame().data, croppedFrame().data);
203 croppedFrame(), shift, xmipp_transformation::DONT_WRAP,
204 croppedFrame().computeAvg());
206 if (this->fnAligned !=
"")
207 shiftedFrame.
write(this->fnAligned, frameOffset + 1,
true,
209 if (this->fnAvg !=
"") {
210 if (frameIndex == this->nfirstSum)
211 averageMicrograph() = shiftedFrame();
213 averageMicrograph() += shiftedFrame();
217 std::swap(shiftedFrame().data, croppedFrame().data);
220 if (this->verbose > 1) {
221 std::cout <<
"Frame " <<
std::to_string(frameIndex) <<
" processed." << std::endl;
void init_progress_bar(long total)
std::vector< Point2D< T > > shifts
#define REPORT_ERROR(nerr, ErrormMsg)
void resizeNoCopy(const MultidimArray< T1 > &v)
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 defineParams() override
Define parameters.
void readParams() override
Read argument from command line.
Incorrect argument received.
void progress_bar(long rlen)
#define DIRECT_MULTIDIM_ELEM(v, n)
void scaleToSizeFourier(int Zdim, int Ydim, int Xdim, MultidimArray< double > &mdaIn, MultidimArray< double > &mdaOut, int nThreads)
virtual void defineParams()
Define parameters.
void translate(PDB *pdb_original, PDB *pdb_move, unsigned num_atoms, double x0, double y0, double z0)
template float bestShift(MultidimArray< float > &, float &, float &, const MultidimArray< int > *, int)
std::string to_string(bond_type bondType)
virtual void readParams()
Read argument from command line.