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

Add method to calculate angular velocity and save it to the csv #13

Open
lauraporta opened this issue Jul 22, 2024 · 0 comments
Open

Add method to calculate angular velocity and save it to the csv #13

lauraporta opened this issue Jul 22, 2024 · 0 comments

Comments

@lauraporta
Copy link
Member

Is your feature request related to a problem? Please describe.
It would be useful to know the angular velocity of the mouse head at every frame

Describe the solution you'd like
I made this draft method:

def get_angular_velocity(angles, sampling_rate):
    #  angles are in degrees
    # angles = np.deg2rad(angles)
    diffs = np.diff(angles)
    #  remove outliers
    diffs = np.where(np.abs(diffs) > 0.05, 0, diffs)
    angular_velocity = diffs / sampling_rate

    return angular_velocity, diffs


angles_array = derotate.interpolated_angles
sampling_rate = 1 / 179200  # 1 / Hz

angular_velocity, diffs = get_angular_velocity(angles_array, sampling_rate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant