From d67fadbc1b05827041ecbb2b72f872ac1aabc932 Mon Sep 17 00:00:00 2001 From: filimarc Date: Wed, 13 Nov 2024 12:26:24 +0100 Subject: [PATCH] fix: assign correct units for Current devices --- bsb_neuron/adapter.py | 7 ++++++- bsb_neuron/devices/current_clamp.py | 2 +- bsb_neuron/devices/synapse_recorder.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bsb_neuron/adapter.py b/bsb_neuron/adapter.py index 8abc220..80b030e 100644 --- a/bsb_neuron/adapter.py +++ b/bsb_neuron/adapter.py @@ -38,9 +38,14 @@ def record(self, obj, **annotations): v = p.record(obj) def flush(segment): + if "unit" in annotations.keys(): + device_unit = annotations["unit"] + else: + device_unit = "mV" + annotations["unit"] = "mV" segment.analogsignals.append( AnalogSignal( - list(v), units="mV", sampling_period=p.dt * ms, **annotations + list(v), units=device_unit, sampling_period=p.dt * ms, **annotations ) ) diff --git a/bsb_neuron/devices/current_clamp.py b/bsb_neuron/devices/current_clamp.py index dcb4b0f..1391117 100644 --- a/bsb_neuron/devices/current_clamp.py +++ b/bsb_neuron/devices/current_clamp.py @@ -33,4 +33,4 @@ def _add_clamp(self, simdata, location, **annotations): clamp = location.section.iclamp( x=sx, delay=self.before, duration=self.duration, amplitude=self.amplitude ) - simdata.result.record(clamp._ref_i, **annotations) + simdata.result.record(clamp._ref_i, **annotations, unit="nA") diff --git a/bsb_neuron/devices/synapse_recorder.py b/bsb_neuron/devices/synapse_recorder.py index e3ed6ea..ffeb059 100644 --- a/bsb_neuron/devices/synapse_recorder.py +++ b/bsb_neuron/devices/synapse_recorder.py @@ -30,4 +30,4 @@ def implement(self, adapter, simulation, simdata): def _record_synaptic_current(result, synapse, **annotations): - result.record(synapse._pp._ref_i, **annotations) + result.record(synapse._pp._ref_i, **annotations, unit="nA")