Skip to main content

A library for processing and plotting EEG data

Project description

EEG Analysis

This Library provides functions to process and plot EEG data, specifically focusing on the effects of different states (Before, During, After) on various EEG frequency bands.

Installation

To install the library, use pip:

pip install eeg_analysis

Usage

Loading the Data

First, load the data from a CSV file. The CSV file should be structured with columns for subject, location, band, and power measurements for three states (Before, During, After).

import pandas as pd
from eeg_analysis import load_data

# Load the data
data = load_data('path/to/your/data.csv')

Cleaning the Data

Once the data is loaded, it needs to be cleaned and structured into a more usable format. The clean_data function organizes the data into a DataFrame with appropriate columns.

from eeg_analysis import clean_data

# Clean and structure the data
df = clean_data(data)

# Optionally, save the cleaned data to a new CSV file
df.to_csv('cleaned_data.csv', index=False)
print(df.head())

Performing Paired T-Tests

The library includes a function to perform paired t-tests between the different states for a specified frequency band. This can help determine if there are statistically significant differences in power between the states.

from eeg_analysis import perform_ttests

# Perform t-tests for a specific band (e.g., 'Delta')
ttest_results_df = perform_ttests(df, 'Delta')

# Display the results
print(ttest_results_df)

Plotting Median Power Across Bands

The library provides a function to plot the median power across different states for each frequency band. This can help visualize the changes in power for different subjects and states.

from my_pypi_library import plot_median_across_bands

# Plot the median power across bands
plot_median_across_bands(df)

Example Workflow

Here's a complete example that demonstrates the typical workflow using the library:

import pandas as pd
from eeg_analysis import load_data, clean_data, perform_ttests, plot_median_across_bands

# Step 1: Load the data
data = load_data('path/to/your/data.csv')

# Step 2: Clean and structure the data
df = clean_data(data)

# Step 3: Perform t-tests for a specific band (e.g., 'Delta')
ttest_results_df = perform_ttests(df, 'Delta')
print(ttest_results_df)

# Step 4: Plot the median power across bands
plot_median_across_bands(df)

API Reference

load_data(filepath: str) -> pd.DataFrame

Load the data from a CSV file.

  • Parameters:

    • filepath (str): The path to the CSV file containing the data.
  • Returns:

    • pd.DataFrame: A DataFrame containing the loaded data.

clean_data(data: pd.DataFrame) -> pd.DataFrame

Clean and structure the data into a usable format.

  • Parameters:

    • data (pd.DataFrame): The raw data DataFrame.
  • Returns:

    • pd.DataFrame: A cleaned and structured DataFrame.

perform_ttests(data: pd.DataFrame, band: str) -> pd.DataFrame

Perform paired t-tests for a given frequency band.

  • Parameters:

    • data (pd.DataFrame): The cleaned data DataFrame.
    • band (str): The frequency band to analyze (e.g., 'Delta').
  • Returns:

    • pd.DataFrame: A DataFrame containing the t-test results for each subject and comparison.

plot_median_across_bands(data: pd.DataFrame)

Plot the median power across different states for each frequency band.

  • Parameters:
    • data (pd.DataFrame): The cleaned data DataFrame.

Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

eeg_analysis-0.1.3.tar.gz (157.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eeg_analysis-0.1.3-py3-none-any.whl (157.8 kB view details)

Uploaded Python 3

File details

Details for the file eeg_analysis-0.1.3.tar.gz.

File metadata

  • Download URL: eeg_analysis-0.1.3.tar.gz
  • Upload date:
  • Size: 157.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for eeg_analysis-0.1.3.tar.gz
Algorithm Hash digest
SHA256 244cd3e766ea01c588b4630108925449079309338e73124fb52bddbb5e63abeb
MD5 0cdd4066c3190e9001b0b28c75236512
BLAKE2b-256 1b9b39f1ca68c9ccb2671d44b95def1d907764d351950510fdbbdae2a1ddb62c

See more details on using hashes here.

File details

Details for the file eeg_analysis-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: eeg_analysis-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 157.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for eeg_analysis-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 406a8df18c786a149d786be6e155f154e2f2a3c66b2c5b78ca97418abb151f2c
MD5 3d92914da65f9e94f31e31e73460f778
BLAKE2b-256 7d826b2ec6815cd6ffea6313aa8687716de83d41fd54fa5833d22719afac6aa2

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