-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extend Nest devices - Added start and stop params for poisson_generator - Added multimeter for Nest recordings. * Black fix * Fix isort. * Add senders annotation to multimeter * Add DC generator from NEST * Implement review feedback * Update bsb-core dependency
- Loading branch information
Showing
8 changed files
with
271 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.h5 | ||
|
||
# C extensions | ||
*.so | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from .dc_generator import DCGenerator | ||
from .multimeter import Multimeter | ||
from .poisson_generator import PoissonGenerator | ||
from .spike_recorder import SpikeRecorder |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import nest | ||
from bsb import config | ||
|
||
from ..device import NestDevice | ||
|
||
|
||
@config.node | ||
class DCGenerator(NestDevice, classmap_entry="dc_generator"): | ||
amplitude = config.attr(type=float, required=True) | ||
"""Current amplitude of the dc generator""" | ||
start = config.attr(type=float, required=False, default=0.0) | ||
"""Activation time in ms""" | ||
stop = config.attr(type=float, required=False, default=None) | ||
"""Deactivation time in ms. | ||
If not specified, generator will last until the end of the simulation.""" | ||
|
||
def implement(self, adapter, simulation, simdata): | ||
nodes = self.get_target_nodes(adapter, simulation, simdata) | ||
params = {"amplitude": self.amplitude, "start": self.start} | ||
if self.stop is not None and self.stop > self.start: | ||
params["stop"] = self.stop | ||
device = self.register_device(simdata, nest.Create("dc_generator", params=params)) | ||
self.connect_to_nodes(device, nodes) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import nest | ||
import quantities as pq | ||
from bsb import ConfigurationError, _util, config, types | ||
from neo import AnalogSignal | ||
|
||
from ..device import NestDevice | ||
|
||
|
||
@config.node | ||
class Multimeter(NestDevice, classmap_entry="multimeter"): | ||
weight = config.provide(1) | ||
properties: list[str] = config.attr(type=types.list(str)) | ||
"""List of properties to record in the Nest model.""" | ||
units: list[str] = config.attr(type=types.list(str)) | ||
"""List of properties' units.""" | ||
|
||
def boot(self): | ||
_util.assert_samelen(self.properties, self.units) | ||
for i in range(len(self.units)): | ||
if not self.units[i] in pq.units.__dict__.keys(): | ||
raise ConfigurationError( | ||
f"Unit {self.units[i]} not in the list of known units of quantities" | ||
) | ||
|
||
def implement(self, adapter, simulation, simdata): | ||
|
||
nodes = self.get_target_nodes(adapter, simulation, simdata) | ||
device = self.register_device( | ||
simdata, | ||
nest.Create( | ||
"multimeter", | ||
params={ | ||
"interval": self.simulation.resolution, | ||
"record_from": self.properties, | ||
}, | ||
), | ||
) | ||
self.connect_to_nodes(device, nodes) | ||
|
||
def recorder(segment): | ||
for prop, unit in zip(self.properties, self.units): | ||
segment.analogsignals.append( | ||
AnalogSignal( | ||
device.events[prop], | ||
units=pq.units.__dict__[unit], | ||
sampling_period=self.simulation.resolution * pq.ms, | ||
name=self.name, | ||
senders=device.events["senders"], | ||
) | ||
) | ||
|
||
simdata.result.create_recorder(recorder) |
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
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
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