-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_io_spiketrain.py
109 lines (73 loc) · 2.49 KB
/
test_io_spiketrain.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
from mod_software.SI import si
import numpy as np
import time
import h5py
import matplotlib.pyplot as plt
from tqdm import tqdm
from scipy.stats import linregress
import os
from datetime import datetime
ADCfclk = 2000000 # 2000000
obj = si(Rshunt=100000, ADCspeed=ADCfclk) # 14000 , 47000, , electrode11='in'
Rshunt = obj.Rshunt
num_sweeps = 6
# #################################
now = datetime.now()
real_d_string = now.strftime("%d_%m_%Y")
d_string = now.strftime("%Y_%m_%d")
print("Date:", real_d_string)
print("Date:", d_string)
t_string = now.strftime("%H_%M_%S")
print("Time Stamp:", t_string, "\n\n")
p = 1
OP = 4 # 4
#test_label = 'IO_sweep_%s__p%s_Op%d' % (type,p,OP)
test_label = 'PKs__%s__p%s_Op%d' % ('SpikeT',p,OP)
#test_label = 'CustomDRN_%s__Op%d' % (type,OP)
save_dir = "Results/%s/%s_%s" % (d_string, t_string, test_label)
os.makedirs(save_dir)
# ################################
obj.ElectrodeState()
input("Press Enter to start sweeps... ")
for inst in [-1, -0.5, -0.2, -0.1, -0.05, 0.05, 0.1, 0.2, 0.5, 1]:
print("Measuring spike train input for:", inst)
input_pairs = [[p,inst]]
ops = [OP]
record = obj.SetV_spike_train(input_pairs, ops, encoding='rate')
# save data
location = "%s/data.hdf5" % (save_dir)
with h5py.File(location, 'a') as hdf:
G = hdf.create_group("Instance_%.3f" % (inst))
G_in = G.create_group("In")
for in_pair in input_pairs:
electrode, inst = in_pair
G_in.create_dataset('electrode_%d' % (electrode), data=record['electrode_%d' % (electrode)])
G_op = G.create_group("Ops")
for op in ops:
G_op.create_dataset('op_%d' % (op), data=record['op_%d' % (op)])
#
#
fig, axs = plt.subplots(2, sharex=True)
axs[0].set_title("Responce to input instance %.3f" % (inst))
for in_pair in input_pairs:
electrode, inst = in_pair
zipped = record['electrode_%d' % (electrode)]
t, st = list(zip(*zipped))
axs[0].plot(t, st, '-x', label="in%d" % (electrode))
axs[0].legend()
axs[0].set_ylabel('Input Voltage Spikes')
for op in ops:
zipped = record['op_%d' % (op)]
t, Vo = list(zip(*zipped))
axs[1].plot(t, Vo, '-x', label="op%d" % (op))
axs[1].legend()
axs[1].set_xlabel('Time')
axs[1].set_xlabel('Voltage')
fig_path = "%s/FIG_spike_responce__%s.png" % (save_dir, str(inst))
fig.savefig(fig_path, dpi=200)
plt.close(fig)
#
plt.show()
plt.close('all')
obj.fin()
# fin