Skip to content

Commit

Permalink
Merge branch 'master' into test_arbor_eden
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Aug 10, 2023
2 parents 3b19911 + c079c88 commit 2265bb2
Show file tree
Hide file tree
Showing 104 changed files with 2,583 additions and 2,128 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ report*.txt
/utilities/tests/*.gen.c
/utilities/tests/*_eden.py
arm64
/*ken.sh
9 changes: 8 additions & 1 deletion omv/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
__version__ = '0.2.7'
try:
import importlib.metadata

__version__ = importlib.metadata.version("OSBModelValidation")
except ImportError:
import importlib_metadata

__version__ = importlib_metadata.version("OSBModelValidation")
35 changes: 9 additions & 26 deletions omv/analyzers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,13 @@
from omv.analyzers.timeseries import TimeSeriesAnalyzer

OMVAnalyzers = {
'spike times' : SpikeAnalyzer,
'spike rate' : RateAnalyzer,
'dry': DryRunAnalyzer,
'resting': RestingAnalyzer,
'morphology': MorphologyAnalyzer,
'temperature': TemperatureAnalyzer,
'activation variables': ActivationVariableAnalyzer,
'input resistance': InputResAnalyzer,
'timeseries': TimeSeriesAnalyzer
"spike times": SpikeAnalyzer,
"spike rate": RateAnalyzer,
"dry": DryRunAnalyzer,
"resting": RestingAnalyzer,
"morphology": MorphologyAnalyzer,
"temperature": TemperatureAnalyzer,
"activation variables": ActivationVariableAnalyzer,
"input resistance": InputResAnalyzer,
"timeseries": TimeSeriesAnalyzer,
}

















38 changes: 10 additions & 28 deletions omv/analyzers/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,20 @@


class ActivationVariableAnalyzer(OMVAnalyzer):

def parse_observable(self):
if 'file' in self.observable:
f = fn.FileNodeHelper(self.observable['file'], self.omt_root)
inform('Activation variable from file',
self.observable['file'], indent=1, verbosity=1)
if "file" in self.observable:
f = fn.FileNodeHelper(self.observable["file"], self.omt_root)
inform(
"Activation variable from file",
self.observable["file"],
indent=1,
verbosity=1,
)
return f.get_timeseries()

def __call__(self):
obs = self.parse_observable()
allin = ts.all_within_bounds(obs, (0, 1))
if not allin:
inform('Activation variable outside of (0,1) interval: ',
obs, indent=1)
inform("Activation variable outside of (0,1) interval: ", obs, indent=1)
return allin




















41 changes: 25 additions & 16 deletions omv/analyzers/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,60 @@ def parse_observable(self):
pass

def __call__(self):

try:
obs = self.parse_observable()
if obs is None:
inform("Could not determine observed values")
return False
inform("Could not determine observed values")
return False
if isinstance(obs, list):
for o in obs:
if not o:
inform("Could not determine observed values")
return False

exp = self.parse_expected()

if exp is None:
inform("Could not determine expected values, value None")
return False
inform("Could not determine expected values, value None")
return False
if isinstance(exp, list):
for e in exp:
if not e:
inform("Could not determine expected values")
return False
except IOError as e:
inform("Input/output error when\
checking for observable data: %s" % e)
inform(
"Input/output error when\
checking for observable data: %s"
% e
)
return False

try:
tolerance = float(self.observable['tolerance'])
tolerance = float(self.observable["tolerance"])
except (TypeError, KeyError): # observable can be None
tolerance = 1e-1

are_close, best_tol = compare_arrays((obs, exp), tolerance)

if not are_close:
pretty_obs, pretty_exp = pretty_print_copypaste(obs,exp)
inform("Comparison of \n\
pretty_obs, pretty_exp = pretty_print_copypaste(obs, exp)
inform(
"Comparison of \n\
(observed data): %s\n\
and\n\
(expected data): %s\n\
failed against tolerance %g" %
(pretty_obs, pretty_exp, tolerance))
failed against tolerance %g"
% (pretty_obs, pretty_exp, tolerance)
)
if best_tol:
inform("A better tolerance to try is: ", best_tol, indent=1)
else:
if best_tol and best_tol < tolerance:
inform("Passed, but an even better tolerance might be: %s, as opposed to: %s (diff: %s)" % (best_tol, tolerance,(tolerance-best_tol)), indent=3, verbosity=1)
inform(
"Passed, but an even better tolerance might be: %s, as opposed to: %s (diff: %s)"
% (best_tol, tolerance, (tolerance - best_tol)),
indent=3,
verbosity=1,
)
return are_close
19 changes: 3 additions & 16 deletions omv/analyzers/dryrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,11 @@


class DryRunAnalyzer(OMVAnalyzer):

def __init__(self, ost, expected, engine, omt_root, mep_root):
inform('No mep file specified. Will only run simulation using: ',
engine, indent=1)
inform(
"No mep file specified. Will only run simulation using: ", engine, indent=1
)
self.engine = engine

def __call__(self):
return not self.engine.returncode













59 changes: 26 additions & 33 deletions omv/analyzers/input_resistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,39 @@ class InputResAnalyzer(OMVAnalyzer):
Input resistance
"""


def parseOMT(self, to_parse):
f = fn.FileNodeHelper(to_parse['file_Vm'], self.omt_root)
f_i = fn.FileNodeHelper(to_parse['file_VC_i'], self.omt_root)
inform('Calculating input resistance from files:',
(f.filename,f_i.filename), indent=1, verbosity=1)
h_voltage = to_parse.get('holding voltage', -70.)
cmd_voltage = to_parse.get('command voltage', -80.)
h_window = to_parse.get('holding window', [0., 0.])
cmd_window = to_parse.get('command window', [0., 0.])
f = fn.FileNodeHelper(to_parse["file_Vm"], self.omt_root)
f_i = fn.FileNodeHelper(to_parse["file_VC_i"], self.omt_root)
inform(
"Calculating input resistance from files:",
(f.filename, f_i.filename),
indent=1,
verbosity=1,
)
h_voltage = to_parse.get("holding voltage", -70.0)
cmd_voltage = to_parse.get("command voltage", -80.0)
h_window = to_parse.get("holding window", [0.0, 0.0])
cmd_window = to_parse.get("command window", [0.0, 0.0])

# h_window = [float(t) for t in to_parse.get('holding window', [0., 0.])[0].split()]
# cmd_window = [float(t) for t in to_parse.get('command window', [0., 0.])[0].split()]
inform('Time wondow used for detection of current injections:',
(h_window,cmd_window), indent=2, verbosity=1)
input_resistance = ts.input_resistance(f.get_timeseries(), f_i.get_timeseries(), h_window, cmd_window, (h_voltage,cmd_voltage))
inform(
"Time wondow used for detection of current injections:",
(h_window, cmd_window),
indent=2,
verbosity=1,
)
input_resistance = ts.input_resistance(
f.get_timeseries(),
f_i.get_timeseries(),
h_window,
cmd_window,
(h_voltage, cmd_voltage),
)
return input_resistance

def parse_expected(self):
return self.expected

def parse_observable(self):
return self.parseOMT(self.observable)




















28 changes: 5 additions & 23 deletions omv/analyzers/morphology.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
from omv.analyzers.analyzer import OMVAnalyzer


class MorphologyAnalyzer(OMVAnalyzer):

def before_running(self):
if 'total area' in self.expected:
base = self.observable.get('base section', 'cell[0]')
if "total area" in self.expected:
base = self.observable.get("base section", "cell[0]")
self.query = self.engine.query_area(base)

def parse_expected(self):
return self.expected['total area']
return self.expected["total area"]

def parse_observable(self):
area = float(self.engine.fetch_query(self.query))
scale = float(self.observable.get('scaling', 1))
scale = float(self.observable.get("scaling", 1))
return scale * area


















Loading

0 comments on commit 2265bb2

Please sign in to comment.