Coder Social home page Coder Social logo

mousetracking's Introduction

Mouse Tracking analysis pipeline ๐Ÿญ

image

This repository contains a collection of code to analyze behavior in mice.

I used this pipeline to analyze and automatically score open field and novel object-place-context recognition test in mice in order to test episodic memory.

It uses the following Python libraries:

  • Analysis:
    • Pandas
    • Numpy
    • OpenCV
  • Plotting:
    • Matplotlib
    • Seaborn

Expected inputs

Behavioral videos have to be processed with DeepLabCut in order to extract coordinates for different body regions in each frame (the nose, the right ear, the left ear, the bottom, the mid tail and the tip of the tail).

image7(1)

General behavioral scoring

Based on the tracking results, the analysis pipeline will automatically calculate the following behavioral parameters:

  • Total distance traveled (cm)
  • Average speed (cm/s)
  • Time spent in the center of the arena (s)
  • Time spent in the periphery of the arena (s)

The pipeline will also produce trajectories and heatmaps of the mouse location during the session:

image53

Behavioral classification

To test memory retention, I exploit the spontaneous tendency of mice to explore novel objects and situations more than familiar ones. If a subject remembers to have explored the same object before it should prioritize the exploration of the other, novel one.

I quantitatively measure this tendency with a Discrimination Index defined as:

(T_novel - T_familiar) / (T_novel + T_familiar)

where:

  • T_novel is the time in seconds spent exploring the novel object
  • T_familiar is the time in seconds spent exploring the familiar object

Based on the distances of some body parts from the two objects, I implemented two ways to automatically classify frames as exploration or non-exploration

Random forest classifier

I trained a custom random forest classifier to predict whether the mouse is exploring or not an object (bool variable) based on the distances of its body parts from the object edge.

This approach has the advantage that takes into consideration the actual posture of an animal and its gaze direction.

Nose-to-Object distance

As a reference, I also implemented a classification method based only on the distance between the nose and the object's edges, as more classically done in the literature. This method requires the user to set a distance threshold to consider a frame to be an exploration one.

To determine an appropriate distance threshold, I manually scored each individual frame of several videos and used this data as ground truth. I found out that using a threshold distance of 2cm yields the most similar results to GT.

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.