# 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):


import numpy as np
from ..Common import errors
from ..Sigproc import reref, prewhiten, filters
from mtspec import mtspec

def multiband(data, fs, avgref=True):
    """
    Pipeline function for computing the power spectral density of ECoG
    using multitaper spectral estimation.

    Data --> CAR Filter --> Multitaper power spectral density

    Parameters
    ----------
        data: ndarray, shape (T, N)
            Input signal with T samples over N variates

        fs: int
            Sampling frequency

        reref: True/False
            Re-reference data to the common average (default: True)

    Returns
    -------
        freq: ndarray, shape (F,)
            Range of frequencies over which power spectrum is being measured.

        powerspec: ndarray, shape (F, N)
            Power spectral density across F frequencies for N variates.
    """

    # Standard param checks
    errors.check_type(data, np.ndarray)

# 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/Pipelines/ecog_powerspec.py
import numpy as np
from ..Common import errors
from ..Sigproc import reref, prewhiten, filters
from mtspec import mtspec


def multiband(data, fs, avgref=True):
    """
    Pipeline function for computing the power spectral density of ECoG
    using multitaper spectral estimation.

    Data --> CAR Filter --> Multitaper power spectral density

    Parameters
    ----------
        data: ndarray, shape (T, N)
            Input signal with T samples over N variates

        fs: int
            Sampling frequency

        reref: True/False
            Re-reference data to the common average (default: True)

    Returns
    -------
        freq: ndarray, shape (F,)
            Range of frequencies over which power spectrum is being measured.

        powerspec: ndarray, shape (F, N)
            Power spectral density across F frequencies for N variates.
    """

    # Standard param checks
    errors.check_type(data, np.ndarray)

    errors.check_dims(data, 2)