bsb-nest 4.3.0__py2.py3-none-any.whl → 4.3.1__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 CHANGED
@@ -9,4 +9,4 @@ from .adapter import NestAdapter
9
9
  from .simulation import NestSimulation
10
10
 
11
11
  __plugin__ = SimulationBackendPlugin(Simulation=NestSimulation, Adapter=NestAdapter)
12
- __version__ = "4.3.0"
12
+ __version__ = "4.3.1"
bsb_nest/device.py CHANGED
@@ -1,7 +1,12 @@
1
+ import typing
1
2
  import warnings
2
3
 
3
4
  import nest
4
- from bsb import DeviceModel, Targetting, config, refs, types
5
+ from bsb import DeviceModel, SimulationData, Targetting, config, refs, types
6
+
7
+ if typing.TYPE_CHECKING:
8
+ from .adapter import NestAdapter
9
+ from .simulation import NestSimulation
5
10
 
6
11
 
7
12
  @config.node
@@ -24,18 +29,56 @@ class NestDevice(DeviceModel):
24
29
  receptor_type = config.attr(type=int, required=False, default=0)
25
30
  """Integer ID of the postsynaptic target receptor"""
26
31
 
27
- def get_target_nodes(self, adapter, simulation, simdata):
32
+ def get_dict_targets(
33
+ self,
34
+ adapter: "NestAdapter",
35
+ simulation: "NestSimulation",
36
+ simdata: "SimulationData",
37
+ ) -> dict:
38
+ """
39
+ Get a dictionary from a target group to its NEST Collection
40
+ for each target group of the device.
41
+
42
+ :param bsb_nest.NestAdapter adapter:
43
+ :param bsb_nest.NestSimulation simulation: Nest simulation instance
44
+ :param bsb.SimulationData simdata: Simulation data instance
45
+ :return: dictionary of device target group to NEST Collection
46
+ :rtype: dict
47
+ """
28
48
  if isinstance(self.targetting, Targetting):
29
- node_collector = self.targetting.get_targets(
30
- adapter, simulation, simdata
31
- ).values()
49
+ node_collector = self.targetting.get_targets(adapter, simulation, simdata)
32
50
  else:
33
- node_collector = (
34
- simdata.populations[model][targets]
51
+ node_collector = {
52
+ model: simdata.populations[model][targets]
35
53
  for model, targets in simdata.populations.items()
36
54
  if not self.targetting.cell_models or model in self.targetting.cell_models
37
- )
38
- return sum(node_collector, start=nest.NodeCollection())
55
+ }
56
+ return node_collector
57
+
58
+ @staticmethod
59
+ def _flatten_nodes_ids(dict_targets):
60
+ return sum(dict_targets.values(), start=nest.NodeCollection())
61
+
62
+ @staticmethod
63
+ def _invert_targets_dict(dict_targets):
64
+ return {elem: k.name for k, v in dict_targets.items() for elem in v.tolist()}
65
+
66
+ def get_target_nodes(
67
+ self,
68
+ adapter: "NestAdapter",
69
+ simulation: "NestSimulation",
70
+ simdata: "SimulationData",
71
+ ):
72
+ """
73
+ Get the NEST Collection of the targets of the device.
74
+
75
+ :param bsb_nest.NestAdapter adapter:
76
+ :param bsb_nest.NestSimulation simulation: Nest simulation instance
77
+ :param bsb.SimulationData simdata: Simulation data instance
78
+ :return: Flattened NEST collection with all the targets of the device
79
+ """
80
+ targets_dict = self.get_dict_targets(adapter, simulation, simdata)
81
+ return self._flatten_nodes_ids(targets_dict)
39
82
 
40
83
  def connect_to_nodes(self, device, nodes):
41
84
  if len(nodes) == 0:
@@ -75,5 +118,5 @@ class ExtNestDevice(NestDevice, classmap_entry="external"):
75
118
  simdata.devices[self] = device = nest.Create(
76
119
  self.nest_model, params=self.constants
77
120
  )
78
- nodes = self.get_target_nodes(adapter, simdata)
121
+ nodes = self.get_target_nodes(adapter, simulation, simdata)
79
122
  self.connect_to_nodes(device, nodes)
@@ -1,4 +1,5 @@
1
1
  import nest
2
+ import numpy as np
2
3
  import quantities as pq
3
4
  from bsb import ConfigurationError, _util, config, types
4
5
  from neo import AnalogSignal
@@ -24,7 +25,9 @@ class Multimeter(NestDevice, classmap_entry="multimeter"):
24
25
 
25
26
  def implement(self, adapter, simulation, simdata):
26
27
 
27
- nodes = self.get_target_nodes(adapter, simulation, simdata)
28
+ targets_dict = self.get_dict_targets(adapter, simulation, simdata)
29
+ nodes = self._flatten_nodes_ids(targets_dict)
30
+ inv_targets = self._invert_targets_dict(targets_dict)
28
31
  device = self.register_device(
29
32
  simdata,
30
33
  nest.Create(
@@ -38,15 +41,20 @@ class Multimeter(NestDevice, classmap_entry="multimeter"):
38
41
  self.connect_to_nodes(device, nodes)
39
42
 
40
43
  def recorder(segment):
41
- for prop, unit in zip(self.properties, self.units):
42
- segment.analogsignals.append(
43
- AnalogSignal(
44
- device.events[prop],
45
- units=pq.units.__dict__[unit],
46
- sampling_period=self.simulation.resolution * pq.ms,
47
- name=self.name,
48
- senders=device.events["senders"],
44
+ senders = device.events["senders"]
45
+ for sender in np.unique(senders):
46
+ sender_filter = senders == sender
47
+ for prop, unit in zip(self.properties, self.units):
48
+ segment.analogsignals.append(
49
+ AnalogSignal(
50
+ device.events[prop][sender_filter],
51
+ units=pq.units.__dict__[unit],
52
+ sampling_period=self.simulation.resolution * pq.ms,
53
+ name=self.name,
54
+ cell_type=inv_targets[sender],
55
+ cell_id=sender,
56
+ prop_recorded=prop,
57
+ )
49
58
  )
50
- )
51
59
 
52
60
  simdata.result.create_recorder(recorder)
@@ -35,6 +35,7 @@ class PoissonGenerator(NestDevice, classmap_entry="poisson_generator"):
35
35
  senders=sr.events["senders"],
36
36
  t_stop=simulation.duration,
37
37
  device=self.name,
38
+ pop_size=len(nodes),
38
39
  )
39
40
  )
40
41
 
@@ -1,5 +1,5 @@
1
1
  import nest
2
- from bsb import config
2
+ from bsb import ConfigurationError, config
3
3
  from neo import SpikeTrain
4
4
 
5
5
  from ..device import NestDevice
@@ -56,6 +56,7 @@ class SinusoidalPoissonGenerator(
56
56
  senders=sr.events["senders"],
57
57
  t_stop=simulation.duration,
58
58
  device=self.name,
59
+ pop_size=len(nodes),
59
60
  )
60
61
  )
61
62
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: bsb-nest
3
- Version: 4.3.0
3
+ Version: 4.3.1
4
4
  Summary: NEST simulation adapter for the BSB framework.
5
5
  Author-email: Robin De Schepper <robingilbert.deschepper@unipv.it>
6
6
  Description-Content-Type: text/markdown
@@ -1,19 +1,19 @@
1
- bsb_nest/__init__.py,sha256=La2BwDgSYXsBpvdE_GMHPLfH1bGgXK5JE4rAAh0vGuU,311
1
+ bsb_nest/__init__.py,sha256=jmNzWzEx2ygwXCcVTy7eWawQcalhBxceHFo2nAlHhd4,311
2
2
  bsb_nest/adapter.py,sha256=uwFdicGOx7mRyYlfRY89zw7re0dnv9qumli1llJ0Rok,6668
3
3
  bsb_nest/cell.py,sha256=AauERRJd5OkKVSIxbx6LO2D9L7LDA6iMFfYjxu59e4c,960
4
4
  bsb_nest/connection.py,sha256=KFMXRvSR-tN7E52Mpo7dgWjXVQQSOd1VdryRPx-NfHQ,5571
5
- bsb_nest/device.py,sha256=OXpUXJSwduUCIPxzbrAztTwLzS_tLOUvwmoqISGbYr0,2874
5
+ bsb_nest/device.py,sha256=s-cIgR2-6J1k9WqhYdZv2FfMUVnnIdmCG-lXNNPgfj8,4388
6
6
  bsb_nest/distributions.py,sha256=qAYaHJkMwaCfbTh_efoJT1hMoDHWsfQo_3SNLoD8WeA,1950
7
7
  bsb_nest/exceptions.py,sha256=NX4oiGWIshrLG1DCak_nTfI8cQI7GTdewR71qNzsXGM,264
8
8
  bsb_nest/simulation.py,sha256=MCfEhwhbl_S1WNyY-EAzW8SmVKk-nLui71jK9M3lGKw,985
9
9
  bsb_nest/devices/__init__.py,sha256=AgiHteAtWd5jhl_xB_V60oeM31fGb-DGi3WjoLZLL_E,232
10
10
  bsb_nest/devices/dc_generator.py,sha256=g-jRZorCl2yYhr5bx2I00ZlxYrblDcqVbtk0XYZzmdI,953
11
- bsb_nest/devices/multimeter.py,sha256=dLBDNCJuFIgxOZ0ssEoir7d65EW7ORS1jFNsvmU2wJ0,1811
12
- bsb_nest/devices/poisson_generator.py,sha256=SGo4jhq_rbIoB38OM5FTTYlyShxGAwWqCqAncWVB3qg,1465
13
- bsb_nest/devices/sinusoidal_poisson_generator.py,sha256=MlNSmJgkuschiUgd2RZXBl008cDWYezbXXdup0TAtJY,2191
11
+ bsb_nest/devices/multimeter.py,sha256=pM35gSCbjuAMOtj9m4r4eGusc5tnLXA0k2ZKtJMiMOc,2240
12
+ bsb_nest/devices/poisson_generator.py,sha256=7knwxFmJbV_RCg18H4wizot23fKUrvr6IhIye0BeOfA,1506
13
+ bsb_nest/devices/sinusoidal_poisson_generator.py,sha256=MEV5yJ5laKYLIy8T1W9cDbnAhFB7OPZAfaqH8ffqDwc,2252
14
14
  bsb_nest/devices/spike_recorder.py,sha256=vJ9FQqmrcF0HdLl5Jy_bt_ABCUIgF-PLVI23E76JkhY,894
15
- bsb_nest-4.3.0.dist-info/entry_points.txt,sha256=uJlX9h2VeYfAumav18IM2PTJ3FssfwDUnUmfSFdR2SA,41
16
- bsb_nest-4.3.0.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
17
- bsb_nest-4.3.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
- bsb_nest-4.3.0.dist-info/METADATA,sha256=7vrpz4RkqfZZkyYO0z4PPAPUz8BoNVTYPVMlv8mNckQ,1600
19
- bsb_nest-4.3.0.dist-info/RECORD,,
15
+ bsb_nest-4.3.1.dist-info/entry_points.txt,sha256=uJlX9h2VeYfAumav18IM2PTJ3FssfwDUnUmfSFdR2SA,41
16
+ bsb_nest-4.3.1.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
17
+ bsb_nest-4.3.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
18
+ bsb_nest-4.3.1.dist-info/METADATA,sha256=QfslnPnYKys8N2puto1YZcIBoMEkJILcHEabaWz4AVY,1600
19
+ bsb_nest-4.3.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.9.0
2
+ Generator: flit 3.10.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any