# Path: scot/datasets.py
# def fetch(dataset="mi", datadir=datadir):
#     """Fetch example dataset.
# 
#     If the requested dataset is not found in the location specified by
#     `datadir`, the function attempts to download it.
# 
#     Parameters
#     ----------
#     dataset : str
#         Which dataset to load. Currently only 'mi' is supported.
#     datadir : str
#         Path to the storage location of example datasets. Datasets are
#         downloaded to this location if they cannot be found. If the directory
#         does not exist it is created.
# 
#     Returns
#     -------
#         data : list of dicts
#             The data set is stored in a list, where each list element
#             corresponds to data from one subject. Each list element is a
#             dictionary with the following keys:
#               "eeg" ... EEG signals
#               "triggers" ... Trigger latencies
#               "labels" ... Class labels
#               "fs" ... Sample rate
#               "locations" ... Channel locations
#     """
#     if dataset not in datasets:
#         raise ValueError("Example data '{}' not available.".format(dataset))
#     else:
#         files = datasets[dataset]["files"]
#         url = datasets[dataset]["url"]
#         md5 = datasets[dataset]["md5"]
#     if not isdir(datadir):
#         makedirs(datadir)
# 
#     data = []
# 
#     for n, filename in enumerate(files):
#         fullfile = join(datadir, filename)
#         if not isfile(fullfile):
#             with open(fullfile, "wb") as f:
#                 response = get(join(url, filename))
#                 f.write(response.content)
#         with open(fullfile, "rb") as f:  # check if MD5 of downloaded file matches original hash
#             hash = hashlib.md5(f.read()).hexdigest()
#         if hash != md5[n]:
#             raise MD5MismatchError("MD5 hash of {} does not match {}.".format(fullfile, md5[n]))
#         data.append(convert(dataset, loadmat(fullfile)))
# 
#     return data


import numpy as np
import scot.xvschema
    from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
    from sklearn.lda import LDA
from sklearn.cross_validation import KFold
from sklearn.metrics import confusion_matrix
from scot.datasets import fetch
"""
This example shows how to decompose EEG signals into source activations with
CSPVARICA, and subsequently extract single-trial connectivity as features for
LDA classification.
"""

from __future__ import print_function

try:  # new in sklearn 0.19
except ImportError:


# The data set contains a continuous 45 channel EEG recording of a motor
# imagery experiment. The data was preprocessed to reduce eye movement
# artifacts and resampled to a sampling rate of 100 Hz. With a visual cue, the
# subject was instructed to perform either hand or foot motor imagery. The
# trigger time points of the cues are stored in 'triggers', and 'classes'
# contains the class labels. Duration of the motor imagery period was
# approximately six seconds.



# Path: scot/datasets.py
# def fetch(dataset="mi", datadir=datadir):
#     """Fetch example dataset.
# 
#     If the requested dataset is not found in the location specified by
#     `datadir`, the function attempts to download it.
# 
#     Parameters
#     ----------
#     dataset : str
#         Which dataset to load. Currently only 'mi' is supported.
#     datadir : str
#         Path to the storage location of example datasets. Datasets are
#         downloaded to this location if they cannot be found. If the directory
#         does not exist it is created.
# 
#     Returns
#     -------
#         data : list of dicts
#             The data set is stored in a list, where each list element
#             corresponds to data from one subject. Each list element is a
#             dictionary with the following keys:
#               "eeg" ... EEG signals
#               "triggers" ... Trigger latencies
#               "labels" ... Class labels
#               "fs" ... Sample rate
#               "locations" ... Channel locations
#     """
#     if dataset not in datasets:
#         raise ValueError("Example data '{}' not available.".format(dataset))
#     else:
#         files = datasets[dataset]["files"]
#         url = datasets[dataset]["url"]
#         md5 = datasets[dataset]["md5"]
#     if not isdir(datadir):
#         makedirs(datadir)
# 
#     data = []
# 
#     for n, filename in enumerate(files):
#         fullfile = join(datadir, filename)
#         if not isfile(fullfile):
#             with open(fullfile, "wb") as f:
#                 response = get(join(url, filename))
#                 f.write(response.content)
#         with open(fullfile, "rb") as f:  # check if MD5 of downloaded file matches original hash
#             hash = hashlib.md5(f.read()).hexdigest()
#         if hash != md5[n]:
#             raise MD5MismatchError("MD5 hash of {} does not match {}.".format(fullfile, md5[n]))
#         data.append(convert(dataset, loadmat(fullfile)))
# 
#     return data


# Path: examples/misc/features.py
import numpy as np
import scot.xvschema
    from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
    from sklearn.lda import LDA
from sklearn.cross_validation import KFold
from sklearn.metrics import confusion_matrix
from scot.datasets import fetch

"""
This example shows how to decompose EEG signals into source activations with
CSPVARICA, and subsequently extract single-trial connectivity as features for
LDA classification.
"""

from __future__ import print_function

try:  # new in sklearn 0.19
except ImportError:


# The data set contains a continuous 45 channel EEG recording of a motor
# imagery experiment. The data was preprocessed to reduce eye movement
# artifacts and resampled to a sampling rate of 100 Hz. With a visual cue, the
# subject was instructed to perform either hand or foot motor imagery. The
# trigger time points of the cues are stored in 'triggers', and 'classes'
# contains the class labels. Duration of the motor imagery period was
# approximately six seconds.



midata = fetch("mi")[0]