Skip to content

Commit

Permalink
Changes to configuration & NEURON adapter (#136)
Browse files Browse the repository at this point in the history
* synapses only on some dendritic labels

* connection_models, list of synapseS

* Use relay synapses, use locations

* corrected NDMA typo

* Fixed section stack overflow, changed "type" to "types

* no multiple syn from glom to goc

* bump to patch v3

* added NEURON from pip

* don't install NEURON from wget

Co-authored-by: Robin De Schepper <robin.deschepper93@gmail.com>
Co-authored-by: Robin De Schepper <robingilbert.deschepper@unipv.it>
  • Loading branch information
3 people committed Oct 19, 2020
1 parent 418a53b commit 6203e7d
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 57 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ jobs:
python: 3.6
before_install:
- export NEST_INSTALL_DIR=/home/travis/nest-$NEST_VERSION
- wget https://neuron.yale.edu/ftp/neuron/versions/v7.7/nrn-7.7.x86_64-linux.deb
- sudo dpkg -i nrn-7.7.x86_64-linux.deb
- export PYTHONPATH=/usr/local/nrn/lib/python:$PYTHONPATH
install:
- source devops/check_nest_cache.sh
- sudo apt-get install -y python3-rtree build-essential cmake cython libgsl-dev libltdl-dev libncurses-dev libreadline-dev openmpi-bin libopenmpi-dev
Expand Down
2 changes: 1 addition & 1 deletion bsb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "3.6.0b2"
__version__ = "3.6.0b4"

from .reporting import set_verbosity, report, warn
55 changes: 25 additions & 30 deletions bsb/configurations/mouse_cerebellum_cortex.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"output": {
"format": "bsb.output.HDF5Formatter",
"morphology_repository": "morphologies.hdf5",
"file": "300x_200z_130GrLThick.hdf5"
"file": "300x_200z.hdf5"
},
"network_architecture": {
"simulation_volume_x": 300.0,
Expand Down Expand Up @@ -196,12 +196,7 @@
"class": "bsb.connectivity.ConnectomeGlomerulusGolgi",
"from_cell_types": [{"type": "glomerulus", "compartments": ["soma"]}],
"to_cell_types": [{"type": "golgi_cell", "compartments": ["basal_dendrites"]}],
"detailed": true,
"contacts": {
"type": "norm",
"loc": 20,
"scale": 4
}
"detailed": true
},
"golgi_to_granule": {
"class": "bsb.connectivity.ConnectomeGolgiGranule",
Expand All @@ -220,7 +215,7 @@
"class": "bsb.connectivity.TouchDetector",
"from_cell_types": [{"type": "granule_cell", "compartments": ["ascending_axon"]}],
"to_cell_types": [{"type": "golgi_cell", "compartments": ["basal_dendrites"]}],
"compartment_intersection_radius": 2.0,
"compartment_intersection_radius": 3.0,
"synapses": {
"type": "norm",
"loc": 5,
Expand All @@ -238,7 +233,7 @@
"class": "bsb.connectivity.TouchDetector",
"from_cell_types": [{"type": "granule_cell", "compartments": ["ascending_axon"]}],
"to_cell_types": [{"type": "purkinje_cell", "compartments": ["aa_targets"]}],
"compartment_intersection_radius": 2.0,
"compartment_intersection_radius": 3.0,
"synapses": {
"type": "norm",
"loc": 4,
Expand Down Expand Up @@ -338,57 +333,57 @@
},
"connection_models": {
"glomerulus_to_granule": {
"synapse": "AMPA"
"synapses": ["AMPA", "NMDA"]
},
"glomerulus_to_golgi": {
"synapse": "AMPA_MF"
"synapses": ["AMPA_MF","NMDA"]
},
"mossy_to_glomerulus": {
"synapse": null
"synapses": []
},
"golgi_to_golgi": {
"synapse": "GABA"
"synapses": ["GABA"]
},
"ascending_axon_to_purkinje": {
"synapse": "AMPA"
"synapses": ["AMPA"]
},
"ascending_axon_to_golgi": {
"synapse": "AMPA_AA"
"synapses": ["AMPA_AA","NMDA"]
},
"parallel_fiber_to_golgi": {
"synapse": "AMPA_PF"
"synapses": ["AMPA_PF"]
},
"golgi_to_granule": {
"synapse": "GABA"
"synapses": ["GABA"]
},
"parallel_fiber_to_purkinje": {
"synapse": "AMPA"
"synapses": ["AMPA"]
},
"parallel_fiber_to_basket": {
"synapse": "AMPA"
"synapses":["AMPA", "NMDA"]
},
"parallel_fiber_to_stellate": {
"synapse": "AMPA"
"synapses": ["AMPA", "NMDA"]
},
"basket_to_purkinje": {
"synapse": "GABA"
"synapses": ["GABA"]
},
"stellate_to_purkinje": {
"synapse": "GABA"
"synapses": ["GABA"]
},
"stellate_to_stellate": {
"synapse": "GABA"
"synapses": ["GABA"]
},
"basket_to_basket": {
"synapse": "GABA"
"synapses": ["GABA"]
}
},
"devices": {
"initial": {
"io": "input",
"device": "spike_generator",
"targetting": "cell_type",
"cell_types": ["purkinje_cell", "golgi_cell", "basket_cell", "stellate_cell"],
"cell_types": ["golgi_cell", "basket_cell", "stellate_cell"],
"section_type": "dendrites",
"synapses": ["AMPA", "AMPA_PF"],
"parameters": {
Expand All @@ -404,8 +399,8 @@
"device": "spike_generator",
"targetting": "cell_type",
"cell_types": ["purkinje_cell"],
"section_type": "dendrites",
"synapses": ["AMPA", "AMPA_PF"],
"section_type": "aa_targets",
"synapses": ["AMPA"],
"parameters": {
"noise": true,
"start": 100,
Expand All @@ -419,7 +414,7 @@
"device": "spike_generator",
"targetting": "cell_type",
"cell_types": ["mossy_fibers"],
"synapses": ["AMPA", "NMDA"],
"synapses": ["AMPA", "NMDA", "AMPA_MF"],
"parameters": {
"noise": true,
"start": 100,
Expand All @@ -433,7 +428,7 @@
"targetting": "by_id",
"targets": [229, 213, 221, 228, 230, 220, 237, 203, 204, 205, 246, 212, 245],
"cell_types": ["mossy_fibers"],
"synapses": ["AMPA", "NMDA"],
"synapses": ["AMPA", "NMDA", "AMPA_MF"],
"parameters": {
"noise": false,
"start": 700,
Expand All @@ -447,7 +442,7 @@
"targetting": "by_id",
"targets": [229,213, 221, 228, 197, 270, 193, 273],
"cell_types": ["mossy_fibers"],
"synapses": ["AMPA", "NMDA"],
"synapses": ["AMPA", "NMDA", "AMPA_MF"],
"parameters": {
"noise": true,
"start": 100,
Expand Down
38 changes: 27 additions & 11 deletions bsb/simulators/neuron/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ def get_parameters(self):
class NeuronConnection(SimulationComponent):
node_name = "simulations.?.connection_models"

required = ["synapse"]
required = ["synapses"]

casts = {"synapses": list}

def validate(self):
pass

def resolve_synapses(self):
return self.synapse if isinstance(self.synapse, list) else [self.synapse]
return self.synapses


class NeuronDevice(TargetsNeurons, TargetsSections, SimulationComponent):
Expand Down Expand Up @@ -123,7 +125,7 @@ def get_pattern(self, target, cell=None, section=None, synapse=None):
+ " device does not implement any `get_pattern` function."
)

def implement(self, target, cell, section):
def implement(self, target, location):
raise NotImplementedError(
"The "
+ self.__class__.__name__
Expand All @@ -140,12 +142,12 @@ def validate_specifics(self):
def get_locations(self, target):
locations = []
if target in self.adapter.relay_scheme:
for cell_id, section_id in self.adapter.relay_scheme[target]:
for cell_id, section_id, connection in self.adapter.relay_scheme[target]:
if cell_id not in self.adapter.node_cells:
continue
cell = self.adapter.cells[cell_id]
section = cell.sections[section_id]
locations.append((cell, section))
locations.append(TargetLocation(cell, section, connection))
elif target in self.adapter.node_cells:
try:
cell = self.adapter.cells[target]
Expand All @@ -156,7 +158,7 @@ def get_locations(self, target):
)
)
sections = self.target_section(cell)
locations.extend((cell, section) for section in sections)
locations.extend(TargetLocation(cell, section) for section in sections)
return locations


Expand Down Expand Up @@ -545,8 +547,8 @@ def create_devices(self):
# Broadcast to make sure all the nodes have the same targets for each device.
targets = self.scaffold.MPI.COMM_WORLD.bcast(targets, root=0)
for target in targets:
for cell, section in device.get_locations(target):
device.implement(target, cell, section)
for location in device.get_locations(target):
device.implement(target, location)

def index_relays(self):
report("Indexing relays.")
Expand Down Expand Up @@ -584,7 +586,11 @@ def index_relays(self):
)
bin = terminal_relays
connections = connectivity_set.intersections
target = lambda c: (c.to_id, c.to_compartment.section_id)
target = lambda c: (
c.to_id,
c.to_compartment.section_id,
connection_model,
)
for id in self.scaffold.get_placement_set(from_cell_type.name).identifiers:
if id not in bin:
bin[id] = []
Expand Down Expand Up @@ -650,9 +656,9 @@ def index_relays(self):
report(
"Node",
self.pc_id,
"needs to receive from",
"needs to relay",
len(self.relay_scheme),
"relays",
"relays.",
level=4,
)

Expand Down Expand Up @@ -710,6 +716,16 @@ def get_meta(self):
return self.meta


class TargetLocation:
def __init__(self, cell, section, connection=None):
self.cell = cell
self.section = section
self.connection = connection

def get_synapses(self):
return self.connection and self.connection.synapses


class SpikeRecorder(LocationRecorder):
def get_data(self):
recording = np.array(self.recorder)
Expand Down
6 changes: 3 additions & 3 deletions bsb/simulators/neuron/devices/current_clamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


class CurrentClamp(NeuronDevice):
def implement(self, target, cell, section):
pattern = self.get_pattern(target, cell, section)
section.iclamp(**pattern)
def implement(self, target, location):
pattern = self.get_pattern(target, location)
location.section.iclamp(**pattern)

def validate_specifics(self):
pass
Expand Down
6 changes: 4 additions & 2 deletions bsb/simulators/neuron/devices/spike_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
class SpikeGenerator(NeuronDevice):
defaults = {"record": True}

def implement(self, target, cell, section):
def implement(self, target, location):
cell = location.cell
section = location.section
if not hasattr(section, "available_synapse_types"):
raise Exception(
"{} {} targetted by {} has no synapses".format(
cell.__class__.__name__, ",".join(section.labels), self.name
)
)
for synapse_type in self.synapses:
for synapse_type in location.get_synapses() or self.synapses:
if synapse_type in section.available_synapse_types:
synapse = cell.create_synapse(section, synapse_type)
pattern = self.get_pattern(target, cell, section, synapse_type)
Expand Down
11 changes: 7 additions & 4 deletions bsb/simulators/neuron/devices/synapse_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class SynapseRecorder(PatternlessDevice, NeuronDevice):
defaults = {
"record_spikes": True,
"record_current": False,
"type": None,
"types": None,
}

def boot(self):
pass

def implement(self, target, cell, section):
def implement(self, target, location):
cell = location.cell
section = location.section
print(
"Node",
self.adapter.pc_id,
Expand All @@ -31,7 +33,7 @@ def implement(self, target, cell, section):
if self.record_current:
print("Recording current...")
recorder_classes.append(SynapticCurrentRecorder)
for synapse in get_section_synapses(section, self.type):
for synapse in get_section_synapses(section, self.types):
for recorder_class in recorder_classes:
recorder = recorder_class(cell, section, synapse)
print(
Expand Down Expand Up @@ -65,9 +67,10 @@ def __init__(self, cell, section, synapse):
self.meta = {
"cell": cell.ref_id,
"section": cell.sections.index(section),
"x": point_process.get_loc(),
"x": point_process.get_segment().x,
"type": synapse._type,
}
p.pop_section()
self.vectors = self._record(synapse._point_process)

def get_data(self):
Expand Down
4 changes: 3 additions & 1 deletion bsb/simulators/neuron/devices/voltage_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
class VoltageRecorder(NeuronDevice):
casts = {"x": float}

def implement(self, target, cell, section):
def implement(self, target, location):
cell = location.cell
section = location.section
group = "voltage_recorders"
if hasattr(self, "group"):
group = self.group
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ plotly==4.1.0
pre-commit==1.21.0
black==20.8b1
sphinx_rtd_theme==0.4.3
nrn-patch==2.2.0
nrn-patch==3.0.0b0
dbbs_models==1.3.0
colour==0.1.5
errr==1.0.0
NEURON==7.8.1.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
extras_require={
"dev": ["sphinx", "sphinx_rtd_theme>=0.4.3", "pre-commit", "black==20.8b1"],
"NEURON": ["dbbs_models>=1.3.0", "nrn-patch>=2.2.0"],
"NEURON": ["dbbs_models>=1.3.1", "nrn-patch>=3.0.0b0"],
"MPI": ["mpi4py"],
},
)

0 comments on commit 6203e7d

Please sign in to comment.