Skip to content

This repository houses the codebase to predict stress solely on the electrical activity of the heart using machine learning techniques.

Notifications You must be signed in to change notification settings

AlexAntonides/Enhancing-Generalizability-in-Acute-Mental-Stress-Detection

Repository files navigation

Python Version PyTorch Version


Enhancing Generalizability in Acute Mental Stress Detection:
A Machine Learning Approach Leveraging ECG from a Novel Dataset

This repository houses the codebase to predict stress solely on the electrical activity of the heart using machine learning techniques.

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Frequently Asked Questions

About The Project

This project aims to predict the stress of an unknown person soley on the electrical activity of the heart. This is achieved through training machine learning models on electrocardiogram (ECG) recordings.

Stress-in-Action (SiA)-Kit

The SiA-Kit is a package that provides human-readable and extendable pipelines to repeat the experiments described in the project. The builder pattern that is used throughout the pipelines, makes it easier to understand what is happening behind the scenes.

(back to top)

Getting Started

Prerequisites

  • Python v3.9+

(back to top)

Preparation

  1. Install The Packages.
    Open the terminal in the root directory and execute the following command,
pip[3] install -r requirements.txt

Preprocessing

A step by step series of examples that tell you how to get the data cleaned.

  1. Prepare your dataset.
    The directories that were used throughout the experiment can be found in data/, which is separated into four parts, raw for the raw data, cleaned for the cleaned data, features for the manually extracted features used to build the machine learning models, and signal which can be used by a neural network.
    The use of these directories are optional, any directories can be used, as long as the paths are changed accordingly.
    The dataset can be prepared by using the pipeline found in 1_preprocessing.ipynb, or by using the methods that can be found in the SiA-kit, like so,
sia.Preprocessing() \
    .data(read_csv('<in_path>/*.csv')) \
    .process(neurokit()) \
    .to(write_csv('<out_path>/[0-9]{5}.csv'))
  1. Extract the features.
    The features can be extracted by using the pipeline found in 2_feature_extraction.ipynb, or by using the methods that can be found in the SiA-kit, like so,
sia.Segmenter() \
    .data(read_csv('<in_path>/*.csv')) \
    .segment(SlidingWindow(WINDOW_SIZE, STEP_SIZE)) \
        .extract(hrv([Statistic.MEAN, Statistic.CVSD, Statistic.NN20]))
    .to(write_csv('<out_path>/[0-9]{5}.csv'))
  1. Build the model.
    The model can be built by using the pipeline found in 3_training.ipynb.

(back to top)

Frequently Asked Questions

  1. Where are the experiments?
    For better readability, this repository has been overhauled. The notebooks with the experiments can be found in /deprecated.

(back to top)

About

This repository houses the codebase to predict stress solely on the electrical activity of the heart using machine learning techniques.

Topics

Resources

Stars

Watchers

Forks