Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatMRC invert slow axis for non-FEI files #202

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/xxx.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``FormatMRC``: invert the slow axis for non-ThermoFisher (FEI) files.
18 changes: 17 additions & 1 deletion src/dxtbx/format/FormatMRC.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,28 @@ def _detector(self):

# Beam centre not in the header - set to the image centre
beam_centre = [(pixel_size * i) / 2 for i in image_size]

# As reported in https://doi.org/10.1016/j.str.2023.07.004
# and investigated further by @huwjenkins in
# https://github.com/huwjenkins/em_image_conversions/wiki/Y%E2%80%90axis-flips-in-conversion-to-MRC-using-EMAN2-and-IMOD
# different interpretations of the MRC format may lead to a flip in the
# Y-axis. Our understanding is that ThermoFisher (FEI) data always
# assumes the slow axis is -y, so viewed from the source to the image
# the origin is upper left. Most (all?) non-FEI data, e.g. images that
# have been converted by EMAN2 or IMOD, assume the slow axis is +y, and
# the origin is lower left. If we flip the slow axis, we need to invert
# the distance too.
slow_axis = "-y"
if not self._header_dictionary["exttyp"].startswith(b"FEI"):
distance = -1.0 * distance
slow_axis = "+y"

detector = self._detector_factory.simple(
"PAD",
distance,
beam_centre,
"+x",
"-y",
slow_axis,
(pixel_size, pixel_size),
image_size,
trusted_range,
Expand Down
Loading