Exemplo n.º 1
0
def get_pca_mean_and_pre_whitener_raw(raw, picks, start, stop, decim, reject,
                                      flat, tstep, pre_whitener,
                                      reject_by_annotation):
    """Aux method based on ica._fit_raw from mne v0.15"""

    if picks is None:  # just use good data channels
        picks = _pick_data_channels(raw.info,
                                    exclude='bads',
                                    with_ref_meg=False)

    info = pick_info(raw.info, picks)
    if info['comps']:
        info['comps'] = []

    start, stop = _check_start_stop(raw, start, stop)

    reject_by_annotation = 'omit' if reject_by_annotation else None
    # this will be a copy
    data = raw.get_data(picks, start, stop, reject_by_annotation)

    # this will be a view
    if decim is not None:
        data = data[:, ::decim]

    # this will make a copy
    if (reject is not None) or (flat is not None):
        data, drop_inds_ = _reject_data_segments(data, reject, flat, decim,
                                                 info, tstep)
    # this may operate inplace or make a copy
    data, pre_whitener = pre_whiten(data, raw.info, picks, pre_whitener)

    pca_mean_ = np.mean(data, axis=1)

    return pca_mean_, pre_whitener
Exemplo n.º 2
0
def mark_reject_peak2peak(raw, reject={'eeg': 23e-5}, window_length=1.,
						  label='bad p2p'):
	import mne
	from mne.utils import _reject_data_segments
	_, inds = _reject_data_segments(raw._data, reject, {'eeg': 0.},
									window_length, raw.info, 0.5)

	# turn inds to time, join
	time_segments = np.array(inds) / raw.info['sfreq']
	time_segments = join_segments(time_segments)

	segment_duration = np.diff(time_segments, axis=-1).ravel()
	return mne.Annotations(time_segments[:, 0], segment_duration, label)
Exemplo n.º 3
0
def mark_reject_peak2peak(raw, reject={'eeg': 23e-5}, window_length=1.,
						  label='bad p2p'):
	import mne
	from mne.utils import _reject_data_segments
	_, inds = _reject_data_segments(raw._data, reject, {'eeg': 0.},
									window_length, raw.info, 0.5)

	# turn inds to time, join
	time_segments = np.array(inds) / raw.info['sfreq']
	time_segments = join_segments(time_segments)

	segment_duration = np.diff(time_segments, axis=-1).ravel()
	return mne.Annotations(time_segments[:, 0], segment_duration, label)