Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import numpy as np | |
import theano | |
import theano.tensor as tt | |
# constants | |
N = 1000000 | |
freq = 1000. | |
tau = 20*0.001 | |
dt = 0.1*0.001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested with Brian 2.1.3.1 | |
from brian2 import * | |
G = NeuronGroup(2, '''drate/dt = amplitude*sin(2*pi*100*Hz*t)/(10*ms) : Hz | |
rate_delayed : Hz | |
amplitude : Hz | |
buffer_pointer : integer (shared) | |
delay_steps : integer''', method='euler') | |
G.amplitude = [50, 100] * Hz |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from brian2 import * | |
# A little script to get an overview over the new error messages for unit | |
# errors in Brian 2 (in the form of a table that can be pasted into github) | |
if __name__ == '__main__': | |
@check_units(x=volt, y=1, result=amp) | |
def myfunc(x, y): | |
if y == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from brian2 import * | |
from brian2.devices.cpp_standalone import CPPStandaloneCodeObject | |
# The following code works only for numpy runtime or C++ standalone | |
set_device('cpp_standalone') | |
prefs.codegen.cpp.headers += ['"run.h"'] # This is necessary to use brian_end() | |
#prefs.codegen.target = 'numpy' | |
# Simple model, the neurons will increasingly spike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Record the spikes at a synapse with Brian 2. Note that you cannot use | |
SpikeMonitor for this task, as it is only meant to record from a NeuronGroup | |
(or another SpikeSource such as PoissonGroup). | |
''' | |
from brian2 import * | |
# The record_spikes function only works with the numpy target | |
prefs.codegen.target = 'numpy' | |
synapse_spikes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_schedule(network=None): | |
if network is None: | |
network = magic_network | |
network._update_magic_objects(level=1) | |
network._sort_objects() | |
print('Available slots (also "before_..." and "after_..."):\n%s\n' % network.schedule) | |
print('Slot Order Name') | |
prev_slot = None |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from brian2 import * | |
# Does also work in standalone mode, enable with: | |
# set_device('cpp_standalone') | |
N = 10 | |
G = NeuronGroup(N, | |
''' | |
dv/dt = -v / (10*ms) + 1*mV*ms**-0.5*xi : volt | |
v_max : volt | |
''') |
OlderNewer