Code Monkey home page Code Monkey logo

sleepworks's Introduction

Automatic Sleep Stage Classification using Deep Learning

Introduction

This repository provides a deep learning-based approach to automatically classify sleep stages using polysomnography (PSG) signals from European Data Format (EDF, EDF+) files. The model architectures provided consist of Convolutional Neural Network (CNN) and Convolutional LSTM models.

The repository includes Python scripts to extract PSG signals from EDF files, preprocess the signals, train and evaluate the deep learning model, and make predictions on new PSG data. The repository also includes a Jupyter notebook that demonstrates how to use the scripts.

Data Set

This repository uses Polysomnography (PSG) data obtained during sleep. PSG data is a multi-channel time series data containing EEG, EOG, EMG, and other physiological signals taken during sleep. PSG data is commonly used in the diagnosis and treatment of sleep disorders.

Requirements

  • Python 3.x
  • NumPy
  • SciPy
  • Matplotlib
  • MNE-Python
  • TensorFlow 2.x

Usage

To use the repository, follow these steps:

  1. Clone the repository:
git clone https://github.com/username/repository.git
  1. Install the required libraries:

This repository was developed using Python 3.x, and pip can be used to install required dependencies. First, install the required libraries using the following command:

pip install -r requirements.txt
  1. Extract PSG signals from EDF files using the extract_psg.py script:
python extract_psg.py /edf /psg
  1. Preprocess the PSG signals using the preprocess_psg.py script:

Data preprocessing involves reading EDF files, signal processing, data scaling, and other preprocessing tasks.

EDF files are read using MNE (a Python library for Magnetoencephalography and Electroencephalography). PSG signals are sampled signals, and this sampling rate is resampled to a sampling rate determined in the preprocessing stage. The data is then scaled and processed.

python preprocess_psg.py /psg /prep --sampling_rate 100
  1. Train the deep learning model using the train_model.py script:

This repository uses various deep learning models such as CNN, CNN-LSTM to predict sleep stages. After the data preprocessing is completed, a model is trained for classifying sleep stages.

python train_model.py /prep /train --epochs 50 --batch_size 32
  1. Evaluate the trained model using the evaluate_model.py script:

After model training is completed, the trained model is used on test data, and its performance is evaluated on test data.

python evaluate_model.py /prep /models
  1. Make predictions on new PSG data using the predict_psg.py script:
python predict.py --edf_file <edf_file_path> --model_path <model_path> --output_path <output_path>

License

This project is licensed under the GNU GPL License - see the LICENSE file for details.

Acknowledgments

  • PhysioNet for providing the sleep dataset used in this project.
  • MNE-Python development team for providing the EDF file reader and other helpful functions.

Contributers

Goksu Ozen

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.