Skip to content

Commit

Permalink
FormatMRC: relax MZ check (#740)
Browse files Browse the repository at this point in the history
MZ is expected to either equal NZ, or MZ == 1 for a "volume stack"
containing a single volume.
  • Loading branch information
dagewa committed Jul 10, 2024
1 parent e8c2c92 commit 4e46bec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions newsfragments/740.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
``FormatMRC``: relax restrictive check on the overloaded MZ header
value, which caused failures to read files where MZ == 1
9 changes: 6 additions & 3 deletions src/dxtbx/format/FormatMRC.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ def _unpack_header(header):

# For image stacks, NX==MX etc. should always be true. Assert this
# to ensure we fail on an MRC file of the wrong type.
assert hd["nx"] == hd["mx"]
assert hd["ny"] == hd["my"]
assert hd["nz"] == hd["mz"]
try:
assert hd["nx"] == hd["mx"]
assert hd["ny"] == hd["my"]
assert (hd["nz"] == hd["mz"]) or (hd["mz"] == 1)
except AssertionError:
raise ValueError("Unexpected data size values in the header")

return hd

Expand Down

0 comments on commit 4e46bec

Please sign in to comment.