Skip to content

Commit

Permalink
fix MRC axis orientation handling
Browse files Browse the repository at this point in the history
Co-authored-by: tluchko <[email protected]>
  • Loading branch information
orbeckst and tluchko authored Feb 20, 2022
1 parent 51ed84b commit fa33473
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gridData/mrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ def read(self, filename):
# All other "xyz" quantitities are also reordered.
axes_order = np.hstack([h.mapc, h.mapr, h.maps])
axes_c_order = np.argsort(axes_order)
self.array = np.transpose(np.transpose(mrc.data), axes=axes_c_order)
self.delta = np.diag(
np.array([mrc.voxel_size.x, mrc.voxel_size.y, mrc.voxel_size.z])[axes_c_order])
# the grid is shifted to the CCP4 origin by offset
transpose_order = np.argsort(axes_order[::-1])
self.array = np.transpose(mrc.data, axes=transpose_order)
self.delta = np.diag(np.array([mrc.voxel_size.x, mrc.voxel_size.y, mrc.voxel_size.z]))
# the grid is shifted to the MRC origin by offset
# (assume orthorhombic)
offsets = np.hstack([h.nxstart, h.nystart, h.nzstart])[axes_c_order] * np.diag(self.delta)
# GridData origin is centre of cell at x=col=0, y=row=0 z=seg=0
self.origin = np.hstack([h.origin.x, h.origin.y, h.origin.z])[axes_c_order] + offsets
self.origin = np.hstack([h.origin.x, h.origin.y, h.origin.z]) + offsets
self.rank = 3

@property
Expand Down

0 comments on commit fa33473

Please sign in to comment.