bsb-arbor 6.0.0a5__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-arbor might be problematic. Click here for more details.

@@ -0,0 +1,30 @@
1
+ import arbor
2
+ from arbor import units as U
3
+ from bsb import config
4
+
5
+ from ..connection import Receiver
6
+ from ..device import ArborDevice
7
+
8
+
9
+ @config.node
10
+ class PoissonGenerator(ArborDevice, classmap_entry="poisson_generator"):
11
+ record = config.attr(type=bool, default=True)
12
+ """Flag to save the spikes generated to file."""
13
+ rate = config.attr(type=float, required=True)
14
+ """Frequency of the poisson generator."""
15
+ weight = config.attr(type=float, required=True)
16
+ """Weight of the connection between the device and its target."""
17
+ delay = config.attr(type=float, required=True)
18
+ """Delay of the transmission between the device and its target."""
19
+
20
+ def implement_probes(self, simdata, gid):
21
+ return []
22
+
23
+ def implement_generators(self, simdata, gid):
24
+ target = Receiver(self, None, [-1, -1], [-1, -1], 0).on()
25
+ gen = arbor.event_generator(
26
+ target,
27
+ self.weight,
28
+ arbor.poisson_schedule(tstart=0 * U.ms, freq=self.rate * U.Hz, seed=gid),
29
+ )
30
+ return [gen]
@@ -0,0 +1,54 @@
1
+ import arbor
2
+ from bsb.exceptions import ConfigurationError
3
+
4
+ from ..device import ArborDevice
5
+
6
+
7
+ class Probe(ArborDevice):
8
+ required = ["targetting", "probe_type"]
9
+
10
+ def get_probe_name(self):
11
+ return f"cable_probe_{self.probe_type}"
12
+
13
+ def validate_specifics(self):
14
+ if self.get_probe_name() not in vars(arbor):
15
+ raise ConfigurationError(
16
+ f"`{self.probe_type}` is not a valid probe type for `{self.name}`"
17
+ )
18
+
19
+ def implement(self, target):
20
+ probe_args = ("where", "mechanism", "ion", "state")
21
+ kwargs = dict((k, getattr(self, k)) for k in probe_args if hasattr(self, k))
22
+ return [getattr(arbor, self.get_probe_name())(**kwargs)]
23
+
24
+ def prepare_samples(self, sim, comm):
25
+ super().prepare_samples(sim, comm)
26
+ for probe_id, handle in zip(self._probe_ids, self._handles, strict=False):
27
+ self.adapter.result.add(ProbeRecorder(self, sim, probe_id, handle))
28
+
29
+
30
+ class ProbeRecorder:
31
+ def __init__(self, device, sim, probe_id, handle):
32
+ self.path = ("recorders", device.name, *probe_id)
33
+ self.meta = device.get_meta()
34
+ self.meta["probe_id"] = probe_id
35
+ self._sim = sim
36
+ self._handle = handle
37
+
38
+ def samples(self):
39
+ return self._sim.samples(self._handle)
40
+
41
+ def multi_collect(self):
42
+ for i, sample in enumerate(self.samples()):
43
+ yield ProbeRecorderSample(self, i, sample)
44
+
45
+
46
+ class ProbeRecorderSample:
47
+ def __init__(self, parent, i, sample):
48
+ self.path = tuple(list(parent.get_path()) + [i])
49
+ self.data = sample[0]
50
+ self.meta = parent.meta.copy()
51
+ self.meta["location"] = str(sample[1])
52
+
53
+ def get_data(self):
54
+ return self.data
@@ -0,0 +1,42 @@
1
+ import neo
2
+ from bsb import config
3
+
4
+ from ..device import ArborDevice
5
+
6
+
7
+ @config.node
8
+ class SpikeRecorder(ArborDevice, classmap_entry="spike_recorder"):
9
+ def boot(self):
10
+ self._gids = set()
11
+
12
+ def prepare_samples(self, simdata, comm):
13
+ super().prepare_samples(simdata, comm)
14
+ if not comm.get_rank():
15
+
16
+ def record_device_spikes(segment):
17
+ spiketrain = list()
18
+ senders = list()
19
+ for (gid, index), time in simdata.arbor_sim.spikes():
20
+ if index == 0 and gid in self._gids:
21
+ spiketrain.append(time)
22
+ senders.append(gid)
23
+ segment.spiketrains.append(
24
+ neo.SpikeTrain(
25
+ spiketrain,
26
+ units="ms",
27
+ array_annotations={"senders": senders},
28
+ t_stop=self.simulation.duration,
29
+ device=self.name,
30
+ gids=list(self._gids),
31
+ pop_size=len(self._gids),
32
+ )
33
+ )
34
+
35
+ simdata.result.create_recorder(record_device_spikes)
36
+
37
+ def implement_probes(self, simdata, gid):
38
+ self._gids.add(gid)
39
+ return []
40
+
41
+ def implement_generators(self, simdata, gid):
42
+ return []
@@ -0,0 +1,38 @@
1
+ import psutil
2
+ from bsb import Simulation, config, types
3
+
4
+ from .cell import ArborCell
5
+ from .connection import ArborConnection
6
+ from .device import ArborDevice
7
+
8
+
9
+ @config.node
10
+ class ArborSimulation(Simulation):
11
+ """
12
+ Interface between the scaffold model and the Arbor simulator.
13
+ """
14
+
15
+ resolution = config.attr(type=types.float(min=0.0), default=0.1)
16
+ """Simulation time step size in milliseconds."""
17
+ profiling = config.attr(type=bool)
18
+ """Flag to perform profiling during the simulation."""
19
+ cell_models: config._attrs.cfgdict[ArborCell] = config.dict(
20
+ type=ArborCell, required=True
21
+ )
22
+ """Dictionary of cell models in the simulation."""
23
+ connection_models: config._attrs.cfgdict[ArborConnection] = config.dict(
24
+ type=ArborConnection, required=True
25
+ )
26
+ """Dictionary of connection models in the simulation."""
27
+ devices: config._attrs.cfgdict[ArborDevice] = config.dict(
28
+ type=ArborDevice, required=True
29
+ )
30
+ """Dictionary of devices in the simulation."""
31
+
32
+ @config.property(default=1)
33
+ def threads(self):
34
+ return self._threads
35
+
36
+ @threads.setter
37
+ def threads(self, value):
38
+ self._threads = value if value != "all" else psutil.cpu_count(logical=False)
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.4
2
+ Name: bsb-arbor
3
+ Version: 6.0.0a5
4
+ Summary: Arbor simulation adapter for the BSB framework.
5
+ Author-email: Robin De Schepper <robin@alexandria.sc>, Dimitri Rodarie <dimitri.rodarie@unipv.it>
6
+ Requires-Python: >=3.10,<4
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy~=1.21
11
+ Requires-Dist: bsb-core~=6.0
12
+ Requires-Dist: arborize~=6.0
13
+ Requires-Dist: arbor~=0.10; sys_platform != 'win32'
14
+ Requires-Dist: bsb-arbor[test, docs] ; extra == "dev"
15
+ Requires-Dist: pre-commit~=3.5 ; extra == "dev"
16
+ Requires-Dist: ruff>=0.8.2 ; extra == "dev"
17
+ Requires-Dist: snakeviz~=2.1 ; extra == "dev"
18
+ Requires-Dist: furo~=2024.0 ; extra == "docs"
19
+ Requires-Dist: sphinxext-bsb~=6.0 ; extra == "docs"
20
+ Requires-Dist: bsb-core[parallel] ; extra == "test"
21
+ Requires-Dist: bsb-hdf5~=6.0 ; extra == "test"
22
+ Requires-Dist: bsb-test~=6.0 ; extra == "test"
23
+ Requires-Dist: coverage>=7.3 ; extra == "test"
24
+ Provides-Extra: dev
25
+ Provides-Extra: docs
26
+ Provides-Extra: test
27
+
28
+ [![Build Status](https://github.com/dbbs-lab/bsb-arbor/actions/workflows/main.yml/badge.svg)](https://github.com/dbbs-lab/bsb-arbor/actions/workflows/main.yml)
29
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
30
+
31
+ # bsb-arbor
32
+
33
+ bsb-arbor is a plugin of the [BSB](https://github.com/dbbs-lab/bsb) (see also
34
+ [bsb-core](https://github.com/dbbs-lab/bsb-core)).
35
+ It contains the interfaces and tools to simulate BSB circuit with the
36
+ [Arbor simulator](https://arbor-sim.org/).
@@ -0,0 +1,15 @@
1
+ bsb_arbor/__init__.py,sha256=1kJSMSgt1vnjllcKXRUfomu0XTczbqYkkRf-TjSQbP8,437
2
+ bsb_arbor/adapter.py,sha256=2aeDo_znf7_przJMDe7AqfVse9GlRA0WA8qDDJcfEqs,16136
3
+ bsb_arbor/cell.py,sha256=V4JxsdwS_FNfQ_wRjnJH-kFVLMwipzLSHcYbf-VgP_c,2476
4
+ bsb_arbor/connection.py,sha256=1u3yLA7R0G3Rxxf0Zvw3AcBa242n8XeSVej_r8iXjXY,2446
5
+ bsb_arbor/device.py,sha256=5PD6nujSlTu74BonS5Ojp7LhopusQ4cDVEEAYg1aAMA,1752
6
+ bsb_arbor/simulation.py,sha256=3aZ1qiFWytRFp5qSpLXG_Qcjf-zoXLa09GZraG8BanE,1243
7
+ bsb_arbor/devices/__init__.py,sha256=8PgEH4gktvNW7KywuFXIzZXsPuWayWt0BPuKz6sJyPA,188
8
+ bsb_arbor/devices/poisson_generator.py,sha256=PGcx1YQn6WoZ3yZGXbW0nF1gtDo1fC7KGnmFYaklR3s,1045
9
+ bsb_arbor/devices/probe.py,sha256=Dv0GiWxNUuiKRYg8wCik2xlQLvh5dJBE4e-v3-W2eLg,1732
10
+ bsb_arbor/devices/spike_recorder.py,sha256=xJ720Tg9EO71RIc54ZEN04UqUDNyyI5TliC1ZD5UHWc,1339
11
+ bsb_arbor-6.0.0a5.dist-info/entry_points.txt,sha256=8z5oyflKGOBD2smUKyrUit-_2JqBs85g8rm5YOM8SYg,43
12
+ bsb_arbor-6.0.0a5.dist-info/licenses/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
13
+ bsb_arbor-6.0.0a5.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
14
+ bsb_arbor-6.0.0a5.dist-info/METADATA,sha256=77X9S1tNYAPrkQvpC6tf4r1acY5vWCCVc35PDMgcMfo,1601
15
+ bsb_arbor-6.0.0a5.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.12.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [bsb.simulation_backends]
2
+ arbor=bsb_arbor
3
+