# Path: neurokit/eeg/eeg_data.py
# def eeg_select_electrodes(eeg, include="all", exclude=None, hemisphere="both", central=True):
#     """
#     Returns electrodes/sensors names of selected region (according to a 10-20 EEG montage).
# 
#     Parameters
#     ----------
#     eeg : mne.Raw or mne.Epochs
#         EEG data.
#     include : str ot list
#         Sensor area to include.
#     exclude : str or list or None
#         Sensor area to exclude.
#     hemisphere : str
#         Select both hemispheres? "both", "left" or "right".
#     central : bool
#         Select the central line.
# 
#     Returns
#     ----------
#     electrodes : list
#         List of electrodes/sensors corresponding to the selected area.
# 
#     Example
#     ----------
#     >>> import neurokit as nk
#     >>> nk.eeg_select_electrodes(include="F", exclude="C")
# 
# 
#     Notes
#     ----------
#     *Authors*
# 
#     - `Dominique Makowski <https://dominiquemakowski.github.io/>`_
# 
#     """
#     # Get all channel names
#     eeg = eeg.copy().pick_types(meg=False, eeg=True)
#     channel_list = eeg.ch_names
# 
#     # Include
#     if include == "all":
#         electrodes = channel_list
#     elif isinstance(include, str):
#         electrodes = [s for s in channel_list if include in s]
#     elif isinstance(include, list):
#         electrodes = []
#         for i in include:
#             electrodes += [s for s in channel_list if i in s]
#     else:
#         print("NeuroKit Warning: eeg_select_electrodes(): 'include' parameter must be 'all', str or list.")
# 
#     # Exclude
#     if exclude is not None:
#         if isinstance(exclude, str):
#             to_remove = [s for s in channel_list if exclude in s]
#             electrodes = [s for s in electrodes if s not in to_remove]
#         elif isinstance(exclude, list):
#             to_remove = []
#             for i in exclude:
#                 to_remove += [s for s in channel_list if i in s]
#             electrodes = [s for s in electrodes if s not in to_remove]
#         else:
#             print("NeuroKit Warning: eeg_select_electrodes(): 'exclude' parameter must be None, str or list.")
# 
#     # Laterality
#     if hemisphere != "both":
#         if hemisphere.lower() == "left" or hemisphere.lower() == "l":
#             hemi = [s for s in electrodes if len(re.findall(r'\d+', s)) > 0 and int(re.findall(r'\d+', s)[0])%2 > 0]
#         elif hemisphere.lower() == "right" or hemisphere.lower() == "r":
#             hemi = [s for s in electrodes if len(re.findall(r'\d+', s)) > 0 and int(re.findall(r'\d+', s)[0])%2 == 0]
#         else:
#             print("NeuroKit Warning: eeg_select_electrodes(): 'hemisphere' parameter must be 'both', 'left' or 'right'. Returning both.")
# 
#         if central is True:
#             hemi += [s for s in electrodes if 'z' in s]
# 
#         electrodes = hemi
# 
#     return(electrodes)
# 
# Path: neurokit/eeg/eeg_data.py
# def eeg_to_df(eeg, index=None, include="all", exclude=None, hemisphere="both", central=True):
#     """
#     Convert mne Raw or Epochs object to dataframe or dict of dataframes.
# 
#     DOCS INCOMPLETE :(
#     """
#     if isinstance(eeg, mne.Epochs):
#         data = {}
# 
#         if index is None:
#             index = range(len(eeg))
# 
#         for epoch_index, epoch in zip(index, eeg.get_data()):
# 
#             epoch = pd.DataFrame(epoch.T)
#             epoch.columns = eeg.ch_names
#             epoch.index = eeg.times
# 
#             selection = eeg_select_electrodes(eeg, include=include, exclude=exclude, hemisphere=hemisphere, central=central)
# 
#             data[epoch_index] = epoch[selection]
# 
#     else:  # it might be a Raw object
#         data = eeg.get_data().T
#         data = pd.DataFrame(data)
#         data.columns = eeg.ch_names
#         data.index = eeg.times
# 
#     return(data)
# 
# Path: neurokit/eeg/eeg_data.py
# def eeg_to_all_evokeds(all_epochs, conditions=None):
#     """
#     Convert all_epochs to all_evokeds.
# 
#     DOCS INCOMPLETE :(
#     """
#     if conditions is None:
#         # Get event_id
#         conditions = {}
#         for participant, epochs in all_epochs.items():
#             conditions.update(epochs.event_id)
# 
#     all_evokeds = {}
#     for participant, epochs in all_epochs.items():
#         evokeds = {}
#         for cond in conditions:
#             try:
#                 evokeds[cond] = epochs[cond].average()
#             except KeyError:
#                 pass
#         all_evokeds[participant] = evokeds
# 
#     return(all_evokeds)


from .eeg_data import eeg_select_electrodes
from .eeg_data import eeg_to_df
from .eeg_data import eeg_to_all_evokeds
import numpy as np
import pandas as pd
import mne
"""
ERP analysis EEG submodule.
"""






# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
def eeg_erp(eeg, times=None, index=None, include="all", exclude=None, hemisphere="both", central=True, verbose=True, names="ERP", method="mean"):
    """
    DOCS INCOMPLETE :(
    """
    erp = {}


# Path: neurokit/eeg/eeg_data.py
# def eeg_select_electrodes(eeg, include="all", exclude=None, hemisphere="both", central=True):
#     """
#     Returns electrodes/sensors names of selected region (according to a 10-20 EEG montage).
# 
#     Parameters
#     ----------
#     eeg : mne.Raw or mne.Epochs
#         EEG data.
#     include : str ot list
#         Sensor area to include.
#     exclude : str or list or None
#         Sensor area to exclude.
#     hemisphere : str
#         Select both hemispheres? "both", "left" or "right".
#     central : bool
#         Select the central line.
# 
#     Returns
#     ----------
#     electrodes : list
#         List of electrodes/sensors corresponding to the selected area.
# 
#     Example
#     ----------
#     >>> import neurokit as nk
#     >>> nk.eeg_select_electrodes(include="F", exclude="C")
# 
# 
#     Notes
#     ----------
#     *Authors*
# 
#     - `Dominique Makowski <https://dominiquemakowski.github.io/>`_
# 
#     """
#     # Get all channel names
#     eeg = eeg.copy().pick_types(meg=False, eeg=True)
#     channel_list = eeg.ch_names
# 
#     # Include
#     if include == "all":
#         electrodes = channel_list
#     elif isinstance(include, str):
#         electrodes = [s for s in channel_list if include in s]
#     elif isinstance(include, list):
#         electrodes = []
#         for i in include:
#             electrodes += [s for s in channel_list if i in s]
#     else:
#         print("NeuroKit Warning: eeg_select_electrodes(): 'include' parameter must be 'all', str or list.")
# 
#     # Exclude
#     if exclude is not None:
#         if isinstance(exclude, str):
#             to_remove = [s for s in channel_list if exclude in s]
#             electrodes = [s for s in electrodes if s not in to_remove]
#         elif isinstance(exclude, list):
#             to_remove = []
#             for i in exclude:
#                 to_remove += [s for s in channel_list if i in s]
#             electrodes = [s for s in electrodes if s not in to_remove]
#         else:
#             print("NeuroKit Warning: eeg_select_electrodes(): 'exclude' parameter must be None, str or list.")
# 
#     # Laterality
#     if hemisphere != "both":
#         if hemisphere.lower() == "left" or hemisphere.lower() == "l":
#             hemi = [s for s in electrodes if len(re.findall(r'\d+', s)) > 0 and int(re.findall(r'\d+', s)[0])%2 > 0]
#         elif hemisphere.lower() == "right" or hemisphere.lower() == "r":
#             hemi = [s for s in electrodes if len(re.findall(r'\d+', s)) > 0 and int(re.findall(r'\d+', s)[0])%2 == 0]
#         else:
#             print("NeuroKit Warning: eeg_select_electrodes(): 'hemisphere' parameter must be 'both', 'left' or 'right'. Returning both.")
# 
#         if central is True:
#             hemi += [s for s in electrodes if 'z' in s]
# 
#         electrodes = hemi
# 
#     return(electrodes)
# 
# Path: neurokit/eeg/eeg_data.py
# def eeg_to_df(eeg, index=None, include="all", exclude=None, hemisphere="both", central=True):
#     """
#     Convert mne Raw or Epochs object to dataframe or dict of dataframes.
# 
#     DOCS INCOMPLETE :(
#     """
#     if isinstance(eeg, mne.Epochs):
#         data = {}
# 
#         if index is None:
#             index = range(len(eeg))
# 
#         for epoch_index, epoch in zip(index, eeg.get_data()):
# 
#             epoch = pd.DataFrame(epoch.T)
#             epoch.columns = eeg.ch_names
#             epoch.index = eeg.times
# 
#             selection = eeg_select_electrodes(eeg, include=include, exclude=exclude, hemisphere=hemisphere, central=central)
# 
#             data[epoch_index] = epoch[selection]
# 
#     else:  # it might be a Raw object
#         data = eeg.get_data().T
#         data = pd.DataFrame(data)
#         data.columns = eeg.ch_names
#         data.index = eeg.times
# 
#     return(data)
# 
# Path: neurokit/eeg/eeg_data.py
# def eeg_to_all_evokeds(all_epochs, conditions=None):
#     """
#     Convert all_epochs to all_evokeds.
# 
#     DOCS INCOMPLETE :(
#     """
#     if conditions is None:
#         # Get event_id
#         conditions = {}
#         for participant, epochs in all_epochs.items():
#             conditions.update(epochs.event_id)
# 
#     all_evokeds = {}
#     for participant, epochs in all_epochs.items():
#         evokeds = {}
#         for cond in conditions:
#             try:
#                 evokeds[cond] = epochs[cond].average()
#             except KeyError:
#                 pass
#         all_evokeds[participant] = evokeds
# 
#     return(all_evokeds)


# Path: neurokit/eeg/eeg_erp.py
from .eeg_data import eeg_select_electrodes
from .eeg_data import eeg_to_df
from .eeg_data import eeg_to_all_evokeds
import numpy as np
import pandas as pd
import mne

"""
ERP analysis EEG submodule.
"""






# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
# ==============================================================================
def eeg_erp(eeg, times=None, index=None, include="all", exclude=None, hemisphere="both", central=True, verbose=True, names="ERP", method="mean"):
    """
    DOCS INCOMPLETE :(
    """
    erp = {}


    data = eeg_to_df(eeg, index=index, include=include, exclude=exclude, hemisphere=hemisphere, central=central)