Metadata-Version: 2.1
Name: ensemble_eeg
Version: 0.1.2
Summary: Package used to analyze preprocess edf files for the ENSEMBLE2 study
Author: Bauke van der Velde
Author-email: Bauke van der Velde <b.vandervelde-3@umcutrecht.nl>
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >3.1
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy
Requires-Dist: defusedxml

<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![PyPI version](https://badge.fury.io/py/ensemble-eeg.svg)](https://badge.fury.io/py/ensemble-eeg)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

<!-- TABLE OF CONTENTS -->
<details>
  <summary>Table of Contents</summary>
  <ol>
    <li>
      <a href="#about-the-project">ENSEMBLE EEG</a>
    </li>
    <li>
      <a href="#getting-started">Getting Started</a>
      <ul>
        <li><a href="#prerequisites">Prerequisites</a></li>
        <li><a href="#installation">Installation</a></li>
      </ul>
    </li>
    <li><a href="#usage">Usage</a></li>
    <li><a href="#acknowledgments">Acknowledgments</a></li>
  </ol>
</details>


<!-- ABOUT THE PROJECT -->
# ENSEMBLE EEG
Ensemble EEG is a library of EEG analyis tools for the ENSEMBLE study. As of
today it is focuses on 5 seperate things:

- **Anonymizing** EDF files in accordance with the ENSEMBLE study and the
  requirements of [EDF+](https://www.edfplus.info/specs/edfplus.html)
- **Fixing** EDF headers to adhere to the [EDF+](https://www.edfplus.info/specs/edfplus.html) standard
- **Converting** BRM to [EDF+](https://www.edfplus.info/specs/edfplus.html) files
- **Combining** seperate aEEG channels into one [EDF+](https://www.edfplus.info/specs/edfplus.html) file
- **Renaming** EEG files according to ENSEMBLE and [BIDS](https://bids-specification.readthedocs.io/en/stable/) standards

<!-- GETTING STARTED -->
## 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](https://github.com/PackeTsar/Install-Python/blob/master/README.md)

### Installation
```sh
python3 -m pip install ensemble_eeg
```

<!-- USAGE EXAMPLES -->
## 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](https://jupyter.org/install)
   2) [PyCharm](https://www.jetbrains.com/help/pycharm/installation-guide.html#standalone)
   3) [Spyder](https://docs.spyder-ide.org/current/installation.html)

#### Anonymizing EDF-files
```python
from ensemble_eeg import ensemble_edf
ensemble_edf.anonymize_edf_header('path/2/your/edf/file')
```
#### Fixing EDF headers
```python
from ensemble_eeg import ensemble_edf
ensemble_edf.fix_edf_header('path/2/your/edf/file')
```
#### Combine left and right aEEG channels into one single file
```python
from ensemble_eeg import ensemble_edf
ensemble_edf.combine_aeeg_channels('path/2/your/left/channel', 'path/2/your/right/channel', 'new_filename')
```
#### Rename EDF-files according to BIDS and ENSEMBLE standards
```python
from ensemble_eeg import ensemble_edf
ensemble_edf.rename_for_ensemble('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
```python
from ensemble_eeg import ensemble_edf
file = 'path/2/your/edf/file'
ensemble_edf.fix_edf_header(file)       # for header check
ensemble_edf.anonymize_edf_header(file) # for anonymization
ensemble_edf.rename_for_ensemble(file)  # for renaming

```
##### 2) File is .brm 
```python
from ensemble_eeg import brm_to_edf
from ensemble_eeg import ensemble_edf
brm_file = '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) Files are .edf, but left and right channel are seperate 
```python
from ensemble_eeg import ensemble_edf
left_file = 'path/2/your/left/edf/file'
right_file = 'path/2/your/right/edf/file'
ensemble_edf.combine_aeeg_channels(left_file, right_file) # output is automatically anonymized
ensemble_edf.rename_for_ensemble(file)                    # for renaming

```
##### 4) Anonymize multiple .edf files in the same directory 
```python
from ensemble_eeg import ensemble_edf
import glob
import os
edf_directory = 'path/2/your/left/edf/directory'
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) 
      ensemble_edf.rename_for_ensemble(file)                    
```
##### 5) Convert multiple .brm files in the same directory 
```python
from ensemble_eeg import brm_to_edf
import glob
import os
brm_directory = 'path/2/your/left/edf/directory'
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](demos) folder
<!-- ACKNOWLEDGMENTS -->
## Acknowledgements
- [edfrd](https://github.com/somnonetz/edfrd)
- [Install-Python-Instructions](https://github.com/PackeTsar/Install-Python/tree/master)
