Skip to content

Commit

Permalink
Added metadata to have more info when loading result nio files (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: danilobenozzo <[email protected]>
  • Loading branch information
filimarc and danilobenozzo authored Nov 13, 2024
1 parent 38d28d4 commit 032f977
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
12 changes: 9 additions & 3 deletions bsb_neuron/devices/current_clamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ def implement(self, adapter, simulation, simdata):
for location in self.locations.get_locations(target):
if clamped:
warn(f"Multiple current clamps placed on {target}")
self._add_clamp(simdata, location)
self._add_clamp(
simdata,
location,
name=self.name,
cell_type=target.cell_model.name,
cell_id=target.id,
)
clamped = True

def _add_clamp(self, simdata, location):
def _add_clamp(self, simdata, location, **annotations):
sx = location.arc(0.5)
clamp = location.section.iclamp(
x=sx, delay=self.before, duration=self.duration, amplitude=self.amplitude
)
simdata.result.record(clamp._ref_i)
simdata.result.record(clamp._ref_i, **annotations)
13 changes: 10 additions & 3 deletions bsb_neuron/devices/synapse_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ def implement(self, adapter, simulation, simdata):
not self.synapse_types
or synapse.synapse_name in self.synapse_types
):
_record_synaptic_current(simdata.result, synapse)
_record_synaptic_current(
simdata.result,
synapse,
name=self.name,
cell_type=target.cell_model.name,
cell_id=target.id,
synapse_type=synapse.synapse_name,
)


def _record_synaptic_current(result, synapse):
result.record(synapse._pp._ref_i)
def _record_synaptic_current(result, synapse, **annotations):
result.record(synapse._pp._ref_i, **annotations)
12 changes: 9 additions & 3 deletions bsb_neuron/devices/voltage_clamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ def implement(self, adapter, simulation, simdata):
for location in self.locations.get_locations(target):
if clamped:
warnings.warn(f"Multiple voltage clamps placed on {target}")
self._add_clamp(simdata.results, location)
self._add_clamp(
simdata.results,
location,
name=self.name,
cell_type=target.cell_model.name,
cell_id=target.id,
)
clamped = True

def _add_clamp(self, results, location):
def _add_clamp(self, results, location, **annotations):
sx = location.arc(0.5)
clamp = location.section.vclamp(
voltage=self.voltage,
Expand All @@ -36,4 +42,4 @@ def _add_clamp(self, results, location):
if (v := getattr(self, k)) is not None
},
)
results.record(clamp)
results.record(clamp, **annotations)
12 changes: 9 additions & 3 deletions bsb_neuron/devices/voltage_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ def implement(self, adapter, simulation, simdata):
).items():
for target in pop:
for location in self.locations.get_locations(target):
self._add_voltage_recorder(simdata.result, location)
self._add_voltage_recorder(
simdata.result,
location,
name=self.name,
cell_type=target.cell_model.name,
cell_id=target.id,
)

def _add_voltage_recorder(self, results, location):
def _add_voltage_recorder(self, results, location, **annotations):
section = location.section
x = location.arc(0)
results.record(section(x)._ref_v)
results.record(section(x)._ref_v, **annotations)

0 comments on commit 032f977

Please sign in to comment.