Skip to content

Preserve IMOD final tilt angles in YTilt#1343

Closed
amineuron wants to merge 1 commit into
3dem:ver5.1from
amineuron:fix/imod-ytilt-offset
Closed

Preserve IMOD final tilt angles in YTilt#1343
amineuron wants to merge 1 commit into
3dem:ver5.1from
amineuron:fix/imod-ytilt-offset

Conversation

@amineuron
Copy link
Copy Markdown

@amineuron amineuron commented May 16, 2026

Summary

  • keep IMOD final .tlt angles in _rlnTomoYTilt instead of subtracting AngleOffset
  • make the C++ align_tiltseries runner and Python IMOD helper consistent
  • document that .tlt is IMOD's final OutputTiltFile used for reconstruction geometry

Rationale

When IMOD tiltalign estimates AngleOffset, the final .tlt file already includes that offset and IMOD tilt reconstructs from those corrected angles. Subtracting AngleOffset while writing _rlnTomoYTilt reverts the STAR metadata to nominal stage tilts, making RELION projection matrices inconsistent with the IMOD reconstruction geometry. This matches the symptom reported in #1141.

CTF / downstream extraction

This PR intentionally does not rewrite existing _rlnCtfScalefactor values during alignment. RELION native tomogram reconstruction already initializes _rlnCtfScalefactor = cos(_rlnTomoYTilt) when the column is absent, so preserving the final IMOD angles keeps the default CTF scale consistent with the projection geometry.

If _rlnCtfScalefactor is already present, it may have been written by RELION CTF refinement as a signal/ice-thickness scale. Overwriting it at alignment-import time would be unsafe.

Tests

  • git diff --check
  • python -m py_compile src/tomography_python_programs/align_tilt_series/imod/_utils.py

IMOD's final OutputTiltFile already includes any AngleOffset estimated by tiltalign. Subtracting that offset again stores nominal stage angles in rlnTomoYTilt, while the aligned stack and IMOD reconstruction use the final corrected angles.

Keep the final .tlt angles in rlnTomoYTilt so RELION projection matrices match the IMOD geometry. This also keeps native tomogram reconstruction's default CTF scale consistent: relion_tomo_reconstruct_tomogram initialises rlnCtfScalefactor as cos(rlnTomoYTilt) when the column is absent.

Do not rewrite pre-existing rlnCtfScalefactor values here: RELION CTF refinement can use that column for signal/ice-thickness scale, so overwriting it during alignment would be unsafe.
@amineuron amineuron force-pushed the fix/imod-ytilt-offset branch from 0e61999 to 5be7821 Compare May 16, 2026 20:43
@amineuron
Copy link
Copy Markdown
Author

amineuron commented May 20, 2026

Closing this PR.

After deeper investigation in my fork, I could see you might had designer choice and might need to be sure this convention change would be safe, couldn't find why Relion choose different convention

  1. Whether _rlnTomoYTilt stores IMOD's pitch-corrected angle or the nominal angle is empirically equivalent for self-consistent project chains — every YTilt consumer in the built tomo code (Tomogram::getCtf, reconstruct_tomogram.cpp, subtomo.cpp, reconstruct_particle.cpp) uses whatever YTilt is in the STAR.

  2. For our own fork the IMOD-consistent convention is convenient, but I don't think it's the right thing to push upstream, it would change default behavior for every existing user without solving a reproducible bug.

Will submit a focused PR for the _rlnTomoVisibleFrames issue (reconstruct_particle.cpp uses geometric visibility only, while exp_model.cpp correctly intersects with the explicit mask, so Reconstruct and Refine3D end up using different frame sets when --max_dose was set at Extract).

Thanks for the review patience.

@amineuron amineuron closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant