Skip to main content

A package for extracting facial expressions from SLEAP analyses

Project description

SLEAPyFaces

This is a package for extracting facial expressions from SLEAP analyses.


PyPI - Version PyPI - Python Version


To Do:

Things that it does:

  1. iterate (repeatedly) over each mouse and each week (each mouse and each experiment)
    • get project files (experimental) structure
    • initialize an iterator over project structure
  2. get daq data from CSV file
    • read CSV files
    • save each column from CSV file
      • Note: CSV columns are of differing lengths
  3. get “beh_metadata” from json metadata
    • read JSON file
    • grab the values for key “beh_metadata”
      • get the values of sub key “trialArray”
      • get the values of subkey “ITIArray”
  4. get video metadata from *.mp4 file (with ffmpeg.probe)
    • read in the *.mp4 metadata
    • select the correct video stream
    • get the average frames per second
  5. get SLEAP data from *.h5 file
    • open h5 file
    • get transposed values of key “tracks” (tracking_locations)
    • fill missing locations (linear regress. fit)
    • get transposed values of key “edge_inds”
    • get values of key “edge_names”
    • get transposed values of “instance_scores”
    • get transposed values of “point_scores”
    • get values of “track_occupancy”
    • get transposed values of “tracking_scores”
    • get decoded values of “node_names” (make sure theres no encoding issues)
  6. deconstruct SLEAP points into x and y points (across all frames)
    • iterate over each node
    • breakup the 4D array “tracks” into 1D array for x and y values respectively
      • Note: [frame, node, x/y, color] for greyscale the color dimension is 1D (i.e. essentially the 4D array is 3D because the color dimension is constant)
    • iterate over each frame
    • assign mouse, week, frame #, and timestamp (using average frames per second)
  7. Split data into individual trials by trial type using the Speaker and LED data from the CSV daq data
    • initialize trial iterators for the consistently documented points from the daq CSV
    • iterate over each trial in “trialArray”
    • get the index of 10sec before and 13sec after trial start
    • for each feature, grab the start and end indices
    • store data from each trial in a pd.dataframe
    • concatenate all pd.dataframes together for each video
    • concatenate the pd.dataframes from each video together for each mouse (base expr split)
  8. Prepare the data
    • (opt.) mean center across all points for a single trial
    • mean center across all trials for a single experiment
    • mean center across all experiments for a single mouse
    • mean center across all mice
    • (opt.) z-score mean centered data
  9. Analyze the data
    • Perform 2D and 3D PCAs on all data (raw, centered, by trial, by week, by mouse, etc…)
    • apply gaussian kernel to PCA outputs
  10. Save the data
    • write everything to HDF5 file(s)

Table of Contents

Installation

pip install sleapyfaces

License

sleapyfaces is distributed under the terms of the MIT license.

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

sleapyfaces-1.0.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

sleapyfaces-1.0.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file sleapyfaces-1.0.0.tar.gz.

File metadata

  • Download URL: sleapyfaces-1.0.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.1

File hashes

Hashes for sleapyfaces-1.0.0.tar.gz
Algorithm Hash digest
SHA256 071f08edcd5a8ed7a51f9b8482e95c8d1573fabb0976d09bced3c4dcc635a0f7
MD5 f1b8e26acb12c4bd50c006566b3090ac
BLAKE2b-256 18a4c55784c3ab66fec4cb92a5eb313c3633e43911c1eecc5d415c759d8651f7

See more details on using hashes here.

File details

Details for the file sleapyfaces-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sleapyfaces-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28224ea3fbba31421e16d9862b5b25921839c180e12c0b98783a39809795b865
MD5 485abd87ebb49f177f55171f19f3d1c1
BLAKE2b-256 a2b9d2e4a7469468d0548bb047b436826bcd26e7d562e9af7689b6f85d016ccc

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