Extract Viewing Direction Distribution

Hi @Pielhaas,

Please see this thread for a similar script which you could use as a template for how to load particles into a python script using CryoSPARC Tools. For the code snippet:

# [...]
from cryosparc_compute import geometry
import numpy as n

particles_dset = job.load_output('particles') # particles from desired job
poses = particles_dset['alignments3D/pose']

def get_viewdir(poses):
    """ Get the viewing direction from 3D particle poses """
    Rs = geometry.expmaps(poses)
    viewdirs = Rs[...,2]
    return viewdirs

def get_azimuth_elevation(viewdirs):
    """ Get the azimuth and elevation angles from a viewing direction vector """
    viewdirs_azimuth = n.arctan2( viewdirs[:, 1], viewdirs[:, 0])
    viewdirs_elevation = n.arcsin( viewdirs[:, 2])
    return viewdirs_azimuth, viewdirs_elevation

viewdirs = get_viewdir(poses)
az, el = get_azimuth_elevation(viewdirs)

viewdirs is a 3D vector pointing along the projection direction.

Best,
Michael