In [ ]:
# gsarma and travs 5/2015
# Doing some hello world testing with sciunit
# notebook from rgerkin
# http://nbviewer.ipython.org/github/scidash/neuronunit/blob/master/scratch.ipynb
In [1]:
import sciunit, sciunit.capabilities, sciunit.models, sciunit.scores
In [6]:
class EqualsTest(sciunit.Test):
"""Produces a boolean score if the model predicts
the same number as the observation."""
required_capabilities = (sciunit.capabilities.ProducesNumber,)
def generate_prediction(self, model):
return model.produce_number()
score_type = sciunit.scores.BooleanScore
def compute_score(self, observation, prediction):
return self.score_type(observation == prediction)
In [7]:
equals_one_test = EqualsTest(1)
equals_two_test = EqualsTest(2)
print equals_one_test, equals_two_test
In [8]:
one_model = sciunit.models.ConstModel(1)
two_model = sciunit.models.ConstModel(2)
three_model = sciunit.models.ConstModel(3)
print one_model, two_model, three_model
In [9]:
one_one_score = equals_one_test.judge(one_model)
one_two_score = equals_two_test.judge(one_model)
print one_one_score, one_two_score
In [10]:
print one_one_score.model, one_one_score.test
In [11]:
suite = sciunit.TestSuite("suite", [equals_one_test, equals_two_test])
In [12]:
matrix = suite.judge([one_model, two_model, three_model])
print matrix[equals_one_test]
print matrix[two_model]
In [13]:
matrix.view()
Out[13]:
In [2]:
%load_ext autoreload
%autoreload 2
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
In [4]:
from nml.jnml import *
In [1]:
run nml/jnml
In [169]:
cols = load_dat('i_65.lems')
In [170]:
plt.plot(cols[0],cols[1])
Out[170]:
In [190]:
muscle_model_xml = os.path.join(OPENWORM_HOME,'muscle_model/NeuroML2/LEMS_NeuronMuscle.xml')
ca_boyle_nml = os.path.join(OPENWORM_HOME,'muscle_model/NeuroML2/ca_boyle.channel.nml')
In [137]:
run_lems(muscle_model_xml)
Out[137]:
In [171]:
cols = load_dat('nm_v')
In [179]:
plt.plot(cols[0],cols[1],label='Neuron')
plt.plot(cols[0],cols[2],label='Muscle')
plt.xlabel('Time (s)')
plt.ylabel('Vm (V)')
plt.legend()
Out[179]:
In [226]:
run_nml(ca_boyle_nml,'NML2ChannelAnalyse',channelId='ca_boyle',
temperature=34,
minV=-55,
maxV=80,
duration=600,
clampBaseVoltage=-55,
clampDuration=580,
stepTargetVoltage=10,
erev=50,
caConc=0.001)
In [227]:
ls i*.dat
In [182]:
from BlueBrainProjectShowcase.Channelpedia import iv_analyse
In [228]:
v,_,_,i_peak = iv_analyse.main(plot=False)
In [240]:
Vs = np.arange(-55,85,10)
for V in Vs:
file_name = ('i_%d.lems' % V).replace('-','min')
cols = load_dat(file_name)
plt.plot(cols[0],cols[1],label='V = %d' % V)
plt.xlabel('Time (s)')
plt.ylabel('I (nA)')
plt.xlim(0,0.02)
plt.legend()
Out[240]:
In [241]:
capacitance = 1e-13
plt.plot(v,-np.array(i_peak)/capacitance)
Out[241]:
In [ ]: