def main(): tmax = 20e-3 fs = 500e3 sg.set_fs(fs) sg.set_celsius(37) # Acoustic stimmulation anf_ac = sg.ANF_Axon(record_voltages=True) h.topology() h.psection(sec=anf_ac.get_sections()[0]) anf_ac.vesicles = [2e-3, 5e-3] # Electrical stimulation # set-up ANF anf_el = sg.ANF_Axon(record_voltages=True) # anf_el.set_geometry('straight', x0=250e-6, y0=500e-6, z0=0) anf_el.set_geometry('bent', a=750e-6, b=500e-6, z=0) # set-up electrode el = sg.Electrode() el.z = 0 stim = np.zeros(int(tmax * fs)) stim[int(tmax / 3 * fs):int((tmax / 3 + 1e-3) * fs)] = -0.2e-3 # (A) el.fs = fs el.stim = stim # `connect' ANF and electrode anf_el.electrodes = [el] # Run sg.run(tmax, [anf_ac, anf_el]) # Plot print(anf_ac.get_spikes(), anf_el.get_spikes()) sg.plot_vectors(anf_ac.get_voltages()[:, 0:6], fs) sg.plot_vectors(anf_el.get_voltages()[:, 0:6], fs) sg.plot_geometry([anf_el, el]) plt.show()
def main(): fs = 500e3 anf_num = 100 electrode_num = 12 tmax = 0.1 sg.set_fs(fs) sg.set_celsius(37) stim = np.zeros(tmax * fs) electrodes = [] for i in range(electrode_num): electrode = sg.Electrode() electrode.fs = fs electrode.stim = stim anfs = [] for i in range(anf_num): anf = sg.ANF_Axon() anf.electrodes = electrodes anfs.append(anf) sg.run(tmax, anfs)
def run_holmberg2007_sg( sound, fs, anf_num, seed, cf=None, weight=None, channels='schwarz1987_pure', ): """Run inner ear model by [Holmberg2007]_ in quantal mode combined with spiral ganglion neurons. Parameters ---------- weight : float Synaptic weight of the IHC synapse. channels : str or dict Channels used in the ANF model. """ vesicle_trains = cochlea.run_holmberg2007_vesicles( sound=sound, fs=fs, anf_num=anf_num, seed=seed, cf=cf, ) duration = th.get_duration(vesicle_trains) sg.set_celsius(37) sg.set_fs(100e3) anfs = [] for _, train in vesicle_trains.iterrows(): anf = sg.ANF_Axon( weight=weight, channels=channels, meta={ 'type': train['type'], 'cf': train['cf'] }, ) anf.vesicles = train['vesicles'] anfs.append(anf) sg.run(duration=duration, anfs=anfs) trains = [] for anf in anfs: trains.append(anf.get_trains()) trains = pd.concat(trains) return trains
def make_anf_electrode(): h.celsius = 37 electrode = sg.Electrode() electrode.x = 300e-6 anf = sg.ANF_Axon() # anf.set_geometry('bent', a=750, b=500, z=0) anf.set_geometry('straight', x0=0, y0=500e-6, z0=0) return anf, electrode
def test_get_segment_path_positions(): anf = sg.ANF_Axon(nodes=2) anf.set_geometry('straight', x0=0, y0=0, z0=0) # default section length (L): [10, 250, 1, 250, ...] expected = np.array([ 5 * 1e-6, 10e-6 + 250e-6/2, 10e-6 + 250e-6 + 1e-6/2, 10e-6 + 250e-6 + 1e-6 + 250e-6/2 ]) actual = anf.get_segment_path_positions() assert_equal(actual, expected)
def _simulate_anf_at((z, electrodes, return_voltages)): logger.info("Calculating ANF at z = {} [m]".format(z)) sg.set_fs(500e3) sg.set_celsius(37) anf = sg.ANF_Axon(record_voltages=return_voltages) anf.set_geometry('straight', x0=0, y0=500e-6, z0=z) anf.electrodes = electrodes tmax = max([len(el.stim) for el in electrodes]) duration = tmax / electrodes[0].fs sg.run(duration=duration, anfs=[anf]) if return_voltages: return anf.get_voltages() else: return anf.get_trains()