Closed brisvag closed 3 years ago
Apparently this is a general problem, not realted to stacking only.
I'm bashing my head against the wall on this one, very frustrating I ran the following to test outside of peepingtom and it seems like the matrices calculated aren't correct This goes against the observation that we get correct reconstructions from both dynamo and relion with these eulers
import napari
import numpy as np
import starfile
from eulerangles import euler2matrix
star = starfile.read('example_data/HIV_15apx.star')
# get dataframes individually
dfs = [df for name, df in star.groupby('rlnMicrographName')]
# get first dataframe
df0 = dfs[0]
# get xyz
xyz = df0[['rlnCoordinateX', 'rlnCoordinateY', 'rlnCoordinateZ']].to_numpy()
# get euler angles
eulers = df0[['rlnAngleRot', 'rlnAngleTilt', 'rlnAnglePsi']].to_numpy()
# get rotation matrices
matrices = euler2matrix(eulers, axes='zyz', intrinsic=True, positive_ccw=True)
# Apply rotation matrices on unit vector in z
rotated_unit_z = matrices @ np.array([0, 0, 1]).reshape(3, 1)
# add rotated unit z to xyz for depiction
xyz_z_shifted = xyz + rotated_unit_z.reshape(-1, 3) * 5
# visualise
viewer = napari.Viewer()
with napari.gui_qt():
viewer.add_points(xyz, face_color='blue', size=5)
viewer.add_points(xyz_z_shifted, face_color='orange', size=5)
Inverting the matrix gives the correct depiction but this goes against my understanding of the RELION euler angle convention
Understood and on it, will PR to #34 with tidier versions of the fixes
:tada: :tada: :tada:
Closed by #34.
Stacking particles seems a bit clumsy at the moment, and depiction of vectors when stacked is just wrong.