# Path: Echobase/Common/errors.py
# def check_dims(arr, nd):
# def check_type(obj, typ):
# def check_function(obj):
# def check_path(path):
# def make_path(path):
# def check_path_overwrite(path):
# def check_has_key(dictionary, key_ref):
# 
# Path: Echobase/Sigproc/reref.py
# def common_avg_ref(data):
# 
# Path: Echobase/Sigproc/prewhiten.py
# def ar_one(data):
# 
# Path: Echobase/Sigproc/filters.py
# def elliptic(data, fs, wpass, wstop, gpass, gstop):
# 
# Path: Echobase/Network/Functional/correlation.py
# def xcorr_mag(data, fs, tau):
# def xcorr(data, fs, tau):
# 
# Path: Echobase/Network/Functional/coherence.py
# def multitaper(data, fs, time_band, n_taper, cf):


import numpy as np
from ..Common import errors
from ..Sigproc import reref, prewhiten, filters
from ..Network.Functional import correlation, coherence

    # Standard param checks
    errors.check_type(data, np.ndarray)
    errors.check_dims(data, 2)
    errors.check_type(fs, int)

    # Parameter set
    param = {}
    param['Notch_60Hz'] = {'wpass': [58.0, 62.0],
                           'wstop': [59.0, 61.0],
                           'gpass': 0.1,
                           'gstop': 60.0}
    param['HPF_5Hz'] = {'wpass': [5.0],
                        'wstop': [4.0],
                        'gpass': 0.1,
                        'gstop': 60.0}
    param['LPF_115Hz'] = {'wpass': [115.0],
                          'wstop': [120.0],
                          'gpass': 0.1,
                          'gstop': 60.0}
    param['XCorr'] = {'tau': 0.25}

    # Build pipeline
    if avgref:
        data_hat = reref.common_avg_ref(data)
    else:
        data_hat = data.copy()
    data_hat = prewhiten.ar_one(data_hat)
    data_hat = filters.elliptic(data_hat, fs, **param['Notch_60Hz'])
    data_hat = filters.elliptic(data_hat, fs, **param['HPF_5Hz'])

# Path: Echobase/Common/errors.py
# def check_dims(arr, nd):
# def check_type(obj, typ):
# def check_function(obj):
# def check_path(path):
# def make_path(path):
# def check_path_overwrite(path):
# def check_has_key(dictionary, key_ref):
# 
# Path: Echobase/Sigproc/reref.py
# def common_avg_ref(data):
# 
# Path: Echobase/Sigproc/prewhiten.py
# def ar_one(data):
# 
# Path: Echobase/Sigproc/filters.py
# def elliptic(data, fs, wpass, wstop, gpass, gstop):
# 
# Path: Echobase/Network/Functional/correlation.py
# def xcorr_mag(data, fs, tau):
# def xcorr(data, fs, tau):
# 
# Path: Echobase/Network/Functional/coherence.py
# def multitaper(data, fs, time_band, n_taper, cf):


# Path: Echobase/Pipelines/ecog_network.py
import numpy as np
from ..Common import errors
from ..Sigproc import reref, prewhiten, filters
from ..Network.Functional import correlation, coherence


    # Standard param checks
    errors.check_type(data, np.ndarray)
    errors.check_dims(data, 2)
    errors.check_type(fs, int)

    # Parameter set
    param = {}
    param['Notch_60Hz'] = {'wpass': [58.0, 62.0],
                           'wstop': [59.0, 61.0],
                           'gpass': 0.1,
                           'gstop': 60.0}
    param['HPF_5Hz'] = {'wpass': [5.0],
                        'wstop': [4.0],
                        'gpass': 0.1,
                        'gstop': 60.0}
    param['LPF_115Hz'] = {'wpass': [115.0],
                          'wstop': [120.0],
                          'gpass': 0.1,
                          'gstop': 60.0}
    param['XCorr'] = {'tau': 0.25}

    # Build pipeline
    if avgref:
        data_hat = reref.common_avg_ref(data)
    else:
        data_hat = data.copy()
    data_hat = prewhiten.ar_one(data_hat)
    data_hat = filters.elliptic(data_hat, fs, **param['Notch_60Hz'])
    data_hat = filters.elliptic(data_hat, fs, **param['HPF_5Hz'])

    data_hat = filters.elliptic(data_hat, fs, **param['LPF_115Hz'])