find_outliers¶
- find_outliers(data: ~numpy.ndarray, outliers: float, deviation: callable = <function std>, center: callable = <function mean>) ndarray[bool][source][source]¶
Find outliers in data matrix.
This function finds outliers in a data matrix. Outliers are defined as any trial with a maximum value greater than the mean plus outliers times the standard deviation. The function returns a boolean array with True for trials that are not outliers and False for trials that are outliers.
- Parameters:
data (
np.ndarray) – Data to find outliers in. (trials X channels X (frequency) X time)outliers (
float) – Number of deviations from the mean to consider an outlier.deviation (
callable, optional) – Metric function to determine the deviation from the center. Default is median absolute deviation.center (
callable, optional) – Metric function to determine the center of the data. Default is median.
- Returns:
Boolean array with True for trials that are not outliers and False for trials that are outliers.
- Return type:
np.ndarray[bool]
Examples
>>> import numpy as np >>> data = np.array([[1, 1, 1, 1, 1], [0, 60, 0, 10, 0]]).T >>> find_outliers(data, 1) array([ True, False, True, True, True]) >>> find_outliers(data, 10) array([ True, True, True, True, True]) >>> find_outliers(data, 0.1) array([ True, False, True, False, True]) >>> find_outliers(data, 0.1, np.std) array([ True, False, True, False, True]) >>> data = np.array([[1, 1, np.nan, 1, 1], [0, 60, 0, 10, 0]]).T >>> find_outliers(data, 0.1, st.median_abs_deviation) array([ True, False, True, False, True])