This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplot_neural_visual.py
253 lines (220 loc) · 7.58 KB
/
plot_neural_visual.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# ============================================================================
#
# PUBLIC DOMAIN NOTICE
#
# National Institute on Deafness and Other Communication Disorders
#
# This software/database is a "United States Government Work" under the
# terms of the United States Copyright Act. It was written as part of
# the author's official duties as a United States Government employee and
# thus cannot be copyrighted. This software/database is freely available
# to the public for use. The NIDCD and the U.S. Government have not placed
# any restriction on its use or reproduction.
#
# Although all reasonable efforts have been taken to ensure the accuracy
# and reliability of the software and data, the NIDCD and the U.S. Government
# do not and cannot warrant the performance or results that may be obtained
# by using this software or data. The NIDCD and the U.S. Government disclaim
# all warranties, express or implied, including warranties of performance,
# merchantability or fitness for any particular purpose.
#
# Please cite the author in any work or product based on this material.
#
# ==========================================================================
# ***************************************************************************
#
# Large-Scale Neural Modeling software (LSNM)
#
# Section on Brain Imaging and Modeling
# Voice, Speech and Language Branch
# National Institute on Deafness and Other Communication Disorders
# National Institutes of Health
#
# This file (plot_neural_visual.py) was created on December 1, 2014.
#
#
# Author: Antonio Ulloa. Last updated by Antonio Ulloa on July 19 2015
# **************************************************************************/
# plot_neural_visual.py
#
# Plot output data files of visual delay-match-to-sample simulation
# what are the locations of relevant TVB nodes within TVB array?
v1_loc = 345
v4_loc = 393
it_loc = 413
d1_loc = 74
d2_loc = 41
fs_loc = 47
fr_loc = 125
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
# Load data files
lgns = np.loadtxt('lgns.out')
efd1 = np.loadtxt('efd1.out')
efd2 = np.loadtxt('efd2.out')
ev1h = np.loadtxt('ev1h.out')
ev1v = np.loadtxt('ev1v.out')
ev4c = np.loadtxt('ev4c.out')
ev4h = np.loadtxt('ev4h.out')
ev4v = np.loadtxt('ev4v.out')
exfr = np.loadtxt('exfr.out')
exfs = np.loadtxt('exfs.out')
exss = np.loadtxt('exss.out')
# load file containing TVB nodes electrical activity
try:
tvb = np.load('tvb_neuronal.npy')
tvb_v1 = tvb[:, 0, v1_loc, 0]
tvb_v4 = tvb[:, 0, v4_loc, 0]
tvb_it = tvb[:, 0, it_loc, 0]
tvb_fs = tvb[:, 0, fs_loc, 0]
tvb_d1 = tvb[:, 0, d1_loc, 0]
tvb_d2 = tvb[:, 0, d2_loc, 0]
tvb_fr = tvb[:, 0, fr_loc, 0]
except:
pass
# Extract number of timesteps from one of the matrices
timesteps = lgns.shape[0]
print timesteps
# the following variable defines the timesteps we will see in the resulting plot
# we also convert the number of timesteps to seconds by multiplying by 50 and dividng by 1000
start = 0
end = 700
ts_to_plot = end - start
x_lim = ts_to_plot * 50. / 1000.
# Construct a numpy array of timesteps (data points provided in data file)
t = np.linspace(0, (ts_to_plot-1)*50./1000., num=ts_to_plot)
# Set up plot
fig1=plt.figure(1, facecolor='white')
# increase font size
plt.rcParams.update({'font.size': 15})
# optional caption for figure
#txt = '''Figure 1. Plots of electrical activity of all submodules of the LSNM visual model (red lines) and host nodes of the TVB connectome
#(blue lines), for a representative simulated subject. The simulated tasks were: three DMS trials (match, mismatch, match), followed
#by three control trials where degraded shapes were used as inputs and the attention parameter was set to low (passive viewing).
#The y axis of each of the plots represents level of electrical activity, between zero and one. The x axis of the plots represents
#time in seconds.'''
# Plot V1 module
ax = plt.subplot(7,1,1)
#try:
# ax.plot(t, tvb_v1[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(ev1h[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
#ax.set_title('SIMULATED ELECTRICAL ACTIVITY, V1 and V4')
plt.ylabel('V1h', rotation='horizontal', horizontalalignment='right')
#ax = plt.subplot(10,1,2)
#try:
# ax.plot(t, tvb_v1[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
#ax.plot(t, ev1v[start:end], color='r')
#ax.set_yticks([])
#ax.set_xlim(0,x_lim)
#ax.set_ylim(0.,1.)
#plt.setp(ax.get_xticklabels(), visible=False)
#plt.ylabel('V1v', rotation='horizontal', horizontalalignment='right')
# Plot V4 module
ax = plt.subplot(7,1,2)
#try:
# ax.plot(t, tvb_v4[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(ev4h[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel('V4h', rotation='horizontal', horizontalalignment='right')
#ax = plt.subplot(10,1,4)
#try:
# ax.plot(t, tvb_v4[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
#ax.plot(t, ev4c[start:end], color='r')
#ax.set_yticks([])
#ax.set_xlim(0,x_lim)
#ax.set_ylim(0.,1.)
#plt.setp(ax.get_xticklabels(), visible=False)
#plt.ylabel('V4c', rotation='horizontal', horizontalalignment='right')
#ax = plt.subplot(10,1,5)
#try:
# ax.plot(t, tvb_v4[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
#ax.plot(t, ev4v[start:end], color='r')
#ax.set_yticks([])
#ax.set_xlim(0,x_lim)
#ax.set_ylim(0.,1.)
#plt.setp(ax.get_xticklabels(), visible=False)
#plt.ylabel('V4v', rotation='horizontal', horizontalalignment='right')
#plt.tight_layout()
# Plot IT module
ax = plt.subplot(7,1,3)
#try:
# ax.plot(t, tvb_it[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(exss[start:end], axis=1), color='r')
ax.set_yticks([])
#ax.set_title('SIMULATED ELECTRICAL ACTIVITY, IT and PFC')
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel('IT', rotation='horizontal', horizontalalignment='right')
# Plot PFC modules FS, FD1, and FD2
ax = plt.subplot(7,1,4)
#try:
# ax.plot(t, tvb_fs[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(exfs[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel('FS', rotation='horizontal', horizontalalignment='right')
ax = plt.subplot(7,1,5)
#try:
# ax.plot(t, tvb_d1[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(efd1[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel('D1', rotation='horizontal', horizontalalignment='right')
ax = plt.subplot(7,1,6)
#try:
# ax.plot(t, tvb_d2[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(efd2[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.setp(ax.get_xticklabels(), visible=False)
plt.ylabel('D2', rotation='horizontal', horizontalalignment='right')
# Plot FR (Response module)
ax = plt.subplot(7,1,7)
#try:
# ax.plot(t, tvb_fr[0:ts_to_plot], color='b', linewidth=2)
#except:
# pass
ax.plot(t, np.mean(exfr[start:end], axis=1), color='r')
ax.set_yticks([])
ax.set_xlim(0,x_lim)
ax.set_ylim(0.,1.)
plt.ylabel('FR', rotation='horizontal', horizontalalignment='right')
plt.xlabel('Time (s)')
#plt.tight_layout()
# optional figure caption
#fig1.subplots_adjust(bottom=0.2)
#fig1.text(.1, 0.03, txt)
# Show the plot on the screen
plt.show()