Coder Social home page Coder Social logo

farhanaugustine / dynamic_position_velocity_visualizer_for_dlc Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 399 KB

I created this notebook to help me with behavioral neuroscience experiments. It calculates the average positions and velocities of two body parts (for better accuracy), and creates visualizations such as GIFs and streamline plots to represent the motion and flow of movement.

License: GNU General Public License v3.0

Jupyter Notebook 100.00%
analysis behavior-analysis deeplabcut neuroscience

dynamic_position_velocity_visualizer_for_dlc's Introduction

DOI

Dynamic_Position_Velocity_Visualizer_For_DLC

Motion Analysis and Visualization


Video Tutorial and Walkthrough: Link


Tumbnail

Overview

This Jupyter script is designed for motion analysis of tracked body parts in DeepLabCut CSV files. I created this notebook to help me with behavioral neuroscience experiments. It calculates the average positions and velocities of two body parts (for better accuracy). It creates visualizations such as GIFs and streamline plots to represent the motion and flow of movement. Although there are tools like Simba, DLCAnalyzer, and Bonsai, none are as easy as running a Python script.

Installation

To run this script, you will need Python installed on your system along with the following libraries:

pandas numpy matplotlib imageio scipy IPython

You can install these libraries using pip: For example pip install pandas numpy matplotlib imageio scipy IPython

Usage

To use this script, you will need a CSV file containing the tracked body part data generated from DLC analyses. The script reads this data, performs calculations and generates visualizations.

  1. Load your CSV data into a DataFrame.
  2. Create a dictionary mapping body part names to their coordinate columns.
  3. Define functions to calculate average positions and velocities.
  4. Generate GIFs to visualize the movement of body parts.
  5. Create optical flow diagrams and streamline plots to visualize the flow of movement.

Functions

calculate_average_position - Calculates the average position of two body parts. create_position_gif - Creates and displays a GIF from the average positions of two body parts.

Example of Averaged Head and Thorax Movements of Mouse in T-maze

average_position_Head_Thorax

calculate_average_velocity - Calculates the average velocity of two body parts.

create_optical_flow_gif - Creates and displays a GIF from the average positions and velocities of two body parts.

Example of Averaged Head and Thorax Velocities of Mouse in T-maze

Arrow length represent the magnitude of the velocity at each point

optical_flow_Nose_Head

Optical Flow Diagram for Individual Body Part - This Section creates quivers to generate optical flow diagrams.

Example of T-maze Flow Diagram

image

Streamline Plot - This Section of the code creates a streamlined plot where the red color represents the higher average speed.

image

Other Notes:

  1. Ensure that the CSV file path is correct and accessible on your system.
  2. Replace placeholder comments with actual values like frame rates and body part names based on your experimental data.
  3. The calculate_average_velocity function uses np.diff, which reduces the array size by one. Ensure that the positions array is adjusted accordingly when used with velocities.
  4. When creating streamline plots, ensure that the grid interpolation is performed correctly.

dynamic_position_velocity_visualizer_for_dlc's People

Contributors

farhanaugustine avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.