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

Broken vector depiction. #31

Closed
brisvag opened this issue Nov 22, 2020 · 7 comments
Closed

Broken vector depiction. #31

brisvag opened this issue Nov 22, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@brisvag
Copy link
Owner

brisvag commented Nov 22, 2020

Stacking particles seems a bit clumsy at the moment, and depiction of vectors when stacked is just wrong.

@brisvag brisvag added the bug Something isn't working label Nov 22, 2020
@brisvag brisvag changed the title Broken stacked vector depiction. Broken vector depiction. Nov 22, 2020
@brisvag
Copy link
Owner Author

brisvag commented Nov 22, 2020

Apparently this is a general problem, not realted to stacking only.

@alisterburt
Copy link
Collaborator

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)

image

@alisterburt
Copy link
Collaborator

Inverting the matrix gives the correct depiction but this goes against my understanding of the RELION euler angle convention
image

@alisterburt
Copy link
Collaborator

Understood and on it, will PR to #34 with tidier versions of the fixes

@alisterburt
Copy link
Collaborator

HIV_vis

@alisterburt
Copy link
Collaborator

🎉 🎉 🎉

@brisvag
Copy link
Owner Author

brisvag commented Nov 24, 2020

Closed by #34.

@brisvag brisvag closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants