-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
56 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Add :meth:`~mne.Epochs.compute_sme` to compute the analytical standardized measurement error (SME) as a data quality measure for ERP studies, by `Clemens Brunner`_. | ||
Add :func:`~mne.stats.erp.compute_sme` to compute the analytical standardized measurement error (SME) as a data quality measure for ERP studies, by `Clemens Brunner`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import numpy as np | ||
|
||
from mne.utils import _validate_type | ||
|
||
|
||
def compute_sme(epochs, start=None, stop=None): | ||
"""Compute standardized measurement error (SME). | ||
The standardized measurement error :footcite:`LuckEtAl2021` can be used as a | ||
universal measure of data quality in ERP studies. | ||
Parameters | ||
---------- | ||
start : int | float | None | ||
Start time (in s) of the time window used for SME computation. If ``None``, use | ||
the start of the epoch. | ||
stop : int | float | None | ||
Stop time (in s) of the time window used for SME computation. If ``None``, use | ||
the end of the epoch. | ||
Returns | ||
------- | ||
sme : array, shape (n_channels,) | ||
SME in given time window for each channel. | ||
Notes | ||
----- | ||
Currently, only the mean value in the given time window is supported, meaning that | ||
the resulting SME is only valid in studies which quantify the amplitude of an ERP | ||
component as the mean within the time window (as opposed to e.g. the peak, which | ||
would require bootstrapping). | ||
References | ||
---------- | ||
.. footbibliography:: | ||
""" | ||
_validate_type(start, ("numeric", None), "start", "int or float") | ||
_validate_type(stop, ("numeric", None), "stop", "int or float") | ||
start = epochs.tmin if start is None else start | ||
stop = epochs.tmax if stop is None else stop | ||
if start < epochs.tmin: | ||
raise ValueError("start is out of bounds.") | ||
if stop > epochs.tmax: | ||
raise ValueError("stop is out of bounds.") | ||
|
||
data = epochs.get_data(tmin=start, tmax=stop) | ||
return data.mean(axis=2).std(axis=0) / np.sqrt(data.shape[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters