Skip to content

Commit

Permalink
Merging opt tutorials from 2024 bmtk-workshop
Browse files Browse the repository at this point in the history
- Updated format to match main bmtk tutorials
- Fixed typos
  • Loading branch information
beaherrera committed Oct 21, 2024
1 parent cdb42ce commit c39a025
Show file tree
Hide file tree
Showing 305 changed files with 126,889 additions and 0 deletions.
2,064 changes: 2,064 additions & 0 deletions docs/tutorial/01_opt_external_models/Ch_External_Models.ipynb

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions docs/tutorial/01_opt_external_models/Hay_Model_SingleCell.ipynb

Large diffs are not rendered by default.

1,054 changes: 1,054 additions & 0 deletions docs/tutorial/01_opt_external_models/Purkinje_morpho_1.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
number_ind_1 = dict()
number_ind_1['indiv'] = 138
number_ind_1['morfo_n'] = 1



576 changes: 576 additions & 0 deletions docs/tutorial/01_opt_external_models/R_01_final_pop.txt

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions docs/tutorial/01_opt_external_models/Synapses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from neuron import h

class Synapse_py3:
def __init__(self,source,target,section,weight = 1):

self.input = h.NetStim(0.5)
self.input.start = -10
self.input.number = 1
self.input.interval = 1e9
self.weight = weight


self.postsyns = {}

if (type(source) == type('s')):
sourcetype = source


#Purkinje cell
if sourcetype == 'pf':
if target.whatami == 'prk':
# Make a PF synapse onto a purkinje cell
# Use deterministic synapses*
self.whatami = "syn_pf2prk_det"
self.postsyns['AMPA'] = [h.PF_syn(0.5, sec=section)]
self.postsyns['AMPA'][0].tau_facil=10.8*5#
self.postsyns['AMPA'][0].tau_rec=35.1
self.postsyns['AMPA'][0].tau_1=3*2
self.postsyns['AMPA'][0].gmax = 2800
self.postsyns['AMPA'][0].U=0.13

self.nc_syn = [h.NetCon(self.input,receptor[0],0,0.1,1) for receptor in self.postsyns.values()]

elif sourcetype == 'aa':
if target.whatami == 'prk':
# Make a ascending axon synapse onto a purkinje cell
# Use deterministic synapses
self.whatami = "syn_aa2prk_det"
self.postsyns['AMPA'] = [h.PF_syn(0.5, sec=section)]
self.postsyns['AMPA'][0].tau_facil=10.8*5
self.postsyns['AMPA'][0].tau_rec=35.1*1
self.postsyns['AMPA'][0].tau_1=3*5
self.postsyns['AMPA'][0].gmax = 2800
self.postsyns['AMPA'][0].U=0.13

self.nc_syn = [h.NetCon(self.input,receptor[0],0,0.1,1) for receptor in self.postsyns.values()]

elif sourcetype == 'stl':
if target.whatami == 'prk':
self.whatami = "syn_stl2prk_alpha1"
self.postsyns['GABA'] = [h.PC_gaba_alpha1(0.5, sec=section)] # self.postsyns
self.postsyns['GABA'][0].tau_facil=4
self.postsyns['GABA'][0].tau_rec=15
self.postsyns['GABA'][0].tau_1=1
self.postsyns['GABA'][0].Erev = -60
self.postsyns['GABA'][0].gmaxA1 = 2600
self.postsyns['GABA'][0].U=0.35
self.nc_syn = [h.NetCon(self.input,receptor[0],0,0.1,1) for receptor in self.postsyns.values()]

else:
print('SOURCE TYPE DOES NOT EXIST SOMETHING WRONG!!!!!!!!!')


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions docs/tutorial/01_opt_external_models/build_network.L5_updated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from bmtk.builder.networks import NetworkBuilder

net = NetworkBuilder('L5')
net.add_nodes(
N=5,
model_type='biophysical',
model_template='hoc:L5PCtemplate',
morphology='cell3.asc'
)

net.add_nodes(
N=5,
model_type='biophysical',
model_template='hoc:HNTemplate',
morphology='HL5PN1.swc'
)


net.build()
net.save(output_dir='network_L5_updated')



virt_exc = NetworkBuilder('virt_exc')
virt_exc.add_nodes(
N=20,
model_type='virtual',
ei_type='exc'
)
conns = virt_exc.add_edges(
source=virt_exc.nodes(),
target=net.nodes(),
connection_rule=12,
model_template='Exp2Syn',
dynamics_params='AMPA_ExcToExc.json',
distance_range=[0.0, 1.0e20],
target_sections=['soma', 'basal', 'apical'],
delay=2.0,
syn_weight=0.01
)

virt_exc.build()
virt_exc.save(output_dir='network_L5_updated')
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from bmtk.builder.networks import NetworkBuilder

net = NetworkBuilder('L5')
net.add_nodes(
N=1,
model_type='biophysical',
model_template='hoc:L5PCtemplate',
morphology='cell3.asc',
model_processing='add_channels'
)


net.build()
net.save(output_dir='network_added_channels')


virt_exc = NetworkBuilder('virt_exc')
virt_exc.add_nodes(
N=20,
model_type='virtual',
ei_type='exc'
)
conns = virt_exc.add_edges(
source=virt_exc.nodes(),
target=net.nodes(),
connection_rule=12,
model_template='Exp2Syn',
dynamics_params='AMPA_ExcToExc.json',
distance_range=[0.0, 1.0e20],
target_sections=['soma', 'basal', 'apical'],
delay=2.0,
syn_weight=0.01
)

virt_exc.build()
virt_exc.save(output_dir='network_added_channels')
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import numpy as np
from bmtk.builder.networks import NetworkBuilder


net = NetworkBuilder('BAS')
net.add_nodes(
N=5,
model_type='biophysical',
model_template='python:loadBAS',
gnabar=np.random.uniform(0.10, 0.15, size=5),
gkbar=np.random.uniform(0.02, 0.04, size=5),
gl=np.random.uniform(0.0001, 0.0005, size=5),
el=np.random.uniform(-80.0, -50.0, size=5),
g_pas = 0.001,
e_pas = -65
)


net.build()
net.save(output_dir='network_BAS')


virt_exc = NetworkBuilder('virt_exc')
virt_exc.add_nodes(
N=20,
model_type='virtual',
ei_type='exc'
)
conns = virt_exc.add_edges(
source=virt_exc.nodes(),
target=net.nodes(),
connection_rule=12,
model_template='Exp2Syn',
dynamics_params='AMPA_ExcToExc.json',
distance_range=[0.0, 1.0e20],
target_sections=['soma', 'dend'],
delay=1.0,
syn_weight=0.05
)

virt_exc.build()
virt_exc.save(output_dir='network_BAS')
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from bmtk.builder.networks import NetworkBuilder

net = NetworkBuilder('L5')
net.add_nodes(
N=1,
model_type='biophysical',
model_template='hoc:L5PCtemplate',
morphology='cell3.asc',
model_processing='adjust_densities'
)


net.build()
net.save(output_dir='network_modified_densities')


virt_exc = NetworkBuilder('virt_exc')
virt_exc.add_nodes(
N=20,
model_type='virtual',
ei_type='exc'
)
conns = virt_exc.add_edges(
source=virt_exc.nodes(),
target=net.nodes(),
connection_rule=12,
model_template='Exp2Syn',
dynamics_params='AMPA_ExcToExc.json',
distance_range=[0.0, 1.0e20],
target_sections=['soma', 'basal', 'apical'],
delay=2.0,
syn_weight=0.01
)

virt_exc.build()
virt_exc.save(output_dir='network_modified_densities')
45 changes: 45 additions & 0 deletions docs/tutorial/01_opt_external_models/build_network.purkinje.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import numpy as np

from bmtk.builder.networks import NetworkBuilder


np.random.seed(100)

net = NetworkBuilder('purkinje')
net.add_nodes(
pop_name='Scnn1a',
model_type='biophysical',
model_template='python:Purkinje_morph_1',
spines_on=0
)
net.add_nodes(
pop_name='Scnn1a',
model_type='biophysical',
model_template='python:Purkinje_morph_1',
spines_on=1
)


net.build()
net.save(output_dir='network_Purkinje')


virt = NetworkBuilder('virt_exc')
virt.add_nodes(
N=5,
model_type='virtual'
)
virt.add_edges(
source=virt.nodes(), target=net.nodes(),
connection_rule=12,
syn_weight=6.4e-05,
distance_range=[50.0, 10.0e20],
target_sections=['dend'],
delay=1.0,
dynamics_params='AMPA_ExcToExc.json',
model_template='exp2syn'
)

virt.build()
virt.save(output_dir='network_Purkinje')
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
TITLE Medium duration Ca-dependent potassium current
:
: Ca++ dependent K+ current IC responsible for medium duration AHP
:
: Original file written by Alain Destexhe, Salk Institute, Nov 3, 1992
: Modified by Geir Halnes, Norwegian University of Life Sciences, Mar 13, 2011


INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)}

NEURON {
SUFFIX iahp
USEION k READ ek WRITE ik VALENCE 1
USEION Ca READ Cai VALENCE 2
RANGE gkbar, g, minf, taum
GLOBAL beta, cac, m_inf, tau_m, x
}


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


PARAMETER {
v (mV)
ek = -90 (mV)
celsius = 36 (degC)
Cai = 5e-5 (mM) : Initial [Ca]i = 50 nM (Cai is simulated by separate mod-file)
gkbar = 1.3e-4 (mho/cm2) : Conductance (modified from hoc-file)
beta = 0.02 (1/ms) : Backward rate constant
cac = 4.3478e-4(mM) : Middle point of m_inf fcn
taumin = 1 (ms) : Minimal value of the time cst
x = 2 : Binding cites
}




STATE {
m
}


ASSIGNED {
ik (mA/cm2)
g (mho/cm2)
m_inf
tau_m (ms)
minf
taum
tadj
}


BREAKPOINT {
SOLVE states METHOD cnexp
minf = m_inf
taum = tau_m
g = gkbar*m*m
ik = g * (v - ek)
}

DERIVATIVE states {
evaluate_fct(v,Cai)
m' = (m_inf - m) / tau_m
}


UNITSOFF
INITIAL {
: activation kinetics are assumed to be at 22 deg. C
: Q10 is assumed to be 3

VERBATIM
Cai = _ion_Cai;
ENDVERBATIM

tadj = 3 ^ ((celsius-22.0)/10)
evaluate_fct(v,Cai)
m = m_inf
minf = m_inf
taum = tau_m
}

PROCEDURE evaluate_fct(v(mV),Cai(mM)) { LOCAL car, tcar
car = (Cai/cac)^x
m_inf = car / ( 1 + car )
tau_m = 1 / beta / (1 + car) / tadj
if(tau_m < taumin) { tau_m = taumin } : min value of time cst
}

UNITSON
Loading

0 comments on commit c39a025

Please sign in to comment.