Skip to main content

Frequency-domain model analysis package

Project description

FLEX: Frequency Layer Explanation

Overview

This repository contains the implementation of FLEX (Frequency Layer Explanation), a method designed to explain the predictions of deep neural networks (DNNs) for sleep stage classification using EEG data. FLEX combines Integrated Gradients (IG) with a frequency-domain transform (via the Real Fast Fourier Transform (RFFT)) to provide frequency-based attribution scores.

The method is particularly useful for understanding how different frequency components of EEG signals influence the predictions of a DNN, enhancing model interpretability in the context of sleep research.

We will always talk about EEG Data in Sleep Research here, but in general this method can be used for a frequency-wise understanding of a model classifying time-series data.


Features

  • RFFT Transformation: Input EEG signals are transformed into the frequency domain using the RFFT.
  • iRFFT Transformation: The inverse RFFT (iRFFT) is implemented as the first layer in the DNN to process frequency-domain inputs.
  • Integrated Gradients Attribution: Captum's IG method is used to compute relevance scores for frequency bands, providing insights into the features contributing to the model's predictions.

Definition of FLEX

Let F be our model (DNN) and x be our input (EEG-Data). Then with $\bar{F} = F \circ iRFFT$ and $\bar{x} = RFFT(x)$ we get $$FLEX_i(F,x) = IG_i(\bar{F},\bar{x})$$, where $FLEX(F,x) = (FLEX_1(F,x), ..., FLEX_n(F,x))$ with $x \in R^n$.


Installation

Requirements

  • Python 3.8+
  • Required libraries:
  • numpy
  • torch
  • captum

Install Dependencies

You can install the required Python libraries using pip:

pip install numpy torch captum

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

flig-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file flig-0.1.0.tar.gz.

File metadata

  • Download URL: flig-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for flig-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd86723500f8e4031f222be3b0783d5c0490234abef0bddc6acfd888aade00d5
MD5 f3fe54062130c1784bf4b0199f32b098
BLAKE2b-256 e0a8ed686b8b554f429ca567cfd12e5a4eb3dbc297bd8a3ff1f65c992de1355b

See more details on using hashes here.

Supported by

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