Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update outdated example notebooks #339

Merged
merged 8 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ jobs:
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false

examples:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install tox-gh-actions
- name: Run tox
run: |
tox -e examples

docs:
runs-on: ubuntu-22.04
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ bin
*.ipynb_checkpoints
lib
fllog.txt
*.DS_Store
106 changes: 31 additions & 75 deletions examples/basic/basic_notebook1.ipynb

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions examples/deap/GranuleCell1/GranuleCell1.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, conductances):

def steps(step_number, parameters):

# instantiate the class
# instantiate the class
cell = GrCmono(parameters)

# no table are in use from the mod files
Expand Down Expand Up @@ -130,8 +130,7 @@ def steps(step_number, parameters):
stim3[0].dur = stimdata['stim2dur']
stim3[0].amp = stimdata['stim2amp']

# Code to record everything.

# Code to record everything.
time = h.Vector()
time.record(h._ref_t)

Expand Down
14 changes: 6 additions & 8 deletions examples/deap/GranuleCell1/GranuleCellDeap1-scoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import efel
import numpy as np
import GranuleCell1 as grcsteps
import bluepyopt.deapext

from scoop import futures

Expand All @@ -36,7 +37,6 @@
from deap import base
from deap import creator
from deap import tools
from deap import algorithms

FEATURES = ['voltage_base',
'Spikecount',
Expand Down Expand Up @@ -175,17 +175,15 @@ def uniform(lower_list, upper_list, dimensions):
toolbox.register("mate", deap.tools.cxSimulatedBinaryBounded, eta=ETA, low=LOWER, up=UPPER)
toolbox.register("mutate", deap.tools.mutPolynomialBounded, eta=ETA, low=LOWER, up=UPPER, indpb=0.1)
toolbox.register("variate", deap.algorithms.varAnd)
toolbox.register("select", plot_selector, selector=tools.selIBEA)
toolbox.register("select", plot_selector, selector=bluepyopt.deapext.tools.selIBEA)
toolbox.register("map", futures.map)
# toolbox.register("select", tools.selIBEA)
# toolbox.register("select", tools.selIBEA)

def main():
pop = toolbox.population(n=MU)
pop, logbook = algorithms.eaAlphaMuPlusLambda(pop, toolbox, MU,
None, CXPB, 1 - CXPB,
NGEN, verbose=False)
pop, logbook = bluepyopt.deapext.algorithms.eaAlphaMuPlusLambdaCheckpoint(pop, toolbox, MU,
CXPB, 1 - CXPB,
NGEN)
return pop, logbook

if __name__ == '__main__':
print main()
main()
97 changes: 52 additions & 45 deletions examples/deap/GranuleCell1/GranuleCellDeap1.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/deap/deap_efel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# The higher this value, the more spread
ETA = 10.0

# Seletor to use
# Selector to use
SELECTOR = "NSGA2"

# Number of parameters
Expand All @@ -51,7 +51,7 @@

# Create a fitness function
# By default DEAP selector will try to optimise fitness values,
# so we add a -1 weight value to minise
# so we add a -1 weight value to minimise
creator.create("Fitness", base.Fitness, weights=[-1.0] * 2)

# Create an individual that consists of a list
Expand Down
132 changes: 41 additions & 91 deletions examples/deap/deap_efel_neuron2.ipynb

Large diffs are not rendered by default.

444 changes: 397 additions & 47 deletions examples/nmc-portal/L5TTPC2.ipynb

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions examples/nmc-portal/mechanisms/Grc_kca.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
TITLE Cerebellum Granule Cell Model

COMMENT
Reference: Theta-Frequency Bursting and Resonance in Cerebellar Granule Cells:Experimental
Evidence and Modeling of a Slow K+-Dependent Mechanism
Egidio D'Angelo,Thierry Nieus,Arianna Maffei,Simona Armano,Paola Rossi,Vanni Taglietti,
Andrea Fontana and Giovanni Naldi
ENDCOMMENT

NEURON {
SUFFIX GrC_KCa
USEION k READ ek WRITE ik
USEION ca READ cai
RANGE gkbar, ik, ica, g, alpha_c, beta_c
RANGE Aalpha_c, Balpha_c, Kalpha_c
RANGE Abeta_c, Bbeta_c, Kbeta_c
RANGE c_inf, tau_c
}

UNITS {
(mA) = (milliamp)
(mV) = (millivolt)
(molar) = (1/liter)
(mM) = (millimolar)
}

PARAMETER {
Aalpha_c = 2.5 (/ms)
Balpha_c = 1.5e-3 (mM)

:Kalpha_c = -0.085 (/mV)
Kalpha_c = -11.765 (mV)

Abeta_c = 1.5 (/ms)
Bbeta_c = 0.15e-3 (mM)

:Kbeta_c = -0.085 (/mV)
Kbeta_c = -11.765 (mV)

v (mV)
cai (mM)
gkbar= 0.004 (mho/cm2)
ek = -84.69 (mV)
celsius = 30 (degC)
}

STATE {
c
}

ASSIGNED {
ik (mA/cm2)
ica (mA/cm2)

c_inf
tau_c (ms)
g (mho/cm2)
alpha_c (/ms)
beta_c (/ms)
}

INITIAL {
rate(v)
c = c_inf
}

BREAKPOINT {
SOLVE states METHOD derivimplicit
g = gkbar*c
ik = g*(v - ek)
alpha_c = alp_c(v)
beta_c = bet_c(v)
}

DERIVATIVE states {
rate(v)
c' =(c_inf - c)/tau_c
}

FUNCTION alp_c(v(mV))(/ms) { LOCAL Q10
Q10 = 3^((celsius-30(degC))/10(degC))
alp_c = Q10*Aalpha_c/(1+(Balpha_c*exp(v/Kalpha_c)/cai))
}

FUNCTION bet_c(v(mV))(/ms) { LOCAL Q10
Q10 = 3^((celsius-30(degC))/10(degC))
bet_c = Q10*Abeta_c/(1+cai/(Bbeta_c*exp(v/Kbeta_c)))
}

PROCEDURE rate(v (mV)) {LOCAL a_c, b_c
TABLE c_inf, tau_c
DEPEND Aalpha_c, Balpha_c, Kalpha_c,
Abeta_c, Bbeta_c, Kbeta_c, celsius FROM -100 TO 100 WITH 200
a_c = alp_c(v)
b_c = bet_c(v)
tau_c = 1/(a_c + b_c)
c_inf = a_c/(a_c + b_c)
}

36 changes: 36 additions & 0 deletions examples/nmc-portal/mechanisms/Grc_lkg2.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
TITLE Cerebellum Granule Cell Model

COMMENT
Reference: Theta-Frequency Bursting and Resonance in Cerebellar Granule Cells:Experimental
Evidence and Modeling of a Slow K+-Dependent Mechanism
Egidio D'Angelo,Thierry Nieus,Arianna Maffei,Simona Armano,Paola Rossi,Vanni Taglietti,
Andrea Fontana and Giovanni Naldi
ENDCOMMENT

NEURON {
SUFFIX GrC_Lkg2
NONSPECIFIC_CURRENT il
RANGE egaba, ggaba , i
}

UNITS {
(mA) = (milliamp)
(mV) = (millivolt)
}

PARAMETER {
v (mV)
ggaba = 2.17e-5 (mho/cm2)
celsius = 30 (degC)
egaba = -65 (mV)
}

ASSIGNED {
il (mA/cm2)
i (mA/cm2)
}

BREAKPOINT {
il = ggaba*(v - egaba)
i =il
}
97 changes: 97 additions & 0 deletions examples/nmc-portal/mechanisms/Grg_kv.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
TITLE Cerebellum Granule Cell Model

COMMENT
Reference: Theta-Frequency Bursting and Resonance in Cerebellar Granule Cells:Experimental
Evidence and Modeling of a Slow K+-Dependent Mechanism
Egidio D'Angelo,Thierry Nieus,Arianna Maffei,Simona Armano,Paola Rossi,Vanni Taglietti,
Andrea Fontana and Giovanni Naldi
ENDCOMMENT

NEURON {
SUFFIX GrG_KV
USEION k READ ek WRITE ik
RANGE gkbar, ik, g, alpha_n, beta_n
RANGE Aalpha_n, Kalpha_n, V0alpha_n
RANGE Abeta_n, Kbeta_n, V0beta_n
RANGE n_inf, tau_n
}

UNITS {
(mA) = (milliamp)
(mV) = (millivolt)
}

PARAMETER {
:Kbeta_n = -0.0125 (/mV)

Aalpha_n = -0.01 (/ms-mV)
Kalpha_n = -10 (mV)
V0alpha_n = -25 (mV)
Abeta_n = 0.125 (/ms)

Kbeta_n = -80 (mV)
V0beta_n = -35 (mV)
v (mV)
gkbar= 0.003 (mho/cm2)
ek = -84.69 (mV)
celsius = 30 (degC)
}

STATE {
n
}

ASSIGNED {
ik (mA/cm2)
n_inf
tau_n (ms)
g (mho/cm2)
alpha_n (/ms)
beta_n (/ms)
}

INITIAL {
rate(v)
n = n_inf
}

BREAKPOINT {
SOLVE states METHOD derivimplicit
g = gkbar*n*n*n*n
ik = g*(v - ek)
alpha_n = alp_n(v)
beta_n = bet_n(v)
}

DERIVATIVE states {
rate(v)
n' =(n_inf - n)/tau_n
}

FUNCTION alp_n(v(mV))(/ms) { LOCAL Q10
Q10 = 3^((celsius-6.3(degC))/10(degC))
alp_n = Q10*Aalpha_n*linoid(v-V0alpha_n, Kalpha_n)
}

FUNCTION bet_n(v(mV))(/ms) { LOCAL Q10
Q10 = 3^((celsius-6.3(degC))/10(degC))
bet_n = Q10*Abeta_n*exp((v-V0beta_n)/Kbeta_n)
}

PROCEDURE rate(v (mV)) {LOCAL a_n, b_n
TABLE n_inf, tau_n
DEPEND Aalpha_n, Kalpha_n, V0alpha_n,
Abeta_n, Kbeta_n, V0beta_n, celsius FROM -100 TO 100 WITH 200
a_n = alp_n(v)
b_n = bet_n(v)
tau_n = 1/(a_n + b_n)
n_inf = a_n/(a_n + b_n)
}

FUNCTION linoid(x (mV),y (mV)) (mV) {
if (fabs(x/y) < 1e-6) {
linoid = y*(1 - x/y/2)
}else{
linoid = x/(exp(x/y) - 1)
}
}
Loading
Loading