diff --git a/README.md b/README.md index 94305f5..70c6b9e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ -Note: The old braindecode repository has been moved to https://github.com/robintibor/braindevel. +Note: The old braindecode repository has been moved to +https://github.com/robintibor/braindevel. + +Braindecode +=========== -# Braindecode A deep learning for raw time-domain EEG decoding toolbox. + +Installation +============ + +Install pytorch from http://pytorch.org/. + +Documentation +============= + +Documentation is online under http://braindecode.readthedocs.io/ diff --git a/braindecode/modules/__init__.py b/braindecode/datasets/__init__.py similarity index 100% rename from braindecode/modules/__init__.py rename to braindecode/datasets/__init__.py diff --git a/braindecode/datasets/signal_target.py b/braindecode/datasets/signal_target.py new file mode 100644 index 0000000..df87b3f --- /dev/null +++ b/braindecode/datasets/signal_target.py @@ -0,0 +1,20 @@ +class SignalAndTarget(object): + def __init__(self, X, y): + assert len(X) == len(y) + self.X = X + self.y = y + + +def apply_to_X_y(fn, *sets): + X = fn(*[s.X for s in sets]) + y = fn(*[s.y for s in sets]) + return SignalAndTarget(X,y) + + +def split_into_two_sets(dataset, fraction=None, n_boundary=None): + assert fraction is not None or n_boundary is not None + if n_boundary is None: + n_boundary = int(round(len(dataset.X) * fraction)) + first_set = apply_to_X_y(lambda a: a[:n_boundary], dataset) + second_set = apply_to_X_y(lambda a: a[n_boundary:], dataset) + return first_set, second_set diff --git a/braindecode/iterators.py b/braindecode/iterators.py index 506d792..b6eb0e2 100644 --- a/braindecode/iterators.py +++ b/braindecode/iterators.py @@ -1,6 +1,7 @@ import numpy as np from numpy.random import RandomState + def get_balanced_batches(n_trials, rng, shuffle, n_batches=None, batch_size=None): """Create indices for batches balanced in size (batches will have maximum size difference of 1). diff --git a/braindecode/models/shallow_fbcsp.py b/braindecode/models/shallow_fbcsp.py index 54bef1a..397f345 100644 --- a/braindecode/models/shallow_fbcsp.py +++ b/braindecode/models/shallow_fbcsp.py @@ -2,7 +2,7 @@ from torch import nn from torch.nn import init -from braindecode.modules.expression import Expression +from braindecode.torchext.modules import Expression from braindecode.torchext.functions import safe_log, square from braindecode.torchext.util import np_to_var diff --git a/braindecode/modules/expression.py b/braindecode/torchext/modules.py similarity index 100% rename from braindecode/modules/expression.py rename to braindecode/torchext/modules.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..12d2d01 --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +from setuptools import setup # Always prefer setuptools over distutils +from codecs import open # To use a consistent encoding +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the relevant file +with open(path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = f.read() + + +setup( + name='Braindecode', + + # Versions should comply with PEP440. For a discussion on single-sourcing + # the version across setup.py and the project code, see + # http://packaging.python.org/en/latest/tutorial.html#version + version='0.1.1', + + description='A deep learning for raw time-domain EEG decoding toolbox.', + long_description=long_description, #this is the + + # The project's main homepage. + url='https://github.com/robintibor/braindecode', + + # Author details + author='Robin Tibor Schirrmeister', + author_email='robintibor@gmail.com', + + # Choose your license + license='BSD 3-Clause', + + install_requires=['numpy','mne'], + #tests_require = [...] + + # See https://PyPI.python.org/PyPI?%3Aaction=list_classifiers + classifiers=[ + 'Development Status :: 3 - Alpha', + + # Indicate who your project is intended for + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + 'Topic :: Software Development :: Build Tools', + + "Topic :: Scientific/Engineering :: Artificial Intelligence", + + # Pick your license as you wish (should match "license" above) + 'License :: OSI Approved :: BSD License', + + # Specify the Python versions you support here. In particular, ensure + # that you indicate whether you support Python 2, Python 3 or both. + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.5', + ], + + # What does your project relate to? + keywords='eeg deep-learning brain-state-decoding', + + packages=['braindecode'], + +)