-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchirpAsym.py
438 lines (419 loc) · 18.8 KB
/
chirpAsym.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
import time as systime
start_time = systime.time()
import argparse
parser = argparse.ArgumentParser(description = '''Run chirp stimulus simulation''')
parser.add_argument('--cellModel', nargs='?', type=str, default='HayCellMig')
parser.add_argument('--section', nargs='?', type=str, default='apic_0')
parser.add_argument('--amp', nargs='?', type=float, default=1.0)
parser.add_argument('--f0', nargs='?', type=float, default=0.5)
parser.add_argument('--f1', nargs='?', type=float, default=20.0)
parser.add_argument('--delay', nargs='?', type=int, default=3)
parser.add_argument('--t0', nargs='?', type=int, default=20)
parser.add_argument('--offset', nargs='?', type=float, default=0.0)
parser.add_argument('--blockIh', nargs='?', type=str, default=None)
parser.add_argument('--blockIm', nargs='?', type=str, default=None)
parser.add_argument('--saveTraces', nargs='?', type=str, default=None)
parser.add_argument('--vhalfl', nargs='?', type=float, default=None)
parser.add_argument('--vhalft', nargs='?', type=float, default=None)
parser.add_argument('--ih_gbar_factor', nargs='?', type=float, default=None)
parser.add_argument('--TTX', nargs='?', type=str, default=None)
parser.add_argument('--blockSKv3', nargs='?', type=str, default=None)
parser.add_argument('--blockLVACa', nargs='?', type=str, default=None)
parser.add_argument('--blockTASK', nargs='?', type=str, default=None)
parser.add_argument('--blockSKE', nargs='?', type=str, default=None)
parser.add_argument('--morph_file', nargs='?', type=str, default=None)
parser.add_argument('--a0t', nargs='?', type=float, default=None)
parser.add_argument('--blockKtst', nargs='?', type=str, default=None)
parser.add_argument('--tauFactor', nargs='?', type=float, default=None)
args = parser.parse_args()
if args.cellModel == 'M1Cell':
from getCells import M1Cell
s = M1Cell()
soma_seg = s.net.cells[0].secs['soma']['hObj'](0.5)
seg = s.net.cells[0].secs[sys.argv[-1]]['hObj'](0.5)
from neuron import h
elif args.cellModel == 'HayCellMig':
from getCells import HayCellMig
if args.morph_file:
cell, _ = HayCellMig(morphology_file=args.morph_file)
else:
cell, _ = HayCellMig()
soma_seg = cell.soma[0](0.5)
sec_name = args.section.split('_')[0]
sec_num = args.section.split('_')[1]
execstr = 'seg = cell.' + sec_name + '[' + sec_num + '](0.5)'
# seg = cell.apic[int(sec_num)](0.5)
# soma_seg = seg
# seg = soma_seg
exec(execstr)
from neuron import h
elif args.cellModel == 'RichHuman':
from getCells import RichHuman
h, trunk = RichHuman()
soma_seg = h.filament_100000042[0](0.5)
seg = h.filament_100000042[trunk[int(len(trunk)/2)]](0.5)
elif args.cellModel == 'Migliore':
import neuron
from neuron import h
h.load_file('stdrun.hoc')
neuron.load_mechanisms("Ih_current") # directory with mm mod files
h.xopen("Ih_current/fig-5a.hoc")
seg = soma_seg = h.soma[0](0.5)
# soma_seg = h.soma[0](0.5)
# seg = h.dend_5[0](0.5)
from chirpUtils import getChirp, fromtodistance
stim = h.IClamp(seg)
from pylab import fft
import numpy as np
from scipy.signal import find_peaks, hilbert
import json
import os
try:
os.makedirs('supra_data/')
os.makedirs('supra_traces/')
except:
pass
# for sec in h.allsec():
# for seg in sec.allseg():
# try:
# seg.kap.gkabar = 0
# except:
# pass
# try:
# seg.kdr.gkabar = 0
# except:
# pass
# for sec in h.allsec():
# for seg in sec.allseg():
# try:
# seg.kdr.gkdrbar = 0
# except:
# pass
if args.blockIh:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.gbar_hd = 0
except:
pass
if args.a0t:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.hd.a0t = args.a0t
except:
pass
if args.tauFactor:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.hd.tauFactor = args.tauFactor
except:
pass
if args.blockTASK:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.hd.lkFactor = 0
except:
pass
if args.vhalfl:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.hd.vhalfl = args.vhalfl
except:
pass
if args.vhalft:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.hd.vhalft = args.vhalft
except:
pass
if args.ih_gbar_factor:
for sec in h.allsec():
for sec in sec.allseg():
try:
seg.gbar_hd = seg.gbar_hd * args.ih_gbar_factor
except:
pass
if args.TTX:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.NaTa_t.gNaTa_tbar = 0
except:
pass
if args.blockSKv3:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.SKv3_1.gSKv3_1bar = 0
except:
pass
if args.blockLVACa:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.Ca_LVAst.gCa_LVAstbar = 0
except:
pass
if args.blockIm:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.gImbar_Im = 0
except:
pass
if args.blockKtst:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.K_Tst.gK_Tstbar = 0
except:
pass
if args.blockSKE:
for sec in h.allsec():
for seg in sec.allseg():
try:
seg.SK_E2.gSK_E2bar = 0
except:
pass
dist = fromtodistance(seg, soma_seg)
amp = args.amp #0.02
t0 = args.t0 #20
delay = args.delay
Fs = 1000
sampr = 40e3
f0 = args.f0
f1 = args.f1
soma_v = h.Vector().record(soma_seg._ref_v)
seg_v = h.Vector().record(seg._ref_v)
time = h.Vector().record(h._ref_t)
I, t = getChirp(f0, f1, t0, amp, Fs, delay, offset=args.offset)
i = h.Vector().record(h.IClamp[0]._ref_i)
ih = None # h.Vector().record(soma_seg.hd._ref_i)
inat = None # h.Vector().record(soma_seg.NaTa_t._ref_ina)
inap = None # h.Vector().record(soma_seg.Nap_Et2._ref_ina)
iske2 = None # h.Vector().record(soma_seg.SK_E2._ref_ik)
iskv3 = None # h.Vector().record(soma_seg.SKv3_1._ref_ik)
icahva = None # h.Vector().record(soma_seg.Ca_HVA._ref_ica)
icalva = None # h.Vector().record(soma_seg.Ca_LVAst._ref_ica)
ikpst = None # h.Vector().record(soma_seg.K_Pst._ref_ik)
iktst = None # h.Vector().record(soma_seg.K_Tst._ref_ik)
stim.amp = 0
stim.dur = (t0+delay*2) * Fs + 1
I.play(stim._ref_amp, t)
## run simulation
h.celsius = 34
h.tstop = (t0+delay*2) * Fs + 1
print('running ' + args.cellModel + ' ' + args.section + ' f0-' + str(round(args.f0)) + ' f1-' + str(round(args.f1)))
h.run()
v_trim = [v for v, T in zip(soma_v, time) if int((delay)*1000) < T < int((delay+t0)*1000)]
i_trim = [x for x, T in zip(i,time) if int((delay)*1000) < T < int((delay+t0)*1000)]
time_trim = [T for v, T in zip(soma_v, time) if int((delay)*1000) < T < int((delay+t0)*1000)]
current = i_trim
v = v_trim
#current = current[int(delay*sampr - 0.5*sampr+1):-int(delay*sampr- 0.5*sampr)]
# current = np.hstack((np.repeat(current[0],int(delay*sampr)),current, np.repeat(current[-1], int(delay*sampr))))
current = np.hstack((np.repeat(args.offset,int(delay*sampr)),current, np.repeat(args.offset, int(delay*sampr))))
current = current - np.mean(current)
#v = v[int(delay*sampr - 0.5*sampr)+1:-int(delay*sampr - 0.5*sampr)]
v = v - np.mean(v)
v = np.hstack((np.repeat(0,int(delay*sampr)), v, np.repeat(0, int(delay*sampr))))
f = np.hstack((np.repeat(0,int(delay*sampr)), np.linspace(f0,f1,len(v_trim)),np.repeat(0,int(delay*sampr))))
iphase = np.angle(hilbert(current))
allspks, _ = find_peaks(v_trim, 0)
pks, _ = find_peaks(v)
trghs, _ = find_peaks(v*-1)
ipks, _ = find_peaks(current)
itrghs, _ = find_peaks(current*-1)
trghs = [tr for tr in trghs if tr > pks[0]]
f_minus = None
phi_minus = None
asym = -np.min(v)-np.max(v)
peak_to_peak = np.max(v) - np.min(v)
v_init = v_trim[0]
z_plus = None
z_minus = None
if len(allspks):
phi_plus = []
f_plus = []
for peakt, finish, nextt in zip(ipks[:-1], itrghs[:-1], ipks[1:]):
start = peakt - (finish-peakt)
spks, _ = find_peaks(v[start:finish], 0)
if len(spks):
phi_plus.append(iphase[peakt]-iphase[spks[0]+start])
else:
phi_plus.append(np.nan)
f_plus.append(f[peakt])
trghs, _ = find_peaks(v*-1, 0)
trghs = [tr for tr in trghs if tr > pks[0]]
phi_minus = []
for trgh, itrgh in zip(trghs, itrghs):
if iphase[trgh] < 0 and iphase[itrgh] < 0:
phi_minus.append((iphase[itrgh] + 2*np.pi) - (iphase[trgh] + 2*np.pi))
elif iphase[trgh] < 0:
phi_minus.append(iphase[itrgh]-(iphase[trgh] + 2*np.pi))
elif iphase[itrgh] < 0:
phi_minus.append((iphase[itrgh] + 2*np.pi) - iphase[trgh])
else:
phi_minus.append(iphase[itrgh]-iphase[trgh])
f_minus = [f[trgh] for trgh in itrghs]
else:
phi_plus = [iphase[ipk]-iphase[pk] for pk, ipk in zip(pks, ipks)]
z_plus = [np.abs(v[pk])/amp for pk in pks]
z_minus = [np.abs(v[trgh])/amp for trgh in trghs]
f_plus = [f[pk] for pk in pks]
phi_minus = []
for trgh, itrgh in zip(trghs, itrghs):
if iphase[trgh] < 0 and iphase[itrgh] < 0:
phi_minus.append((iphase[itrgh] + 2*np.pi) - (iphase[trgh] + 2*np.pi))
elif iphase[trgh] < 0:
phi_minus.append(iphase[itrgh]-(iphase[trgh] + 2*np.pi))
elif iphase[itrgh] < 0:
phi_minus.append((iphase[itrgh] + 2*np.pi) - iphase[trgh])
else:
phi_minus.append(iphase[itrgh]-iphase[trgh])
f_minus = [f[trgh] for trgh in itrghs]
out = {'f_plus' : f_plus,
'f_minus' : f_minus,
'phi_plus' : phi_plus,
'phi_minus' : phi_minus,
'TTX' : args.TTX,
'offset' : args.offset,
'v_init' : v_init,
'peak_to_peak' : peak_to_peak,
'asym' : asym,
'z_plus': z_plus,
'z_minus' : z_minus}
datadir = 'asym_data/'
tracedir = 'asym_traces/'
if args.blockIh:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockIh.json'
elif args.vhalfl:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_vhalfl_' + str(round(args.vhalfl)) + '.json'
elif args.vhalft:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_vhalft_' + str(round(args.vhalft)) + '.json'
elif args.ih_gbar_factor:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_gbarfactor_' + str(round(args.ih_gbar_factor, 2)) + '.json'
elif args.TTX:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_TTX.json'
elif args.blockSKv3:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockSKv3.json'
elif args.blockIm:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockIm.json'
elif args.blockSKE:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockSKE.json'
elif args.blockTASK:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockTASK.json'
elif args.blockLVACa:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockLVACa.json'
elif args.morph_file:
morph = args.morph_file.split('/')[-1].split('.')[0]
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '+' + morph + '.json'
elif args.a0t:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_a0t_' + str(round(args.a0t,3)) + '.json'
elif args.blockKtst:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockKtst.json'
elif args.tauFactor:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_tauFactor_' + str(round(args.tauFactor,3)) + '.json'
else:
filename = datadir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '.json'
with open(filename, 'w') as fileObj:
json.dump(out, fileObj)
if args.saveTraces:
traces = {'soma_v' : soma_v.as_numpy(),
'i' : i.as_numpy(),
'time' : time.as_numpy(),
'ih' : ih,
'inat' : inat,
'inap' : inap,
'iske2' : iske2,
'iskv3' : iskv3,
'icahva' : icahva,
'icalva' : icalva,
'ikpst' : ikpst,
'iktst' : iktst}
if args.blockIh:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockIh.npy'
elif args.vhalfl:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_vhalf_' + str(round(args.vhalfl)) + '.npy'
elif args.vhalft:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_vhalft_' + str(round(args.vhalft)) + '.npy'
elif args.ih_gbar_factor:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_gbarfactor_' + str(round(args.ih_gbar_factor,2)) + '.npy'
elif args.TTX:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_TTX.npy'
elif args.blockSKv3:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockSKv3.npy'
elif args.blockTASK:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockTASK.npy'
elif args.blockLVACa:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockLVACa.npy'
elif args.blockIm:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockIm.npy'
elif args.blockKtst:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockKtst.npy'
elif args.blockSKE:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_blockSKE.npy'
elif args.morph_file:
morph = args.morph_file.split('/')[-1].split('.')[0]
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '_' + morph + '.npy'
else:
tracefile = tracedir + args.cellModel + '_' + args.section + '_amp_' + str(amp) + '_offset_' + str(args.offset) + '_f0_' + str(round(args.f0)) + '_f1_' + str(round(f1)) + '.npy'
with open(tracefile, 'wb') as fileObj:
np.save(fileObj, traces)
# from matplotlib import pyplot as plt
# fig2, axs2 = plt.subplots(3,3,sharex=True)
# axs2[0][0].plot(ih)
# axs2[0][0].set_title('ih')
# axs2[0][1].plot(inat)
# axs2[0][1].set_title('inat')
# axs2[0][2].plot(inap)
# axs2[0][2].set_title('inap')
# axs2[1][0].plot(iske2)
# axs2[1][0].set_title('iske2')
# axs2[1][1].plot(iskv3)
# axs2[1][1].set_title('iskv3')
# axs2[1][2].plot(icahva)
# axs2[1][2].set_title('icahva')
# axs2[2][0].plot(icalva)
# axs2[2][0].set_title('icalva')
# axs2[2][1].plot(ikpst)
# axs2[2][1].set_title('ikpst')
# axs2[2][2].plot(iktst)
# axs2[2][2].set_title('iktst')
# fig, axs = plt.subplots(3,1, sharex=True)
# axs[0].plot(current)
# axs[1].plot(v)
# axs[2].plot(iphase)
# for pk in ipks:
# axs[0].plot(pk, current[pk], 'k*')
# axs[2].plot(pk, iphase[pk], 'k*')
# for trgh in itrghs:
# axs[0].plot(trgh, current[trgh], 'g*')
# axs[2].plot(trgh, iphase[trgh], 'g*')
# for pk in pks:
# axs[1].plot(pk, v[pk], 'r*')
# axs[2].plot(pk, iphase[pk], 'r*')
# for trgh in trghs:
# axs[1].plot(trgh, v[trgh], 'y*')
# if iphase[trgh] < 0:
# axs[2].plot(trgh, iphase[trgh]+2*np.pi, 'y*')
# else:
# axs[2].plot(trgh, iphase[trgh], 'y*')
# fig2, ax = plt.subplots(1,1)
# if len(allspks):
# ax.plot(f_plus, phi_plus, '*--', label='Spike Times')
# ax.set_ylabel(r'$\Phi$(f)$^{+}$ (rad)', fontsize=14)
# else:
# ax.plot(f_plus, phi_plus, '*--', label='Nonlinear Upper Envelope')
# ax.plot(f_minus, phi_minus, '*--', label='Nonlinear Lower Envelope')
# ax.set_ylabel(r'$\Phi$(f)$^{+/-}$ (rad)', fontsize=14)
# # with open('sub_data/HayCellMig_soma_0_amp_0.025_offset_0.0_f0_0_f1_20.json', 'rb') as fileObj:
# # chirp_data = json.load(fileObj)
# # ax.plot(chirp_data['Freq'], chirp_data['ZinPhase'], label='Linear Response')
# ax.set_xlabel('Frequency (Hz)', fontsize=14)
# ax.legend()