Skip to content

Commit

Permalink
Add mousify mod files
Browse files Browse the repository at this point in the history
  • Loading branch information
jorblancoa committed Oct 22, 2024
1 parent 489c5db commit 22b0e73
Show file tree
Hide file tree
Showing 30 changed files with 1,069 additions and 0 deletions.
169 changes: 169 additions & 0 deletions common/mod/VecStim.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
COMMENT
/**
* @file VecStim.mod
* @brief
* @author king
* @date 2011-03-16
* @remark Copyright © BBP/EPFL 2005-2011; All rights reserved. Do not distribute without further notice.
*/
ENDCOMMENT


: Vector stream of events
NEURON {
THREADSAFE
ARTIFICIAL_CELL VecStim
RANGE ping, index, etime
}

PARAMETER {
ping = 1 (ms)
}

ASSIGNED {
index : The index(+1) of the last retrieved element. See element()
etime (ms)
space
}


VERBATIM
#if defined(NRN_VERSION_GTEQ)
#if NRN_VERSION_GTEQ(9,0,0)
#define NRN_VERSION_GTEQ_9_0_0
#endif
#endif
#ifdef STIM_DEBUG
# define debug_printf(...) printf(__VA_ARGS__)
#else
# define debug_printf(...)
#endif
ENDVERBATIM


INITIAL {
VERBATIM
#ifndef CORENEURON_BUILD
// This Mechanism is not useful for CoreNeuron, since it has its own implementation
// Therefore we should avoid even compiling it together, but for backwards compat keep guards
ENDVERBATIM
index = 0
if(element()) {
net_send(etime - t, 1)
}
if (ping > 0) {
net_send(ping, 2)
}
VERBATIM
#endif
ENDVERBATIM
}


NET_RECEIVE (w) {
if (flag == 1) { : deliver event
VERBATIM
debug_printf("[VecStim] net_event(): index=%d, etime=%g, t=%g\n", (int)index - 1, etime, t);
ENDVERBATIM
net_event(t)

: schedule next event
if (element() > 0) {
if (etime < t) {
printf("[VecStim] WARNING: spike time (%g ms) before current time (%g ms)\n",etime,t)
} else {
net_send(etime - t, 1)
}
}
} else if (flag == 2) { : ping - reset index to 0
:printf("flag=2, etime=%g, t=%g, ping=%g, index=%g\n",etime,t,ping,index)
if (index == -2) { : play() has been called
printf("[VecStim] Detected new time vector.\n")
restartEvent()
}
net_send(ping, 2)
}
}


COMMENT
/**
* Resume the event delivery loop for NEURON restore.
*/
ENDCOMMENT
PROCEDURE restartEvent() {
index = 0
VERBATIM
#ifndef CORENEURON_BUILD
while (element(_threadargs_) && etime < t) {} // Ignore past events
if (index > 0) {
// Invoke low-level artcell_net_send, since generic NMODL net_send is only
// available in INITIAL and NET_RECEIVE blocks. It takes an ABSOLUTE time instead
debug_printf("[VecStim] restartEvent(delay=%g): index=%d, etime=%g, t=%g\n", delay, (int)index - 1, etime, t);
#if defined(NRN_VERSION_GTEQ_9_0_0)
artcell_net_send(_tqitem, (double*)0, _ppvar[1].get<Point_process*>(), etime, 1.0);
#else
artcell_net_send(_tqitem, (double*)0, (Point_process*)_ppvar[1]._pvoid, etime, 1.0);
#endif
}
#endif
ENDVERBATIM
}


VERBATIM
#ifndef NRN_VERSION_GTEQ_8_2_0
extern double* vector_vec();
extern int vector_capacity();
extern void* vector_arg();
#endif
ENDVERBATIM


COMMENT
/**
* \brief Retrieves an element (spike time) from the source vector, store in etime.
*
* \return The index+1 of the element (=~ true). Otherwise 0 (not initialized or end)
*
* NOTE: For back-compat index is incremented *after* the element is retrieved, making
* it like a base-1 indexing scheme, or representing the next elements index.
*/
ENDCOMMENT
FUNCTION element() {
VERBATIM
const int i = (int)index;
IvocVect* const vv = *((IvocVect**)(&space));

int size; double* px;
if (i < 0 || vv == NULL)
return 0;

size = vector_capacity(vv);
px = vector_vec(vv);
if (i < size) {
etime = px[i];
index += 1.;
debug_printf("[VecStim] element(): index=%d, etime=%g, t=%g\n", (int)index - 1, etime, t);
return index;
}
index = -1;
return 0;
ENDVERBATIM
}


PROCEDURE play() {
VERBATIM
#ifndef CORENEURON_BUILD
void** vv;
vv = (void**)(&space);
*vv = NULL;
if (ifarg(1)) {
*vv = vector_arg(1);
}
index = -2;
#endif
ENDVERBATIM
}

29 changes: 29 additions & 0 deletions mousify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Simulation Models :: mousify
----------------------------

These hoc and mod files implement the mousify specific cell mechanism.


Versions
--------

2019.1 - First import after splitting of neurodamus and models
2021.11 - Start using aggregate neurodamus-models repo, drop common submodule


Common models
-------------

TLDR: Run `./fetch_common.bash` to init and update common.

Most Blue Brain models depend on a set of common mods, among themProbAMPANMDA and ProbGABAAB.
Previously the current repo would include them as a submodule. However, besides overly
complicating the deployment process, it could lead to situations of outdated versions of these files.

Since 2021.11 all BBP maintained models therefore drop submodules and implement a fetch_common.bash
script which will ensure that you have locally the latest common files.

Therefore, every time you wish to init or fetch updates for common, simply:

> `./fetch_common.bash`
1 change: 1 addition & 0 deletions mousify/hoc/AMPANMDAHelper.hoc
1 change: 1 addition & 0 deletions mousify/hoc/DetAMPANMDAHelper.hoc
1 change: 1 addition & 0 deletions mousify/hoc/DetGABAABHelper.hoc
1 change: 1 addition & 0 deletions mousify/hoc/GABAABHelper.hoc
1 change: 1 addition & 0 deletions mousify/hoc/GluSynapseHelper.hoc
40 changes: 40 additions & 0 deletions mousify/mod/CaDynamics.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
: Dynamics that track inside calcium concentration
: modified from Destexhe et al. 1994

NEURON {
SUFFIX CaDynamics
USEION ca READ ica WRITE cai
RANGE decay, gamma, minCai, depth
}

UNITS {
(mV) = (millivolt)
(mA) = (milliamp)
FARADAY = (faraday) (coulombs)
(molar) = (1/liter)
(mM) = (millimolar)
(um) = (micron)
}

PARAMETER {
gamma = 0.05 : percent of free calcium (not buffered)
decay = 80 (ms) : rate of removal of calcium
depth = 0.1 (um) : depth of shell
minCai = 1e-4 (mM)
}

ASSIGNED {ica (mA/cm2)}

INITIAL {
cai = minCai
}

STATE {
cai (mM)
}

BREAKPOINT { SOLVE states METHOD cnexp }

DERIVATIVE states {
cai' = -(10000)*(ica*gamma/(2*FARADAY*depth)) - (cai - minCai)/decay
}
82 changes: 82 additions & 0 deletions mousify/mod/Ca_HVA.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
: Reference: Reuveni, Friedman, Amitai, and Gutnick, J.Neurosci. 1993

NEURON {
SUFFIX Ca_HVA
USEION ca READ eca WRITE ica
RANGE gbar, g, ica
}

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

PARAMETER {
gbar = 0.00001 (S/cm2)
}

ASSIGNED {
v (mV)
eca (mV)
ica (mA/cm2)
g (S/cm2)
mInf
mTau
mAlpha
mBeta
hInf
hTau
hAlpha
hBeta
}

STATE {
m
h
}

BREAKPOINT {
SOLVE states METHOD cnexp
g = gbar*m*m*h
ica = g*(v-eca)
}

DERIVATIVE states {
rates()
m' = (mInf-m)/mTau
h' = (hInf-h)/hTau
}

INITIAL{
rates()
m = mInf
h = hInf
}

PROCEDURE rates(){
UNITSOFF
: if((v == -27) ){
: v = v+0.0001
: }
:mAlpha = (0.055*(-27-v))/(exp((-27-v)/3.8) - 1)
mAlpha = 0.055 * vtrap(-27 - v, 3.8)
mBeta = (0.94*exp((-75-v)/17))
mInf = mAlpha/(mAlpha + mBeta)
mTau = 1/(mAlpha + mBeta)
hAlpha = (0.000457*exp((-13-v)/50))
hBeta = (0.0065/(exp((-v-15)/28)+1))
hInf = hAlpha/(hAlpha + hBeta)
hTau = 1/(hAlpha + hBeta)
UNITSON
}

FUNCTION vtrap(x, y) { : Traps for 0 in denominator of rate equations
UNITSOFF
if (fabs(x / y) < 1e-6) {
vtrap = y * (1 - x / y / 2)
} else {
vtrap = x / (exp(x / y) - 1)
}
UNITSON
}
Loading

0 comments on commit 22b0e73

Please sign in to comment.