Example #1
0
y[500:700] = 1
y[1000:1200] = 2
y[1500:1700] = 1
y[2000:2200] = 1
y[2500:2700] = 2
y[2700:3800] = 3

# Plot marker stream
plt.figure(figsize=(8,3))
plt.plot(time, y)
plt.ylim(-1, 5)
plt.xlabel('Time (s)')
plt.ylabel('Value')
plt.tight_layout()

# Annotate the plot
plt.annotate('onset of event\nof type 1', (0.5, 1), xytext=(0.2, 2.1),
    arrowprops=dict(arrowstyle='->')) 

plt.annotate('onset of event\nof type 2', (1, 2), xytext=(0.7, 3.1),
    arrowprops=dict(arrowstyle='->')) 

plt.annotate('onset of event\nof type 3', (2.7, 3), xytext=(2.4, 4.1),
    arrowprops=dict(arrowstyle='->')) 

annotate_horiz(1.5, 1.7, 2, 'duration of event', 0.2)

# Save the plot
plt.savefig('marker_stream.png')
Example #2
0
import golem, psychic
from matplotlib import pyplot as plt
from annotate import annotate_horiz

trials = golem.DataSet.load("../../data/priming-trials.dat")

f = plt.figure(figsize=(12, 4))
f.add_axes([0.05, 0.2, 0.38, 0.7])
trials2 = psychic.nodes.Baseline([0.2, 1]).train_apply(trials, trials)
psychic.plot_erp(trials2.lix[["P3"], :, :], fig=f, pval=0, vspace=15)
annotate_horiz(-0.19, -0.01, 5, "baseline period", 0.5)
plt.gca().legend().set_visible(False)
plt.title("Uncorrected")

f.add_axes([0.55, 0.2, 0.38, 0.7])
trials2 = psychic.nodes.Baseline([-0.2, 0]).train_apply(trials, trials)
psychic.plot_erp(trials2.lix[["P3"], :, :], fig=f, pval=0, vspace=15)
annotate_horiz(-0.19, -0.01, 5, "baseline period", 0.5)
# plt.legend(loc='lower right')
plt.gca().legend().set_visible(False)
plt.title("Baseline corrected")

plt.savefig("baseline.png")
Example #3
0
from matplotlib import pyplot as plt
from annotate import annotate_horiz
import psychic
import numpy as np

f = plt.figure(figsize=(10,5))
f.add_axes([0.1, 0.1, 0.5, 0.5])

d = psychic.fake.gaussian(4, 10, 100)
d = psychic.nodes.Butterworth(4, 15, 'lowpass').train_apply(d, d)
psychic.plot_eeg(d, fig=f, vspace=3)
plt.ylim(-1.5, 15)

plt.title('Sliding window')

for i,x in enumerate(np.arange(0, 10, 2.6)):
    annotate_horiz(x+0.1, x+2.1, 13, 'Trial %d' % (i*2+1), 0.2)

    if x + 3.4 < 10:
        annotate_horiz(x+1.4, x+3.4, 11.2, 'Trial %d' % (i*2+2), 0.2)

plt.savefig('sliding_window.png')