Skip to content

Commit

Permalink
Add README & LICENSE. Fix import.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackz314 committed Apr 1, 2021
1 parent 25f1b79 commit ce1ffcd
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 37 deletions.
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021, Jack Zhang
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# eeglabio

Python I/O support for EEGLAB files
Python I/O support for EEGLAB files

### Installation

Install from [PyPI](https://test.pypi.org/project/eeglabio):

```
pip install -i https://test.pypi.org/simple/ eeglabio
```

### Dependencies

eeglabio requires Python >= 3.6 and the following packages:
* [mne](https://github.com/mne-tools/mne-python)
* [numpy](http://numpy.org/)
* [scipy](https://www.scipy.org/)

### Usage

Export from MNE [`Epochs`](https://mne.tools/stable/generated/mne.Epochs.html) to EEGLAB (`.set`):
```python
import mne
from eeglabio.epochs import export_set
epochs = mne.Epochs(...)
export_set(epochs, "file_name.set")
```

Export from MNE [`Raw`](https://mne.tools/stable/generated/mne.io.Raw.html) to EEGLAB (`.set`):
```python
import mne
from eeglabio.raw import export_set
raw = mne.io.read_raw(...)
export_set(raw, "file_name.set")
```
2 changes: 1 addition & 1 deletion eeglabio/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The version number."""

__version__ = '0.0.1'
__version__ = '0.0.1-1'
2 changes: 1 addition & 1 deletion eeglabio/epochs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from numpy.core.records import fromarrays
from scipy.io import savemat
from utils import _get_eeglab_full_cords
from .utils import _get_eeglab_full_cords


def export_set(inst, fname):
Expand Down
2 changes: 1 addition & 1 deletion eeglabio/raw.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from numpy.core.records import fromarrays
from scipy.io import savemat
from utils import _get_eeglab_full_cords
from .utils import _get_eeglab_full_cords


def export_set(inst, fname):
Expand Down
9 changes: 5 additions & 4 deletions eeglabio/tests/test_epochs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from pathlib import Path
import pytest
from epochs import export_set
from mne import read_events, pick_types, Epochs, read_epochs_eeglab
from mne.io import read_raw_fif
from os import path as op
import numpy as np
from numpy.testing import assert_allclose, assert_array_equal

from eeglabio.epochs import export_set

raw_fname = Path(__file__).parent / "data" / "test_raw.fif"
event_name = Path(__file__).parent / "data" / 'test-eve.fif'

Expand All @@ -33,12 +34,12 @@ def test_export_set(tmpdir, preload):
epochs_read = read_epochs_eeglab(temp_fname)
assert epochs.ch_names == epochs_read.ch_names
cart_coords = np.array([d['loc'][:3]
for d in epochs.info['chs']]) # just xyz
for d in epochs.info['chs']]) # just xyz
cart_coords_read = np.array([d['loc'][:3]
for d in epochs_read.info['chs']])
for d in epochs_read.info['chs']])
assert_allclose(cart_coords, cart_coords_read)
assert_array_equal(epochs.events[:, 0],
epochs_read.events[:, 0]) # latency
assert epochs.event_id.keys() == epochs_read.event_id.keys() # just keys
assert_allclose(epochs.times, epochs_read.times)
assert_allclose(epochs.get_data(), epochs_read.get_data())
assert_allclose(epochs.get_data(), epochs_read.get_data())
4 changes: 2 additions & 2 deletions eeglabio/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
from mne.io import read_raw_fif, read_raw_eeglab
from numpy.testing import assert_allclose
from raw import export_set
from utils_tests import _TempDir

from eeglabio.raw import export_set

raw_fname = Path(__file__).parent / "data" / "test_raw.fif"

Expand Down
24 changes: 0 additions & 24 deletions eeglabio/utils_tests.py

This file was deleted.

8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
with open("requirements.txt") as f:
requires = f.read().splitlines()

GITHUB_URL = "https://github.com/jackz314/eeglabio"
setuptools.setup(
name="eeglabio",
version=version,
Expand All @@ -25,10 +26,11 @@
license="BSD (3-clause)",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/jackz314/pyeeglab",
url=GITHUB_URL,
download_url=GITHUB_URL,
project_urls={
"Source": "https://github.com/jackz314/pyeeglab",
"Tracker": "https://github.com/jackz314/pyeeglab/issues",
"Source": GITHUB_URL,
"Tracker": GITHUB_URL + '/issues',
},
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit ce1ffcd

Please sign in to comment.