Skip to main content

A small suit of function for analyzing freezing behavior based on a threshold.

Project description

FrozenPy

FrozenPy is a small suit of Python functions for detecting freezing behavior and averaging data based on paradigm structure, with a particular focus on Pavlovian conditioning paradigms. Freezing is detected by thresholding motion data under a defined value (e.g. 10 a.u.) for a defined minimum length of time (1 sec). It also includes functions for converting .out files generated from MedPC to easier-to-handle .csv files.

FrozenPy is designed so that it is easy to add metadata (group, sex, etc.) and formats data for use with popular plotting (Seaborn) and statistical (Pingouin) packages within Python.

Usage

Installation

FrozenPy can easily be installed via pip. Type the following into your terminal to install FrozenPy.

pip install FrozenPy

Read .out files

Converting .out to .raw.csv, read .raw.csv:

# Base directory containing .out files
out_dir = '/path/to/your/.out/files'

# convert all .out files within dir to .raw.csv
fp.read_out(out_dir)

# read .raw.csv
data_raw = fp.read_rawcsv('your_data.raw.csv')

Detect freezing and average

Detect freezing:

# detect freezing
data_freezing = fp.detect_freezing(data_raw)

This is an example for if we wanted to slice and average data with a 3 min baseline, 10s CS, 2s US, 58s ISI, and 5 trials:

# slice data
frz_bl, frz_trials = fp.get_averagedslices(df=data_freezing,
                                         BL=180,
                                         CS=10,
                                         US=2,
                                         Trials=5,
                                         ISI=58,
                                         fs=5,
                                         Behav='Freezing')

This would output two variables: frz_bl which contained the averaged BL data for each subject, and frz_trials which contained CS, US, and ISI data for each subject. These are seperated because BL is factorial data whereas Trials are repeated measures. Combining these into one dataframe gets weird in long format and it's easiest to keep these separated for plotting and statistics.

Notes

This code was developed specifically for the Maren Lab which uses MedPC boxes that measure motion via loadcells, but it should work with any motion data so long as it is in the correct format. If you notice any problems or wish to contribute please don't hesitate to contact me at mictott@gmail.com, open a pull request, or submit an issue.

Future directions

  • pip integration
  • plot CS data
  • take advantage of xarrays
  • provide visible feedback to allow for threshold adjustments (not in the near future unless needed)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FrozenPy-0.1.9.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

FrozenPy-0.1.9-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file FrozenPy-0.1.9.tar.gz.

File metadata

  • Download URL: FrozenPy-0.1.9.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.7

File hashes

Hashes for FrozenPy-0.1.9.tar.gz
Algorithm Hash digest
SHA256 e2a24885c20c148dab6189059e34e2fb89efea0ee7378af2665f4acc1b0e5ed6
MD5 b826cc269b615d5e5e3726b365ec7f6b
BLAKE2b-256 48c02e1571d3b7a137d11c90f20519fa889f46251d6be45a1e9d7698c3dfd95d

See more details on using hashes here.

File details

Details for the file FrozenPy-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: FrozenPy-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.7

File hashes

Hashes for FrozenPy-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ecc3910604d1a4bed006eadb665f6f073e6657078e3a655abb50690e2547a2c5
MD5 4c2276cf4b620080ff61ff81a798c628
BLAKE2b-256 b7dfaa6e2623a23ecf72337318ede2f434ed8215d8a1370c55b83bfabfc81120

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page