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


import numpy as np
from ..Common import errors

Created by: Ankit Khambhati

Change Log
----------
2016/11/11 - Implemented common_avg_ref
"""

from __future__ import division



def common_avg_ref(data):
    """
    The common_avg_ref function subtracts the common mode signal from the original
    signal. Suggested for removing correlated noise, broadly over a sensor array.

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

    Returns
    -------
        data_reref: ndarray, shape (T, N)
            Referenced signal with common mode removed
    """

    # 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
import numpy as np
from ..Common import errors


Created by: Ankit Khambhati

Change Log
----------
2016/11/11 - Implemented common_avg_ref
"""

from __future__ import division



def common_avg_ref(data):
    """
    The common_avg_ref function subtracts the common mode signal from the original
    signal. Suggested for removing correlated noise, broadly over a sensor array.

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

    Returns
    -------
        data_reref: ndarray, shape (T, N)
            Referenced signal with common mode removed
    """

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

    errors.check_dims(data, 2)