In the second chapter we tested a real ion channel model using data from the OpenWorm project. Here we'll test a reduced neuron model using data from the NeuroElectro project and from the Allen Brain Institute Cell Types database.
%matplotlib inline
import os, sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['font.size'] = 18
import quantities as pq
import sciunit
import neuronunit
from neuronunit import aibs
from neuronunit.models.reduced import ReducedModel
import quantities as pq
from neuronunit import tests as nu_tests, neuroelectro
neuron = {'nlex_id': 'nifext_50'} # Layer V pyramidal cell
tests = []
dataset_id = 354190013 # Internal ID that AIBS uses for a particular Scnn1a-Tg2-Cre
# Primary visual area, layer 5 neuron.
# Obtain the empirical rheobase current from the Allen Brain Insitute Cell Types database.
observation = aibs.get_observation(dataset_id, 'rheobase')
rheobase_test = nu_tests.RheobaseTest(observation=observation)
tests += [rheobase_test]
test_class_params = [(nu_tests.InputResistanceTest, {}),
(nu_tests.TimeConstantTest, {}),
(nu_tests.CapacitanceTest, {}),
(nu_tests.RestingPotentialTest, {}),
(nu_tests.InjectedCurrentAPWidthTest, {}),
(nu_tests.InjectedCurrentAPAmplitudeTest, {}),
(nu_tests.InjectedCurrentAPThresholdTest, {})
]
# Obtain all other parameters from neuroelectro.org.
for cls, params in test_class_params:
observation = cls.neuroelectro_summary_observation(neuron)
tests += [cls(observation, **params)]
# A hook to update all tests after the RheobaseTest to use the rheobase current (to produce exactly one AP)
def update_amplitude(test,tests,score):
rheobase = score.prediction['value']
for test in tests[1:]:
if 'Injected' in test.name:
# Set current injection to just suprathreshold
test.params['injected_square_current']['amplitude'] = rheobase*1.01
hooks = {tests[0]: {'f': update_amplitude}}
suite = sciunit.TestSuite(tests,name="vm_suite", hooks=hooks)
Getting Rheobase cached data value for from AIBS dataset 354190013 Getting Input Resistance data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Input+Resistance Getting Membrane Time Constant data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Membrane+Time+Constant Getting Cell Capacitance data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Cell+Capacitance Getting Resting membrane potential data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Resting+membrane+potential Getting Spike Half-Width data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Spike+Half-Width Getting Spike Amplitude data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Spike+Amplitude Getting Spike Threshold data values from neuroelectro.org http://neuroelectro.org/api/1/nes/?nlex=nifext_50&e__name=Spike+Threshold
# This example is from https://github.com/OpenSourceBrain/IzhikevichModel.
from pathlib import Path
LEMS_MODEL_PATH = Path(neuronunit.__path__[0]).parent / 'docs' / 'data' / 'NeuroML2' / 'LEMS_2007One.xml'
model = ReducedModel(LEMS_MODEL_PATH, name='Vanilla_Model', backend='jNeuroML')
score_matrix = suite.judge(model)
Score: Ratio = 0.41 for Vanilla_Model on RheobaseTest Score: Z = -0.53 for Vanilla_Model on InputResistanceTest Score: Z = -0.81 for Vanilla_Model on TimeConstantTest Score: Z = -0.19 for Vanilla_Model on CapacitanceTest Score: Z = 1.26 for Vanilla_Model on RestingPotentialTest Score: Z = -0.62 for Vanilla_Model on InjectedCurrentAPWidthTest Score: Z = -1.72 for Vanilla_Model on InjectedCurrentAPAmplitudeTest Score: Z = 2.39 for Vanilla_Model on InjectedCurrentAPThresholdTest
score_matrix.add_mean().T
Vanilla_Model | |
---|---|
Mean | 0.426 |
RheobaseTest | Ratio = 0.41 |
InputResistanceTest | Z = -0.53 |
TimeConstantTest | Z = -0.81 |
CapacitanceTest | Z = -0.19 |
RestingPotentialTest | Z = 1.26 |
InjectedCurrentAPWidthTest | Z = -0.62 |
InjectedCurrentAPAmplitudeTest | Z = -1.72 |
InjectedCurrentAPThresholdTest | Z = 2.39 |
models = []
for vr in np.linspace(-80, -50, 4):
model = ReducedModel(LEMS_MODEL_PATH,
name='V_rest=%dmV' % vr,
attrs={'//izhikevich2007Cell':
{'vr':'%d mV' % vr}
})
models.append(model)
models
[V_rest=-80mV (ReducedModel), V_rest=-70mV (ReducedModel), V_rest=-60mV (ReducedModel), V_rest=-50mV (ReducedModel)]
score_matrix = suite.judge(models)
Score: Ratio = 1.87 for V_rest=-80mV on RheobaseTest Score: Z = -1.04 for V_rest=-80mV on InputResistanceTest Score: Z = -1.50 for V_rest=-80mV on TimeConstantTest Score: Z = -0.22 for V_rest=-80mV on CapacitanceTest Score: Z = -1.80 for V_rest=-80mV on RestingPotentialTest Score: Z = -0.80 for V_rest=-80mV on InjectedCurrentAPWidthTest Score: Z = -1.22 for V_rest=-80mV on InjectedCurrentAPAmplitudeTest Score: Z = 1.59 for V_rest=-80mV on InjectedCurrentAPThresholdTest Score: Ratio = 1.01 for V_rest=-70mV on RheobaseTest Score: Z = -0.87 for V_rest=-70mV on InputResistanceTest Score: Z = -1.27 for V_rest=-70mV on TimeConstantTest Score: Z = -0.22 for V_rest=-70mV on CapacitanceTest Score: Z = -0.27 for V_rest=-70mV on RestingPotentialTest Score: Z = -0.71 for V_rest=-70mV on InjectedCurrentAPWidthTest Score: Z = -1.46 for V_rest=-70mV on InjectedCurrentAPAmplitudeTest Score: Z = 1.96 for V_rest=-70mV on InjectedCurrentAPThresholdTest Score: Ratio = 0.41 for V_rest=-60mV on RheobaseTest Score: Z = -0.53 for V_rest=-60mV on InputResistanceTest Score: Z = -0.81 for V_rest=-60mV on TimeConstantTest Score: Z = -0.19 for V_rest=-60mV on CapacitanceTest Score: Z = 1.26 for V_rest=-60mV on RestingPotentialTest Score: Z = -0.62 for V_rest=-60mV on InjectedCurrentAPWidthTest Score: Z = -1.72 for V_rest=-60mV on InjectedCurrentAPAmplitudeTest Score: Z = 2.39 for V_rest=-60mV on InjectedCurrentAPThresholdTest Score: Ratio = 0.08 for V_rest=-50mV on RheobaseTest Score: Z = 0.29 for V_rest=-50mV on InputResistanceTest Score: Z = 0.40 for V_rest=-50mV on TimeConstantTest Score: Z = -0.14 for V_rest=-50mV on CapacitanceTest Score: Z = 2.79 for V_rest=-50mV on RestingPotentialTest Score: Z = -0.52 for V_rest=-50mV on InjectedCurrentAPWidthTest Score: Z = -2.01 for V_rest=-50mV on InjectedCurrentAPAmplitudeTest Score: Z = 2.85 for V_rest=-50mV on InjectedCurrentAPThresholdTest
score_matrix.show_mean = True # Show the mean value across test scores.
# The mean is computed using the norm_score attribute, which is in the range [0,1] for
# all Score types
score_matrix.T
V_rest=-80mV | V_rest=-70mV | V_rest=-60mV | V_rest=-50mV | |
---|---|---|---|---|
RheobaseTest | Ratio = 1.87 | Ratio = 1.01 | Ratio = 0.41 | Ratio = 0.08 |
InputResistanceTest | Z = -1.04 | Z = -0.87 | Z = -0.53 | Z = 0.29 |
TimeConstantTest | Z = -1.50 | Z = -1.27 | Z = -0.81 | Z = 0.40 |
CapacitanceTest | Z = -0.22 | Z = -0.22 | Z = -0.19 | Z = -0.14 |
RestingPotentialTest | Z = -1.80 | Z = -0.27 | Z = 1.26 | Z = 2.79 |
InjectedCurrentAPWidthTest | Z = -0.80 | Z = -0.71 | Z = -0.62 | Z = -0.52 |
InjectedCurrentAPAmplitudeTest | Z = -1.22 | Z = -1.46 | Z = -1.72 | Z = -2.01 |
InjectedCurrentAPThresholdTest | Z = 1.59 | Z = 1.96 | Z = 2.39 | Z = 2.85 |
score_matrix['RheobaseTest']['V_rest=-60mV'].plot_vm() # Plot the rheobase current from the model with V_rest = -60 mV