-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrn_gbc_demo_with_default_weights.py
94 lines (65 loc) · 1.48 KB
/
nrn_gbc_demo_with_default_weights.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Run a simulation of a globular bushy cell with ANF input.
1. Create sound (pure tone).
2. Run inner ear model.
3. Run GBC model.
"""
from __future__ import division, absolute_import, print_function
import numpy as np
import matplotlib.pyplot as plt
import cochlear_nucleus.nrn as cn
import cochlea
import thorns as th
import thorns.waves as wv
def main():
fs = 100e3
cf = 500
convergence = (35, 0, 0)
# Generate sound
sound = wv.ramped_tone(
fs=fs,
freq=cf,
duration=50e-3,
pad=30e-3,
dbspl=50
)
# Run inner ear model
anf_trains = cochlea.run_zilany2014(
sound=sound,
fs=fs,
cf=cf,
anf_num=convergence,
species='cat',
seed=0
)
# Run GBC
cn.set_celsius(37)
cn.set_fs(fs)
gbc = cn.GBC_Point(
convergence=convergence,
cf=cf,
endbulb_class='tonic',
record_voltages=True
)
gbc.load_anf_trains(anf_trains, seed=0)
cn.run(
duration=len(sound)/fs,
objects=[gbc]
)
# Collect the results
gbc_trains = gbc.get_trains()
voltages = gbc.get_voltages()
# Present the results
print(gbc_trains)
fig, ax = plt.subplots(2, 1)
th.plot_raster(anf_trains, ax=ax[0])
ax[0].set_title("ANF input")
th.plot_signal(
voltages,
fs=fs,
ax=ax[1]
)
th.show()
if __name__ == "__main__":
main()