bsb-nest 4.0.0__py2.py3-none-any.whl → 4.1.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bsb-nest might be problematic. Click here for more details.
- bsb_nest/__init__.py +1 -1
- bsb_nest/adapter.py +182 -180
- bsb_nest/cell.py +30 -23
- bsb_nest/connection.py +164 -163
- bsb_nest/device.py +72 -69
- bsb_nest/devices/__init__.py +4 -2
- bsb_nest/devices/dc_generator.py +23 -0
- bsb_nest/devices/multimeter.py +52 -0
- bsb_nest/devices/poisson_generator.py +41 -32
- bsb_nest/devices/spike_recorder.py +30 -30
- bsb_nest/distributions.py +62 -0
- bsb_nest/exceptions.py +22 -22
- bsb_nest/simulation.py +27 -21
- {bsb_nest-4.0.0.dist-info → bsb_nest-4.1.0.dist-info}/LICENSE +619 -619
- {bsb_nest-4.0.0.dist-info → bsb_nest-4.1.0.dist-info}/METADATA +2 -2
- bsb_nest-4.1.0.dist-info/RECORD +18 -0
- bsb_nest-4.0.0.dist-info/RECORD +0 -15
- {bsb_nest-4.0.0.dist-info → bsb_nest-4.1.0.dist-info}/WHEEL +0 -0
- {bsb_nest-4.0.0.dist-info → bsb_nest-4.1.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import nest
|
|
2
|
-
from bsb import config
|
|
3
|
-
from neo import SpikeTrain
|
|
4
|
-
|
|
5
|
-
from ..device import NestDevice
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@config.node
|
|
9
|
-
class SpikeRecorder(NestDevice, classmap_entry="spike_recorder"):
|
|
10
|
-
weight = config.provide(1)
|
|
11
|
-
|
|
12
|
-
def implement(self, adapter, simulation, simdata):
|
|
13
|
-
|
|
14
|
-
nodes = self.get_target_nodes(adapter, simulation, simdata)
|
|
15
|
-
device = self.register_device(simdata, nest.Create("spike_recorder"))
|
|
16
|
-
self.connect_to_nodes(device, nodes)
|
|
17
|
-
|
|
18
|
-
def recorder(segment):
|
|
19
|
-
segment.spiketrains.append(
|
|
20
|
-
SpikeTrain(
|
|
21
|
-
device.events["times"],
|
|
22
|
-
units="ms",
|
|
23
|
-
senders=device.events["senders"],
|
|
24
|
-
t_stop=simulation.duration,
|
|
25
|
-
device=self.name,
|
|
26
|
-
pop_size=len(nodes),
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
simdata.result.create_recorder(recorder)
|
|
1
|
+
import nest
|
|
2
|
+
from bsb import config
|
|
3
|
+
from neo import SpikeTrain
|
|
4
|
+
|
|
5
|
+
from ..device import NestDevice
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@config.node
|
|
9
|
+
class SpikeRecorder(NestDevice, classmap_entry="spike_recorder"):
|
|
10
|
+
weight = config.provide(1)
|
|
11
|
+
|
|
12
|
+
def implement(self, adapter, simulation, simdata):
|
|
13
|
+
|
|
14
|
+
nodes = self.get_target_nodes(adapter, simulation, simdata)
|
|
15
|
+
device = self.register_device(simdata, nest.Create("spike_recorder"))
|
|
16
|
+
self.connect_to_nodes(device, nodes)
|
|
17
|
+
|
|
18
|
+
def recorder(segment):
|
|
19
|
+
segment.spiketrains.append(
|
|
20
|
+
SpikeTrain(
|
|
21
|
+
device.events["times"],
|
|
22
|
+
units="ms",
|
|
23
|
+
senders=device.events["senders"],
|
|
24
|
+
t_stop=simulation.duration,
|
|
25
|
+
device=self.name,
|
|
26
|
+
pop_size=len(nodes),
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
simdata.result.create_recorder(recorder)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import builtins
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
import errr
|
|
5
|
+
import nest.random.hl_api_random as _distributions
|
|
6
|
+
from bsb import DistributionCastError, TypeHandler, config, types
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from bsb import Scaffold
|
|
10
|
+
|
|
11
|
+
_available_distributions = [d for d in _distributions.__all__]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@config.node
|
|
15
|
+
class NestRandomDistribution:
|
|
16
|
+
"""
|
|
17
|
+
Class to handle NEST random distributions.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
scaffold: "Scaffold"
|
|
21
|
+
distribution: str = config.attr(
|
|
22
|
+
type=types.in_(_available_distributions), required=True
|
|
23
|
+
)
|
|
24
|
+
"""Distribution name. Should correspond to a function of nest.random.hl_api_random"""
|
|
25
|
+
parameters: dict[str, typing.Any] = config.catch_all(type=types.any_())
|
|
26
|
+
"""Dictionary of parameters to assign to the distribution. Should correspond to NEST's"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, **kwargs):
|
|
29
|
+
try:
|
|
30
|
+
self._distr = getattr(_distributions, self.distribution)(**self.parameters)
|
|
31
|
+
except Exception as e:
|
|
32
|
+
errr.wrap(
|
|
33
|
+
DistributionCastError, e, prepend=f"Can't cast to '{self.distribution}': "
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def __call__(self):
|
|
37
|
+
return self._distr
|
|
38
|
+
|
|
39
|
+
def __getattr__(self, attr):
|
|
40
|
+
# hasattr does not work here. So we use __dict__
|
|
41
|
+
if "_distr" not in self.__dict__:
|
|
42
|
+
raise AttributeError("No underlying _distr found for distribution node.")
|
|
43
|
+
return getattr(self._distr, attr)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class nest_parameter(TypeHandler):
|
|
47
|
+
"""
|
|
48
|
+
Type validator. Type casts the value or node to a Nest parameter, that can be either a value or
|
|
49
|
+
a NestRandomDistribution.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def __call__(self, value, _key=None, _parent=None):
|
|
53
|
+
if isinstance(value, builtins.dict) and "distribution" in value.keys():
|
|
54
|
+
return NestRandomDistribution(**value, _key=_key, _parent=_parent)
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def __name__(self): # pragma: nocover
|
|
59
|
+
return "nest parameter"
|
|
60
|
+
|
|
61
|
+
def __inv__(self, value):
|
|
62
|
+
return value
|
bsb_nest/exceptions.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
class KernelWarning(Warning):
|
|
2
|
-
pass
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class NestError(Exception):
|
|
6
|
-
pass
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class NestKernelError(NestError):
|
|
10
|
-
pass
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class NestModuleError(NestKernelError):
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class NestModelError(NestError):
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class NestConnectError(NestError):
|
|
22
|
-
pass
|
|
1
|
+
class KernelWarning(Warning):
|
|
2
|
+
pass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class NestError(Exception):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NestKernelError(NestError):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NestModuleError(NestKernelError):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NestModelError(NestError):
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class NestConnectError(NestError):
|
|
22
|
+
pass
|
bsb_nest/simulation.py
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
from bsb import Simulation, config, types
|
|
2
|
-
|
|
3
|
-
from .cell import NestCell
|
|
4
|
-
from .connection import NestConnection
|
|
5
|
-
from .device import NestDevice
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@config.node
|
|
9
|
-
class NestSimulation(Simulation):
|
|
10
|
-
"""
|
|
11
|
-
Interface between the scaffold model and the NEST simulator.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
modules = config.list(type=str)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
from bsb import Simulation, config, types
|
|
2
|
+
|
|
3
|
+
from .cell import NestCell
|
|
4
|
+
from .connection import NestConnection
|
|
5
|
+
from .device import NestDevice
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@config.node
|
|
9
|
+
class NestSimulation(Simulation):
|
|
10
|
+
"""
|
|
11
|
+
Interface between the scaffold model and the NEST simulator.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
modules = config.list(type=str)
|
|
15
|
+
"""List of NEST modules to load at the beginning of the simulation"""
|
|
16
|
+
threads = config.attr(type=types.int(min=1), default=1)
|
|
17
|
+
"""Number of threads to use during simulation"""
|
|
18
|
+
resolution = config.attr(type=types.float(min=0.0), required=True)
|
|
19
|
+
"""Simulation time step size in milliseconds"""
|
|
20
|
+
verbosity = config.attr(type=str, default="M_ERROR")
|
|
21
|
+
"""NEST verbosity level"""
|
|
22
|
+
seed = config.attr(type=int, default=None)
|
|
23
|
+
"""Random seed for the simulations"""
|
|
24
|
+
|
|
25
|
+
cell_models = config.dict(type=NestCell, required=True)
|
|
26
|
+
connection_models = config.dict(type=NestConnection, required=True)
|
|
27
|
+
devices = config.dict(type=NestDevice, required=True)
|