Pyodide Brian2 test
Loading libraries...
Code:
import sys sys.setrecursionlimit(10**5) from brian2 import * taum = 20*ms taue = 5*ms taui = 10*ms Vt = -50*mV Vr = -60*mV El = -49*mV eqs = ''' dv/dt = (ge+gi-(v-El))/taum : volt (unless refractory) dge/dt = -ge/taue : volt dgi/dt = -gi/taui : volt ''' P = NeuronGroup(4000, eqs, threshold='v>Vt', reset='v = Vr', refractory=5*ms, method='exact') P.v = 'Vr + rand() * (Vt - Vr)' P.ge = 0*mV P.gi = 0*mV we = (60*0.27/10)*mV # excitatory synaptic weight (voltage) wi = (-20*4.5/10)*mV # inhibitory synaptic weight Ce = Synapses(P, P, on_pre='ge += we') Ci = Synapses(P, P, on_pre='gi += wi') Ce.connect('i<3200', p=0.02) Ci.connect('i>=3200', p=0.02) s_mon = SpikeMonitor(P) run(1 * second, report='text') plt.plot(s_mon.t/ms, s_mon.i, ',k') plt.xlabel('Time (ms)') plt.ylabel('Neuron index') # Convert image to base64 import base64 import io pic_IObytes = io.BytesIO() plt.savefig(pic_IObytes, format='png') pic_IObytes.seek(0) brian_pic = str(base64.b64encode(pic_IObytes.read()), 'utf-8')
Image stored in
brian_pic
: