avg_no_outlier

avg_no_outlier(data: ndarray, outliers: float = None, keep: ndarray[bool] = None) ndarray[source][source]

Calculate the average of data without trial outliers.

This function calculates the average of data without trial outliers. Outliers are defined as any trial with a maximum value greater than the mean plus outliers times the standard deviation. The function returns the average of data without outliers.

Parameters:
  • data (np.ndarray) – Data to calculate average of.

  • outliers (float) – Number of standard deviations from the mean to consider an outlier.

  • keep (np.ndarray[bool]) – Boolean array with True for trials that are not outliers and False for trials that are outliers.

Returns:

Average of data without outliers.

Return type:

np.ndarray

Examples

>>> import mne
>>> mne.set_log_file(None)
>>> data = np.array([[[1, 1, 1, 1, 1], [0, 60, 0, 10, 0]]]).T
>>> avg_no_outlier(data, 1)
Removed Trial 0 in Channel 0
Removed Trial 1 in Channel 0
Removed Trial 1 in Channel 1
Removed Trial 2 in Channel 0
Removed Trial 3 in Channel 0
Removed Trial 4 in Channel 0
array([[nan],
       [2.5]])
>>> avg_no_outlier(data, 3)
Removed Trial 0 in Channel 0
Removed Trial 1 in Channel 0
Removed Trial 2 in Channel 0
Removed Trial 3 in Channel 0
Removed Trial 4 in Channel 0
array([[nan],
       [14.]])