Skip to content

Commit 87f0096

Browse files
authored
Merge pull request #1032 from I2PC/ed_olz_fix_psi_indexing
Fix indexing problem in angular_project_library
2 parents d6e6c41 + 720b9e1 commit 87f0096

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/xmipp/libraries/reconstruction/angular_project_library.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ void ProgAngularProjectLibrary::project_angle_vector (int my_init, int my_end, b
197197
FileName fn_proj;
198198
int mySize;
199199
int numberStepsPsi = 1;
200+
const auto numberOfRotTilt = my_end-my_init+1;
200201

201-
mySize=my_end-my_init+1;
202+
mySize=numberOfRotTilt;
202203
if (psi_sampling < 360)
203204
{
204205
numberStepsPsi = (int) (359.99999/psi_sampling);
@@ -207,11 +208,6 @@ void ProgAngularProjectLibrary::project_angle_vector (int my_init, int my_end, b
207208

208209
if (verbose)
209210
init_progress_bar(mySize);
210-
int myCounter=0;
211-
212-
for (double mypsi=0;mypsi<360;mypsi += psi_sampling)
213-
for (int i=0;i<my_init;i++)
214-
myCounter++;
215211
// if (shears && XSIZE(inputVol())!=0 && VShears==NULL)
216212
// VShears=new RealShearsInfo(inputVol());
217213
if (projType == SHEARS && XSIZE(inputVol())!=0 && Vshears==nullptr)
@@ -222,16 +218,19 @@ void ProgAngularProjectLibrary::project_angle_vector (int my_init, int my_end, b
222218
maxFrequency,
223219
BSplineDeg);
224220

225-
for (double mypsi=0;mypsi<360;mypsi += psi_sampling)
221+
for (std::size_t psiIndex = 0; psiIndex < numberStepsPsi; ++psiIndex)
226222
{
227-
for (int i=my_init;i<=my_end;i++)
223+
double mypsi = psiIndex * psi_sampling;
224+
for (std::size_t i = 0; i < numberOfRotTilt; ++i)
228225
{
226+
const auto index = my_init + i;
227+
const auto n = psiIndex*numberOfRotTilt + i;
229228
if (verbose)
230-
progress_bar(i-my_init);
231-
232-
double psi= mypsi+ZZ(mysampling.no_redundant_sampling_points_angles[i]);
233-
double tilt= YY(mysampling.no_redundant_sampling_points_angles[i]);
234-
double rot= XX(mysampling.no_redundant_sampling_points_angles[i]);
229+
progress_bar(n);
230+
231+
double psi= mypsi+ZZ(mysampling.no_redundant_sampling_points_angles[index]);
232+
double tilt= YY(mysampling.no_redundant_sampling_points_angles[index]);
233+
double rot= XX(mysampling.no_redundant_sampling_points_angles[index]);
235234

236235
// if (shears)
237236
// projectVolume(*VShears, P, Ydim, Xdim, rot,tilt,psi);
@@ -247,9 +246,10 @@ void ProgAngularProjectLibrary::project_angle_vector (int my_init, int my_end, b
247246

248247
P.setEulerAngles(rot,tilt,psi);
249248
P.setDataMode(_DATA_ALL);
250-
P.write(output_file,(size_t) (numberStepsPsi * i + mypsi +1),true,WRITE_REPLACE);
249+
P.write(output_file, (n + 1), true, WRITE_REPLACE);
251250
}
252251
}
252+
253253
if (verbose)
254254
progress_bar(mySize);
255255
}

0 commit comments

Comments
 (0)