Fix divide-by-zero in tilt_increment for duplicate tilt angles#349
Fix divide-by-zero in tilt_increment for duplicate tilt angles#349felipemunoz8128 wants to merge 3 commits into
Conversation
Bidirectional tilt schemes acquire two images at 0 degrees (one per half). When the tilt angle list is sorted, these adjacent 0.0 entries produce a pairwise difference of 0, making tilt_increment = 0 and overlap_frequency = inf. This zeros out the ramp filter, the wedge, and all correlation scores (-1000). Use sorted(set(tilt_angles)) to compute tilt_increment from unique angles only. The per-tilt weighting loop is unchanged and still uses all tilts including duplicates.
e1baf47 to
e1f6a08
Compare
|
Hey @felipemunoz8128, thanks for the fix. It seems small enough and I can understand what issues would pop up. I am a bit surprised people would be making two 0 degree images, as I don't think you would get any extra information for the extra dose on the sample. Do you mind adding a test that makes sure this function does not return any NaN/inf when given a set of tilt angles with a duplicate number in it? (can be 0, or a random pre-existing tilt, no real preference from me) |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 3a571cd |
I am also confused by this. I thought one would start at 0 and go to -54, and then go from +3 to +54 |
Fixes #348.
Bidirectional tilt schemes acquire two images at 0° (one per half). When the tilt angle list is sorted, adjacent
0.0entries produce a pairwise difference of 0, makingtilt_increment = 0andoverlap_frequency = inf. This zeros out the ramp filter, the wedge, and all correlation scores.Fix: Use
sorted(set(tilt_angles))to computetilt_incrementfrom unique angles only. One line changed. The per-tilt weighting loop is unchanged and still uses all tilts including duplicates for dose/CTF weighting.