Skip to main content

Python scripts to analyze sleep-scored EEG files

Overview

EEG-based murine sleep studies use waveform signature to define three behavioral states--wake, rapid eye movement (REM) sleep, and non-REM (NREM) sleep. These recordings are long (typically 6-48 hours) and broken down into short epochs (usually 4-10 seconds). Either automatic or manual scoring is required to label each epoch as wake, NREM, or REM (and this package does not assist with this scoring).

These scripts will read in scored EEG files and output key metrics into Excel. These metrics inlcude:

  • Total time in wake, NREM, or REM sleep of user-specified bin size (default = 2 hours)
  • Total number of wake, NREM, and REM sleep bouts of user-specified bin size (default = 12 hours)
  • Average length of wake, NREM, and REM sleep bouts of user-specified bin size (default = 12 hours)
  • Wake bout distribution, or a frequency of wake bouts by their duration. This binning can be specified by user; default is power of 2 (16 seconds - 2048 seconds).
  • Spectral analysis (to be completed)

This code was originally built in MATLAB, which was first used to analyze results in Perron IJ et al..

If you use this analysis package, please cite this repo.

Detailed installation istructions for first time users

For users comfortable with python/anaconda, skip to last step

  1. Download and install anaconda, if you have not done so already.

  2. On your local machine, open anaconda shell. If you see (base), that means python is active in root environment.

  3. Non-first time users skip to step 4.. First time users should create new virtual environment:

conda create --name env3

In this example, env3 is the virutal environment name; it can be named whatever you prefer.

  1. Activate virutal environment:

conda activate env3

The terminal should now show (env3) instead of (base) if this worked correctly.

  1. Install eeg-sleep-analysis package:

pip install eeg-sleep-analysis

Detailed user instructions

  1. In terminal, navigate to your preferred directory. To list directory routes:

ls -la (for mac/linux)

dir (for windows)

To change directory:

cd (for mac/linux/windows)

  1. Type the command to launch the GUI

python -m EEGAnalysis

  1. For a new experiment, create a config.txt file. This will be created in your current directory. You must open and edit this config file with correct file directories and experiment details.

  2. In the GUI, navigate to the correct config.txt file.

  3. Create a new conditions.csv. If the config.txt file is setup properly, this should be generated automatically and correctly. However, it is highly recommended to double check conditions.csv before running analysis.

  4. In the GUI, navigate to the correct conditions.csv file.

  5. Run the analysis. Results will be output into the specified directory in the config.txt file.

Contact information

Please direct any questions or suggestions to ijperron@gmail.com

Acknowledgements

Thank you to the members of the University of Pennsylvania Center for Sleep and Circadian Neurobiology, especially Drs. Allan Pack and Sigrid Veasey. Thank you to Cameron Jones for his help to debug this program.

Release files for eeg-sleep-analysis 1.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eeg-sleep-analysis 1.2.10
File Size Uploaded
eeg-sleep-analysis-1.2.10.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eeg-sleep-analysis 1.2.10
File Interpreter ABI Platform
eeg_sleep_analysis-1.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / eeg-sleep-analysis-1.2.10.tar.gz

Download URL eeg-sleep-analysis-1.2.10.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0ed225cb4ff84d7465686a22b628aaaab2b05bf27b1da58a986382c2ed2ba971
BLAKE2b-256 checksum
How to use checksums
50a74f3da2a722a71c75099bb2a1889eab6351e833f36f75b03ad10ea2d0b6bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / eeg_sleep_analysis-1.2.10-py3-none-any.whl

Download URL eeg_sleep_analysis-1.2.10-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e8abfe2400fcaaac186e5f72235f0bfba5a58a3e90186723b61f34ca7f8877f
BLAKE2b-256 checksum
How to use checksums
7ae6e24b03d24b9532da01f23ee16b81084e19be1555a4367074594ad65ec214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.2.10 This release

2 release files

1.1.7

2 release files

1.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page