forked from nopsal/PlasticityToy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_output.py
More file actions
160 lines (126 loc) · 3.82 KB
/
plot_output.py
File metadata and controls
160 lines (126 loc) · 3.82 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
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
import numpy as np
import matplotlib.pyplot as plt
import h5py
from bmtk.analyzer.cell_vars import _get_cell_report, plot_report
import matplotlib.pyplot as plt
import csv
#PLOT OF ALL INPUTS
#AFTER SOME TIME TONE AND SHOCK COMES ON
#RANDOM INPUTS
#NEXT PANEL COULD BE TONE INPUT AND HTEN SHOCK INPUT
#RASTER PLOT OF WHEN CELLS SPIKE (ISABEL)
#PLOT CSVS OF TONE AND SHOCK INPUT
from bmtk.analyzer.compartment import plot_traces
import pandas as pd
from scipy.signal import find_peaks
import pdb
# Load data
config_file = "simulation_config.json"
raster_file = './output/spikes.h5'
mem_pot_file = './output/v_report.h5'
cai_file = './output/cai_report.h5'
shock_file = 'shock_spikes.csv'
tone_file = 'tone_spikes.csv'
# load
f = h5py.File(mem_pot_file,'r')
g = h5py.File(cai_file,'r')
shock_array = []
with open(shock_file, 'r') as csvfile:
csvreader = csv.reader(csvfile)
fields = next(csvreader)
for row in csvreader:
shock_array.append(row)
print(shock_array)
shock_x = []
shock_y = []
for element in shock_array:
word = element[0].split('\'')
print(word[0])
shock_x.append(int(word[0]))
shock_y.append(int(word[2]))
tone_array = []
with open(tone_file, 'r') as csvfile:
csvreader = csv.reader(csvfile)
fields = next(csvreader)
for row in csvreader:
tone_array.append(row)
print(tone_array)
tone_x = []
tone_y = []
for element in tone_array:
word = element[0].split('\'')
print(word[0])
tone_x.append(int(word[0]))
tone_y.append(int(word[2]))
plt.plot(tone_x, tone_y, '.', label="tone input")
plt.plot(shock_x, shock_y, '.', label="shock input")
plt.xlabel("Time elapsed")
plt.ylabel("Node id")
plt.legend()
plt.show()
mem_potential = f['report']['biophysical']['data']
plt.plot(np.arange(0,mem_potential.shape[0]/10,.1),mem_potential[:,0])
plt.text(200,-80,'tone')
plt.text(700,-80,'tone+shock')
plt.text(1600,-80,'tone+shock')
plt.text(2600,-80,'tone')
plt.xlabel('time (ms)')
plt.ylabel('membrane potential (mV)')
_ = plot_traces(config_file='simulation_config.json', node_ids=[0], report_name='v_report')
plot_two = plot_traces(config_file='simulation_config.json', node_ids=[0], report_name='cai_report')
#caiplt = g['report']['biophysical']['data']
#plt.plot(caiplt[:,0])
plt.show()
h = h5py.File('output\\spikes.h5', 'r')
timestamps = h['spikes']['biophysical']['timestamps'][:]
node_ids = h['spikes']['biophysical']['node_ids'][:]
dh = pd.DataFrame({'node_ids':node_ids, 'ts':timestamps})
#print(dh.head())
plt.plot(dh.ts, dh.node_ids, '.')
plt.xlabel("time(ms)")
plt.ylabel("node id")
plt.plot(tone_x, tone_y, '.', label="tone input")
plt.plot(shock_x, shock_y, '.', label="shock input")
plt.legend()
plt.show()
plt.hist(dh.loc[dh.node_ids==0, 'ts'])
plt.ylabel('node id 0 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==1, 'ts'])
plt.ylabel('node id 1 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==2, 'ts'])
plt.ylabel('node id 2 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==3, 'ts'])
plt.ylabel('node id 3 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==4, 'ts'])
plt.ylabel('node id 4 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==5, 'ts'])
plt.ylabel('node id 5 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==6, 'ts'])
plt.ylabel('node id 6 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==7, 'ts'])
plt.ylabel('node id 7 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==8, 'ts'])
plt.ylabel('node id 8 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
plt.hist(dh.loc[dh.node_ids==9, 'ts'])
plt.ylabel('node id 9 spike #')
plt.xlabel('time elapsed (ms)')
plt.show()
print(dh.loc[dh.node_ids==9, 'ts'])