brisvag / blik

Python tool for visualising and interacting with cryo-ET and subtomogram averaging data.
https://brisvag.github.io/blik/
GNU General Public License v3.0
23 stars 8 forks source link

Broken vector depiction. #31

Closed brisvag closed 3 years ago

brisvag commented 3 years ago

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

brisvag commented 3 years ago

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

alisterburt commented 3 years ago

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 commented 3 years ago

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

alisterburt commented 3 years ago

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

alisterburt commented 3 years ago

HIV_vis

alisterburt commented 3 years ago

:tada: :tada: :tada:

brisvag commented 3 years ago

Closed by #34.