Skip to main content

Package used to analyze preprocess EDF files for the ENSEMBLE study

Project description

PyPI version License: GPL v3

ENSEMBLE EEG

Ensemble EEG is a library of EEG analysis tools for the ENSEMBLE study. As of today it is focuses on 5 separate things:

  • Anonymizing EDF files in accordance with the ENSEMBLE study and the requirements of EDF+
  • Fixing EDF headers to adhere to the EDF+ standard
  • Converting BRM to EDF+ files
  • Combining separate aEEG channels into one EDF+ file
  • Renaming EEG files according to ENSEMBLE and BIDS standards

Getting started

Prerequisites

The following is required for the use of this software

  • Python 3.10 & pip
    • For instructions, please refer to the following link

Installation

python -m pip install ensemble_eeg

Usage

Start python

  1. From command line
    1. Open cmd / terminal / powershell or your preferred command line interpreter
    2. Type python or python3
  2. Using your preferred python interpreter
    1. Jupyter notebook
    2. PyCharm
    3. Spyder

Anonymizing EDF-files

from ensemble_eeg import ensemble_edf
ensemble_edf.anonymize_edf_header("path/2/your/edf/file") # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")

Fixing EDF headers

from ensemble_eeg import ensemble_edf
ensemble_edf.fix_edf_header("path/2/your/edf/file") # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")

Combine left and right aEEG channels into one single file

from ensemble_eeg import ensemble_edf
ensemble_edf.combine_aeeg_channels('path/2/your/left/channel', 'path/2/your/right/channel', 'new_filename') # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")

Rename EDF-files according to BIDS and ENSEMBLE standards

from ensemble_eeg import ensemble_edf
ensemble_edf.rename_for_ensemble('path/2/your/edf/file') # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")

Example scripts for specific situations

1) File is already .edf, but you do not know whether header is EDF+, the file is not anonymized, and not renamed
from ensemble_eeg import ensemble_edf
file = 'path/2/your/edf/file' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
ensemble_edf.fix_edf_header(file)       # for header check
ensemble_edf.anonymize_edf_header(file) # for anonymization

anonymized_file = 'path/2/your/anonymized/edf/file' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
ensemble_edf.rename_for_ensemble(file)  # for renaming
2) Your file is .brm and you want to convert it to .edf
from ensemble_eeg import brm_to_edf
from ensemble_eeg import ensemble_edf
brm_file = 'path/2/your/brm/file' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/brm/file")
brm_to_edf.convert_brm_to_edf(brm_file)     # for conversion, output edf is already anonymized
edf_file = 'path/2/your/edf/file'           # check which file was made in previous step
ensemble_edf.rename_for_ensemble(edf_file)  # for renaming
3) Your files are .edf, but left and right channels are separate
from ensemble_eeg import ensemble_edf
left_file = 'path/2/your/left/edf/file' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
right_file = 'path/2/your/right/edf/file' # for windows, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
ensemble_edf.combine_aeeg_channels(left_file, right_file) # output is automatically anonymized
ensemble_edf.rename_for_ensemble(file)                    # for renaming
4) You want to anonymize multiple .edf files in the same directory
from ensemble_eeg import ensemble_edf
import glob
import os
edf_directory = 'path/2/your/left/edf/directory' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
edf_files = glob.glob(os.path.join(edf_directory, "*.edf"))
for file in edf_files:
      ensemble_edf.fix_edf_header(file)
      ensemble_edf.anonymize_edf_header(file)

      anonymized_filename = Path(file).stem + "_ANONYMIZED" + Path(file).suffix
      ensemble_edf.rename_for_ensemble(anonymized_filename)
5) You want to convert multiple .brm files in the same directory
from ensemble_eeg import brm_to_edf
import glob
import os
brm_directory = 'path/2/your/left/edf/directory' # for windows users, type an r before the " to ensure the use of raw strings (r"path/2/your/edf/file")
brm_files = glob.glob(os.path.join(brm_directory, "*.brm"))
for file in brm_files:
      brm_to_edf.convert_brm_to_edf(file)

For more scripts, please refer to the demos folder

Acknowledgements

Software development has been funded by La Fondation Paralysie Cérébrale under grant ENSEMBLE.

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

ensemble_eeg-0.2.0.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

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

ensemble_eeg-0.2.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file ensemble_eeg-0.2.0.tar.gz.

File metadata

  • Download URL: ensemble_eeg-0.2.0.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ensemble_eeg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b10d2156afec7e2e32560f854fdc9b552a9ec7b2ce1d800d97c0f6a4b4373137
MD5 36d36f325e7f7177b934e95894f37881
BLAKE2b-256 167ebdaba399c1a624dadef161ba201e849aba5e132688109f68a7de03000c5a

See more details on using hashes here.

File details

Details for the file ensemble_eeg-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ensemble_eeg-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ensemble_eeg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e73506272e81bef791d0bc410b0246be09a2b9d0de691c5bff49a0b2ccaaf37d
MD5 4361cdc53f9ab45e50edfc4ee6434213
BLAKE2b-256 8d2fbc0e50817ee6467bb9ee494e1d32a46564535ca8c5d951fee8a036b7e23f

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