[7f9fb8]: / examples / preprocessing / shift_evoked.py

Download this file

64 lines (49 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
.. _ex-shift-evoked:
==================================
Shifting time-scale in evoked data
==================================
"""
# Author: Mainak Jas <mainak@neuro.hut.fi>
#
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.
# %%
import matplotlib.pyplot as plt
import mne
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
meg_path = data_path / "MEG" / "sample"
fname = meg_path / "sample_audvis-ave.fif"
# Reading evoked data
condition = "Left Auditory"
evoked = mne.read_evokeds(fname, condition=condition, baseline=(None, 0), proj=True)
picks = ["MEG 2332"]
# Create subplots
f, (ax1, ax2, ax3) = plt.subplots(3)
evoked.plot(
exclude=[],
picks=picks,
axes=ax1,
titles=dict(grad="Before time shifting"),
time_unit="s",
)
# Apply relative time-shift of 500 ms
evoked.shift_time(0.5, relative=True)
evoked.plot(
exclude=[],
picks=picks,
axes=ax2,
titles=dict(grad="Relative shift: 500 ms"),
time_unit="s",
)
# Apply absolute time-shift of 500 ms
evoked.shift_time(0.5, relative=False)
evoked.plot(
exclude=[],
picks=picks,
axes=ax3,
titles=dict(grad="Absolute shift: 500 ms"),
time_unit="s",
)