-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_dipole_timecourse.py
36 lines (29 loc) · 1.02 KB
/
plot_dipole_timecourse.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 11 11:15:42 2022
@author: mdclarke
Plot somatosensory dipole timecourses with GOF
"""
import mne
import matplotlib.pyplot as plt
import os.path as op
import numpy as np
path = '/Users/ashdrew/Soma_Data/TWA/dips/'
dips = ['408_0', '409_1'] # enter subject numbers for dipoles you want plotted here
for d in dips:
dip_fname = op.join(path, 'soma3_%s.dip' %d)
dip = mne.read_dipole(dip_fname)
gof = dip.gof
np.set_printoptions(formatter={'float_kind':'{:f}'.format})
best_dip_idx = gof.argmax()
max_gof = gof[best_dip_idx]
best_dip_time = dip.times[best_dip_idx]
# plot each dipole as a function of time with latency of highest GOF%
dip.plot_amplitudes()
plt.plot(dip.times, gof, color='red', alpha=0.5, label='GOF', linewidth=1)
plt.axvline(x = best_dip_time, color = 'b',
label = 'Max GOF: %d' %max_gof + '%', alpha=0.5,
linestyle='dashed')
plt.title('dipole %s' %d)
plt.legend()