<commit_before>"""
=========================================
Create evoked objects in delayed SSP mode
=========================================

This script shows how to apply SSP projectors at the evoked
stage. We first will extract Epochs and create evoked objects
with the required settings and then explore the different SSP
projectors at the evoked stage.

"""
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

print __doc__

import mne
from mne import fiff
from mne.datasets import sample
from mne.viz import plot_drop_log
data_path = sample.data_path()

###############################################################################
# Set parameters
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
event_id, tmin, tmax = 1, -0.2, 0.5

#   Setup for reading the raw data
raw = fiff.Raw(raw_fname)
events = mne.read_events(event_fname)

# pick Magnetometer channels
picks = fiff.pick_types(raw.info, meg='mag', stim=False, eog=True,
                        include=[], exclude='bads')

# Read epochs with proj == False
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=(None, 0), reject=dict(mag=4e-12),
                    proj=False)

evoked = epochs.average()  # average epochs and get an Evoked dataset.


###############################################################################
# View evoked response
times = 1e3 * epochs.times  # time in miliseconds
import pylab as pl
pl.figure()
evoked.plot()
pl.xlim([times[0], times[-1]])
pl.xlabel('time (ms)')
pl.ylabel('Potential (uV)')
pl.title('MEG evoked fields | SSP off')
pl.show()

# View evoked response
pl.figure()
evoked.apply_projector().plot()
pl.xlim([times[0], times[-1]])
pl.xlabel('time (ms)')
pl.ylabel('Potential (uV)')
pl.title('MEG evoked fields | SSP on')
pl.show()<commit_msg>ENH: cleanup example<commit_after>"""
=========================================
Create evoked objects in delayed SSP mode
=========================================

This script shows how to apply SSP projectors at the evoked
stage. We first will extract Epochs and create evoked objects
with the required settings and then explore the different SSP
projectors at the evoked stage.

"""
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

print __doc__

import mne
from mne import fiff
from mne.datasets import sample
data_path = sample.data_path()

###############################################################################
# Set parameters
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
event_id, tmin, tmax = 1, -0.2, 0.5

#   Setup for reading the raw data
raw = fiff.Raw(raw_fname)
events = mne.read_events(event_fname)

# pick Magnetometer channels
picks = fiff.pick_types(raw.info, meg='mag', stim=False, eog=True,
                        include=[], exclude='bads')

# Read epochs with proj == False
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=(None, 0), reject=dict(mag=4e-12),
                    proj=False)

evoked = epochs.average()  # average epochs and get an Evoked dataset.


###############################################################################
# View evoked response with projectos idle
times = 1e3 * epochs.times  # time in miliseconds
import pylab as pl
pl.figure()
evoked.plot()
pl.xlim([times[0], times[-1]])
pl.xlabel('time (ms)')
pl.ylabel('MEG evoked fields (fT)')
pl.title('Magnetometers | SSP off')
pl.show()

# now with projectors activated
pl.figure()
evoked.copy().apply_projector().plot()
pl.xlim([times[0], times[-1]])
pl.xlabel('time (ms)')
pl.ylabel('MEG evoked fields (fT)')
pl.title('Magnetometers | SSP on')
pl.show()
{'fraction_non_alphanumeric': 0.23721408378308917, 'fraction_numerical': 0.011308147005911076, 'mean_word_length': 4.665211062590975, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7376271', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1225, 'n_words': 347}