pyprep.Reference¶
- class pyprep.Reference(raw, params, ransac=True, channel_wise=False, max_chunk_size=None, random_state=None, matlab_strict=False)[source]¶
Bases:
object
Estimate the ‘true’ reference with all the bad channels interpolated.
This class implements the functionality of the performReference function as part of the PREP (preprocessing pipeline) for EEG data described in [1].
- Parameters:
- raw
mne.io.Raw
The raw data.
- params
dict
Parameters of PREP which include at least the following keys: -
ref_chs
-reref_chs
- ransacbool,
optional
Whether or not to use RANSAC for noisy channel detection in addition to the other methods in
NoisyChannels
. Defaults to True.- channel_wisebool,
optional
Whether RANSAC should predict signals for chunks of channels over the entire signal length (“channel-wise RANSAC”, see max_chunk_size parameter). If
False
, RANSAC will instead predict signals for all channels at once but over a number of smaller time windows instead of over the entire signal length (“window-wise RANSAC”). Channel-wise RANSAC generally has higher RAM demands than window-wise RANSAC (especially if max_chunk_size isNone
), but can be faster on systems with lots of RAM to spare. Has no effect if not using RANSAC. Defaults toFalse
.- max_chunk_size{
int
,None
},optional
The maximum number of channels to predict at once during channel-wise RANSAC. If
None
, RANSAC will use the largest chunk size that will fit into the available RAM, which may slow down other programs on the host system. If using window-wise RANSAC (the default) or not using RANSAC at all, this parameter has no effect. Defaults toNone
.- random_state{
int
,None
,np.random.RandomState
},optional
The random seed at which to initialize the class. If random_state is an int, it will be used as a seed for RandomState. If None, the seed will be obtained from the operating system (see RandomState for details). Default is None.
- matlab_strictbool,
optional
Whether or not PyPREP should strictly follow MATLAB PREP’s internal math, ignoring any improvements made in PyPREP over the original code. Defaults to False.
- raw
References
[1]Bigdely-Shamlo, N., Mullen, T., Kothe, C., Su, K. M., Robbins, K. A. (2015). The PREP pipeline: standardized preprocessing for large-scale raw analysis. Frontiers in Neuroinformatics, 9, 16.
- perform_reference(max_iterations=4)[source]¶
Estimate the true signal mean and interpolate bad channels.
- Parameters:
- max_iterations
int
,optional
The maximum number of iterations of noisy channel removal to perform during robust referencing. Defaults to
4
.- This function implements the functionality of the `performReference` function
- as part of the PREP pipeline on mne raw object.
- max_iterations
Notes
This function calls
robust_reference
first. Currently this function only implements the functionality of default settings, i.e.,doRobustPost
.
- static remove_reference(signal, reference, index=None)[source]¶
Remove the reference signal from the original EEG signal.
This function implements the functionality of the removeReference function as part of the PREP pipeline on mne raw object.
- Parameters:
- signal
np.ndarray
, shape(channels
,times
) The original EEG signal.
- reference
np.ndarray
, shape(times,) The reference signal.
- index{
list
,None
},optional
A list of channel indices from which the reference signal should be subtracted. Defaults to all channels in signal.
- signal
- Returns:
np.ndarray
, shape(channels
,times
)The referenced EEG signal.
- robust_reference(max_iterations=4)[source]¶
Detect bad channels and estimate the robust reference signal.
This function implements the functionality of the robustReference function as part of the PREP pipeline on mne raw object.
- Parameters:
- max_iterations
int
,optional
The maximum number of iterations of noisy channel removal to perform during robust referencing. Defaults to
4
.
- max_iterations
- Returns:
- noisy_channels:
dict
A dictionary of names of noisy channels detected from all methods after referencing.
- reference_signal:
np.ndarray
, shape(n
, ) Estimation of the ‘true’ signal mean
- noisy_channels: