Package: neuron-reduce
IntroductionNeuron_Reduce provides an analytical method for reducing neuron model complexity. It enables the mapping of synapses and active ion channels to a computationally simpler model while accelerating simulation speed by up to 200-fold for inputs consisting of thousands of dendritic synapses.Full details are available in the accompanied paper:An efficient analytical reduction of detailed nonlinear neuron models.Nat. Commun., 11 (2020), p. 288  -https://www.nature.com/articles/s41467-019-13932-6Installationpip install --user neuron_reduceQuick StartThe following code show the main function that is used to reduce a complex cell.complex_cell# The model cellsynapses_list# A list of all synapse on this cellnetcon_list# A list of all netcons for the synapses on the cellimportneuron_reducereduced_cell,synapses_list,netcons_list=neuron_reduce.subtree_reductor(complex_cell,synapses_list,netcons_list)Detailed exampleCopy example folder from githubgitclonehttps://github.com/orena1/neuron_reduce.gitGo to example foldercdneuron_reducecdexample
nrnivmodlmod#compile the mod filesOpen python and run the following codefrom__future__importdivisionfromneuronimportgui,himportnumpyasnpimportneuron_reduceimporttimeimportmatplotlib.pyplotasplt#Create a L5_PC modelh.load_file('L5PCbiophys3.hoc')h.load_file("import3d.hoc")h.load_file('L5PCtemplate.hoc')complex_cell=h.L5PCtemplate('cell1.asc')h.celsius=37h.v_init=complex_cell.soma[0].e_pas#Add synapses to the modelsynapses_list,netstims_list,netcons_list,randoms_list=[],[],[],[]all_segments=[iforjinmap(list,list(complex_cell.apical))foriinj]+[iforjinmap(list,list(complex_cell.basal))foriinj]len_per_segment=np.array([seg.sec.L/seg.sec.nsegforseginall_segments])rnd=np.random.RandomState(10)foriinrange(10000):seg_for_synapse=rnd.choice(all_segments,p=len_per_segment/sum(len_per_segment))synapses_list.append(h.Exp2Syn(seg_for_synapse))ifrnd.uniform()<0.85:e_syn,tau1,tau2,spike_interval,syn_weight=0,0.3,1.8,1000/2.5,0.0016else:e_syn,tau1,tau2,spike_interval,syn_weight=-86,1,8,1000/15.0,0.0008#set synaptic varibalessynapses_list[i].e,synapses_list[i].tau1,synapses_list[i].tau2=e_syn,tau1,tau2#set netstim variablesnetstims_list.append(h.NetStim())netstims_list[i].interval,netstims_list[i].number,netstims_list[i].start,netstims_list[i].noise=spike_interval,9e9,100,1#set randomrandoms_list.append(h.Random())randoms_list[i].Random123(i)randoms_list[i].negexp(1)netstims_list[i].noiseFromRandom(randoms_list[i])#set netcon varibalesnetcons_list.append(h.NetCon(netstims_list[i],synapses_list[i]))netcons_list[i].delay,netcons_list[i].weight[0]=0,syn_weight#Simulate the full neuron for 1 secondssoma_v=h.Vector()soma_v.record(complex_cell.soma[0](0.5)._ref_v)time_v=h.Vector()time_v.record(h._ref_t)h.tstop=1000st=time.time()h.run()print('complex cell simulation time{:.4f}'.format(time.time()-st))complex_cell_v=list(soma_v)#apply Neuron_Reduce to simplify the cellreduced_cell,synapses_list,netcons_list=neuron_reduce.subtree_reductor(complex_cell,synapses_list,netcons_list,reduction_frequency=0,total_segments_manual=-1)forrinrandoms_list:r.seq(1)#reset random#Running the simulation again but now on the reduced cellst=time.time()h.run()print('reduced cell simulation time{:.4f}'.format(time.time()-st))reduced_celll_v=list(soma_v)#plotting the resultsplt.figure()plt.plot(time_v,complex_cell_v,label='complex cell')plt.plot(time_v,reduced_celll_v,label='redcued cell')plt.show()CitationO. Amsalem, G. Eyal, N. Rogozinski, M. Gevaert, P. Kumbhar, F. Schürmann, I. Segev.An efficient analytical reduction of detailed nonlinear neuron models.Nat. Commun., 11 (2020), p. 288