From dae3b77a559c22a89bd85c062d30e8e479a2f72a Mon Sep 17 00:00:00 2001 From: Eugenio Urdapilleta Date: Mon, 23 Oct 2023 16:56:51 -0300 Subject: [PATCH] Raster plot colored by phase + bug fixes **New features** - Raster plot colored by phase - Examples based on the CA3 model using the 'colorbyPhase' option in the plotRaster **Bug fixes** - Fix voltage movie tutorial - Fix to automatically include netstims in the sim.allSimData object when plotRaster 'include' selects 'all' --- CHANGES.md | 8 + .../index.npjson | 6 + .../mod/CA1ih.mod | 64 ++++ .../mod/CA1ika.mod | 85 +++++ .../mod/CA1ikdr.mod | 60 ++++ .../mod/CA1ina.mod | 89 +++++ .../mod/MyExp2SynBB.mod | 67 ++++ .../mod/MyExp2SynNMDABB.mod | 108 ++++++ .../mod/aux_fun.inc | 43 +++ .../mod/caolmw.mod | 47 +++ .../mod/icaolmw.mod | 51 +++ .../mod/iholmw.mod | 60 ++++ .../mod/kcaolmw.mod | 52 +++ .../mod/kdrbwb.mod | 76 +++++ .../mod/nafbwb.mod | 81 +++++ .../CA3model_RasterColoredbyPhase/src/cfg.py | 34 ++ .../CA3model_RasterColoredbyPhase/src/init.py | 10 + .../src/netParams.py | 322 ++++++++++++++++++ netpyne/analysis/spikes.py | 109 +++++- netpyne/plotting/plotRaster.py | 50 ++- netpyne/plotting/plotter.py | 204 +++++++++-- netpyne/sim/setup.py | 2 +- .../voltage_movie_tut/voltage_movie_tut.py | 4 +- 23 files changed, 1590 insertions(+), 42 deletions(-) create mode 100644 examples/CA3model_RasterColoredbyPhase/index.npjson create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/CA1ih.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/CA1ika.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/CA1ikdr.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/CA1ina.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynBB.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynNMDABB.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/aux_fun.inc create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/caolmw.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/icaolmw.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/iholmw.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/kcaolmw.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/kdrbwb.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/mod/nafbwb.mod create mode 100644 examples/CA3model_RasterColoredbyPhase/src/cfg.py create mode 100644 examples/CA3model_RasterColoredbyPhase/src/init.py create mode 100644 examples/CA3model_RasterColoredbyPhase/src/netParams.py diff --git a/CHANGES.md b/CHANGES.md index 271b04b96..bdcc2a5ce 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,10 +2,18 @@ **New features** +- Raster plot colored by phase + +- Examples based on the CA3 model using the 'colorbyPhase' option in the plotRaster + **Bug fixes** - Fixed loading point cell params from legacy models (issue 607) +- Fix voltage movie tutorial + +- Fix to automatically include netstims in the sim.allSimData object when plotRaster 'include' selects 'all' + # Version 1.0.5 **New features** diff --git a/examples/CA3model_RasterColoredbyPhase/index.npjson b/examples/CA3model_RasterColoredbyPhase/index.npjson new file mode 100644 index 000000000..20c14b4a6 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/index.npjson @@ -0,0 +1,6 @@ +{ + "mod_folder": "mod", + "simConfig": "src/cfg.py", + "python_run": "src/init.py", + "netParams": "src/netParams.py" +} \ No newline at end of file diff --git a/examples/CA3model_RasterColoredbyPhase/mod/CA1ih.mod b/examples/CA3model_RasterColoredbyPhase/mod/CA1ih.mod new file mode 100644 index 000000000..93d435e30 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/CA1ih.mod @@ -0,0 +1,64 @@ +: $Id: CA1ih.mod,v 1.4 2010/12/13 21:35:47 samn Exp $ +TITLE Ih CA3 + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) +} + +NEURON { + SUFFIX hcurrent + NONSPECIFIC_CURRENT ih + RANGE g, e, v50, htau, hinf + RANGE gfactor +} + +PARAMETER { + celsius (degC) + g= 0.0001 (mho/cm2) + e= -30 (mV) + v50=-82 (mV) + gfactor = 1 +} + +STATE { + h +} + +ASSIGNED { + ih (mA/cm2) + hinf + htau (ms) + v (mV) +} + +PROCEDURE iassign () { ih=g*h*(v-e)*gfactor } + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + h'= (hinf- h)/ htau +} + +INITIAL { + rates(v) + h = hinf + iassign() +} + +PROCEDURE rates(v (mV)) { + UNITSOFF + : HCN1 + :hinf = 1/(1+exp(0.151*(v-v50))) + :htau = exp((0.033*(v+75)))/(0.011*(1+exp(0.083*(v+75)))) + + : HCN2 + hinf = 1/(1+exp((v-v50)/10.5)) + htau = (1/(exp(-14.59-0.086*v)+exp(-1.87+0.0701*v))) + UNITSON +} + diff --git a/examples/CA3model_RasterColoredbyPhase/mod/CA1ika.mod b/examples/CA3model_RasterColoredbyPhase/mod/CA1ika.mod new file mode 100644 index 000000000..9e4fe6922 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/CA1ika.mod @@ -0,0 +1,85 @@ +: $Id: CA1ika.mod,v 1.2 2010/12/01 05:06:07 samn Exp $ +TITLE Ika CA1 + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) +} + +NEURON { + SUFFIX kacurrent + NONSPECIFIC_CURRENT ika, ikad + RANGE g, gd, e, ninf, ntau, ndinf, ndtau, linf, ltau +} + +PARAMETER { + celsius (degC) + g= 0.048 (mho/cm2) + gd= 0 (mho/cm2) + e= -90 (mV) +} + +STATE { + n + nd : distal + l +} + +ASSIGNED { + v (mV) + ika (mA/cm2) + ikad (mA/cm2) + ninf + ntau (ms) + ndinf + ndtau (ms) + linf + ltau (ms) +} + +PROCEDURE iassign () { + ika=g*n*l*(v-e) + ikad=gd*nd*l*(v-e) +} + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + n'= (ninf- n)/ ntau + l'= (linf- l)/ ltau + nd'= (ndinf-nd)/ndtau +} + +INITIAL { + rates(v) + n = ninf + l = linf + iassign() +} + +PROCEDURE rates(v (mV)) { + LOCAL a, b + UNITSOFF + a = exp(-0.038*(1.5+1/(1+exp(v+40)/5))*(v-11)) + b = exp(-0.038*(0.825+1/(1+exp(v+40)/5))*(v-11)) + ntau=4*b/(1+a) + if (ntau<0.1) {ntau=0.1} + ninf=1/(1+a) + + a=exp(-0.038*(1.8+1/(1+exp(v+40)/5))*(v+1)) + b=exp(-0.038*(0.7+1/(1+exp(v+40)/5))*(v+1)) + ndtau=2*b/(1+a) + if (ndtau<0.1) {ndtau=0.1} + ndinf=1/(1+a) + + a = exp(0.11*(v+56)) + ltau=0.26*(v+50) + if (ltau<2) {ltau=2} + linf=1/(1+a) + UNITSON +} + diff --git a/examples/CA3model_RasterColoredbyPhase/mod/CA1ikdr.mod b/examples/CA3model_RasterColoredbyPhase/mod/CA1ikdr.mod new file mode 100644 index 000000000..4c5236362 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/CA1ikdr.mod @@ -0,0 +1,60 @@ +: $Id: CA1ikdr.mod,v 1.2 2010/12/01 05:10:52 samn Exp $ +TITLE IKDR CA1 + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) +} + +NEURON { + SUFFIX kdrcurrent + NONSPECIFIC_CURRENT ik + RANGE g, e, ninf, ntau +} + +PARAMETER { + celsius (degC) + g = 0.010 (mho/cm2) + e = -90 (mV) +} + +STATE { + n +} + +ASSIGNED { + v (mV) + ik (mA/cm2) + ninf + ntau (ms) +} + +PROCEDURE iassign () { ik=g*n*(v-e) } + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + n'= (ninf- n)/ ntau +} + +INITIAL { + rates(v) + n = ninf + iassign() +} + +PROCEDURE rates(v (mV)) { + LOCAL a, b + UNITSOFF + a = exp(-0.11*(v-13)) + b = exp(-0.08*(v-13)) + ntau=50*b/(1+a) + if (ntau<2) {ntau=2} + ninf=1/(1+a) + UNITSON +} + diff --git a/examples/CA3model_RasterColoredbyPhase/mod/CA1ina.mod b/examples/CA3model_RasterColoredbyPhase/mod/CA1ina.mod new file mode 100644 index 000000000..d33ab9739 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/CA1ina.mod @@ -0,0 +1,89 @@ +: $Id: CA1ina.mod,v 1.4 2010/11/30 19:50:00 samn Exp $ +TITLE INa CA1 + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) +} + +NEURON { + SUFFIX nacurrent + NONSPECIFIC_CURRENT ina + RANGE g, e, vi, ki + RANGE minf,hinf,iinf,mtau,htau,itau : testing +} + +PARAMETER { + : v (mV) + celsius (degC) + g = 0.032 (mho/cm2) + e = 55 (mV) + vi = -60 (mV) + ki = 0.8 +} + +STATE { + m + h + I : i +} + +ASSIGNED { + i (mA/cm2) + ina (mA/cm2) + minf + mtau (ms) + hinf + htau (ms) + iinf + itau (ms) + v (mV) : testing +} + +: PROCEDURE iassign () { ina=g*m*m*m*h*i*(v-e) } +PROCEDURE iassign () { i=g*m*m*m*h*I*(v-e) ina=i} + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + m' = (minf - m) / mtau + h' = (hinf - h) / htau + : i' = (iinf - i) / itau + I' = (iinf - I) / itau +} + +INITIAL { + rates(v) + h = hinf + m = minf + : i = iinf + I = iinf + iassign() : testing +} + + +PROCEDURE rates(v (mV)) { + LOCAL a, b + UNITSOFF + a = 0.4*(v+30)/(1-exp(-(v+30)/7.2)) + b = 0.124*(v+30)/(exp((v+30)/7.2)-1) + mtau=0.5/(a+b) + if (mtau<0.02) {mtau=0.02} + minf=a/(a+b) + a = 0.03*(v+45)/(1-exp(-(v+45)/1.5)) + b = 0.01*(v+45)/(exp((v+45)/1.5)-1) + htau=0.5/(a+b) + if (htau<0.5) {htau=0.5} + hinf=1/(1+exp((v+50)/4)) + a = exp(0.45*(v+66)) + b = exp(0.09*(v+66)) + itau=3000*b/(1+a) + if (itau<10) {itau=10} + iinf=(1+ki*exp((v-vi)/2))/(1+exp((v-vi)/2)) + UNITSON +} + diff --git a/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynBB.mod b/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynBB.mod new file mode 100644 index 000000000..9a68baef1 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynBB.mod @@ -0,0 +1,67 @@ +: $Id: MyExp2SynBB.mod,v 1.4 2010/12/13 21:27:51 samn Exp $ +NEURON { +: THREADSAFE + POINT_PROCESS MyExp2SynBB + RANGE tau1, tau2, e, i, g, Vwt, gmax + NONSPECIFIC_CURRENT i +} + +UNITS { + (nA) = (nanoamp) + (mV) = (millivolt) + (uS) = (microsiemens) +} + +PARAMETER { + tau1=.1 (ms) <1e-9,1e9> + tau2 = 10 (ms) <1e-9,1e9> + e=0 (mV) + gmax = 1e9 (uS) + Vwt = 0 : weight for inputs coming in from vector +} + +ASSIGNED { + v (mV) + i (nA) + g (uS) + factor + etime (ms) +} + +STATE { + A (uS) + B (uS) +} + +INITIAL { + LOCAL tp + + Vwt = 0 : testing + + if (tau1/tau2 > .9999) { + tau1 = .9999*tau2 + } + A = 0 + B = 0 + tp = (tau1*tau2)/(tau2 - tau1) * log(tau2/tau1) + factor = -exp(-tp/tau1) + exp(-tp/tau2) + factor = 1/factor +} + +BREAKPOINT { + SOLVE state METHOD cnexp + g = B - A + if (g>gmax) {g=gmax}: saturation + i = g*(v - e) +} + +DERIVATIVE state { + A' = -A/tau1 + B' = -B/tau2 +} + +NET_RECEIVE(w (uS)) {LOCAL ww + ww=w + A = A + ww*factor + B = B + ww*factor +} diff --git a/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynNMDABB.mod b/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynNMDABB.mod new file mode 100644 index 000000000..01291643a --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/MyExp2SynNMDABB.mod @@ -0,0 +1,108 @@ +: $Id: MyExp2SynNMDABB.mod,v 1.4 2010/12/13 21:28:02 samn Exp $ +NEURON { +: THREADSAFE + POINT_PROCESS MyExp2SynNMDABB + RANGE tau1, tau2, e, i, iNMDA, s, sNMDA, r, tau1NMDA, tau2NMDA, Vwt, smax, sNMDAmax + NONSPECIFIC_CURRENT i, iNMDA +} + +UNITS { + (nA) = (nanoamp) + (mV) = (millivolt) + (uS) = (microsiemens) +} + +PARAMETER { + tau1 = 0.1 (ms) <1e-9,1e9> + tau2 = 10 (ms) <1e-9,1e9> + tau1NMDA = 15 (ms) + tau2NMDA = 150 (ms) + e = 0 (mV) + mg = 1 + r = 1 + smax = 1e9 (1) + sNMDAmax = 1e9 (1) + + Vwt = 0 : weight for inputs coming in from vector +} + +ASSIGNED { + v (mV) + i (nA) + iNMDA (nA) + s (1) + sNMDA (1) + mgblock (1) + factor (1) + factor2 (1) + + etime (ms) +} + +STATE { + A (1) + B (1) + A2 (1) + B2 (1) +} + +INITIAL { + + LOCAL tp + + Vwt = 0 : testing + + if (tau1/tau2 > .9999) { + tau1 = .9999*tau2 + } + A = 0 + B = 0 + tp = (tau1*tau2)/(tau2 - tau1) * log(tau2/tau1) + factor = -exp(-tp/tau1) + exp(-tp/tau2) + factor = 1/factor + + if (tau1NMDA/tau2NMDA > .9999) { + tau1NMDA = .9999*tau2NMDA + } + A2 = 0 + B2 = 0 + tp = (tau1NMDA*tau2NMDA)/(tau2NMDA - tau1NMDA) * log(tau2NMDA/tau1NMDA) + factor2 = -exp(-tp/tau1NMDA) + exp(-tp/tau2NMDA) + factor2 = 1/factor2 +} + +BREAKPOINT { + SOLVE state METHOD cnexp + : Jahr Stevens 1990 J. Neurosci + mgblock = 1.0 / (1.0 + 0.28 * exp(-0.062(/mV) * v) ) + s = B - A + sNMDA = B2 - A2 + if (s >smax) {s =smax }: saturation + if (sNMDA>sNMDAmax) {sNMDA=sNMDAmax}: saturation + i = s * (v - e) + iNMDA = sNMDA * (v - e) * mgblock +} + +DERIVATIVE state { + A' = -A/tau1 + B' = -B/tau2 + A2' = -A2/tau1NMDA + B2' = -B2/tau2NMDA +} + +NET_RECEIVE(w (uS)) {LOCAL ww + ww=w + :printf("NMDA Spike: %g\n", t) + if(r>=0){ : if r>=0, g = AMPA + NMDA*r + A = A + factor *ww + B = B + factor *ww + A2 = A2 + factor2*ww*r + B2 = B2 + factor2*ww*r + }else{ + if(r>-1000){ : if r>-1, g = NMDA*r + A2 = A2 - factor2*ww*r + B2 = B2 - factor2*ww*r + } + : if r<0 and r<>-1, g = 0 + } +} diff --git a/examples/CA3model_RasterColoredbyPhase/mod/aux_fun.inc b/examples/CA3model_RasterColoredbyPhase/mod/aux_fun.inc new file mode 100644 index 000000000..ccb579afb --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/aux_fun.inc @@ -0,0 +1,43 @@ +: $Id: aux_fun.inc,v 1.1 2009/11/04 01:24:52 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + + + +:------------------------------------------------------------------- +FUNCTION fun1(v(mV),V0(mV),A(/ms),B(mV))(/ms) { + + fun1 = A*exp((v-V0)/B) +} + +FUNCTION fun2(v(mV),V0(mV),A(/ms),B(mV))(/ms) { + + fun2 = A/(exp((v-V0)/B)+1) +} + +FUNCTION fun3(v(mV),V0(mV),A(/ms),B(mV))(/ms) { + + if(fabs((v-V0)/B)<1e-6) { + :if(v==V0) { + fun3 = A*B/1(mV) * (1- 0.5 * (v-V0)/B) + } else { + fun3 = A/1(mV)*(v-V0)/(exp((v-V0)/B)-1) + } +} + +FUNCTION min(x,y) { if (x<=y){ min = x }else{ min = y } } +FUNCTION max(x,y) { if (x>=y){ max = x }else{ max = y } } diff --git a/examples/CA3model_RasterColoredbyPhase/mod/caolmw.mod b/examples/CA3model_RasterColoredbyPhase/mod/caolmw.mod new file mode 100644 index 000000000..3ea21a7ef --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/caolmw.mod @@ -0,0 +1,47 @@ +: $Id: caolmw.mod,v 1.2 2010/11/30 16:40:09 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mollar) = (1/liter) + (M) = (mollar) + (mM) = (millimollar) + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) +} + +NEURON { + SUFFIX Caolmw + USEION ca READ ica, cai WRITE cai + RANGE alpha, tau +} + +PARAMETER { + alpha = 0.002 (cm2-M/mA-ms) + tau = 80 (ms) +} + +ASSIGNED { ica (mA/cm2) } + +INITIAL { cai = 0 } + +STATE { cai (mM) } + +BREAKPOINT { SOLVE states METHOD cnexp } + +DERIVATIVE states { cai' = -(1000) * alpha * ica - cai/tau } diff --git a/examples/CA3model_RasterColoredbyPhase/mod/icaolmw.mod b/examples/CA3model_RasterColoredbyPhase/mod/icaolmw.mod new file mode 100644 index 000000000..51112d099 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/icaolmw.mod @@ -0,0 +1,51 @@ +: $Id: icaolmw.mod,v 1.2 2010/11/30 16:44:13 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) +} + +NEURON { + SUFFIX ICaolmw + USEION ca WRITE ica + RANGE gca,eca +} + +PARAMETER { + gca = 1 (mS/cm2) + eca = 120 (mV) +} + +ASSIGNED { + ica (mA/cm2) + v (mV) +} + +PROCEDURE iassign () { ica = (1e-3) * gca * mcainf(v)^2 * (v-eca) } + +INITIAL { + iassign() +} + +BREAKPOINT { iassign() } + +FUNCTION mcainf(v(mV)) { mcainf = fun2(v, -20, 1, -9)*1(ms) } + +INCLUDE "aux_fun.inc" diff --git a/examples/CA3model_RasterColoredbyPhase/mod/iholmw.mod b/examples/CA3model_RasterColoredbyPhase/mod/iholmw.mod new file mode 100644 index 000000000..ccd919202 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/iholmw.mod @@ -0,0 +1,60 @@ +: $Id: iholmw.mod,v 1.2 2010/11/30 16:34:22 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) +} + +NEURON { + SUFFIX Iholmw + NONSPECIFIC_CURRENT i + RANGE gh,eh +} + +PARAMETER { + gh = 0.15 (mS/cm2) + eh = -40 (mV) +} + +ASSIGNED { + v (mV) + i (mA/cm2) +} + +STATE { q } + +PROCEDURE iassign () { i = (1e-3) * gh * q * (v-eh) } + +INITIAL { + q = qinf(v) + iassign() +} + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { q' = (qinf(v)-q)/qtau(v) } + +FUNCTION qinf(v(mV)) { qinf = fun2(v, -80, 1, 10)*1(ms) } +FUNCTION qtau(v(mV))(ms) { qtau = 200(ms)/(exp((v+70(mV))/20(mV))+exp(-(v+70(mV))/20(mV))) + 5(ms) } + +INCLUDE "aux_fun.inc" diff --git a/examples/CA3model_RasterColoredbyPhase/mod/kcaolmw.mod b/examples/CA3model_RasterColoredbyPhase/mod/kcaolmw.mod new file mode 100644 index 000000000..b2368787e --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/kcaolmw.mod @@ -0,0 +1,52 @@ +: $Id: kcaolmw.mod,v 1.2 2010/11/30 16:47:18 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) + (mollar) = (1/liter) + (mM) = (millimollar) +} + +NEURON { + SUFFIX KCaolmw + USEION k WRITE ik + USEION ca READ cai + RANGE gkca,ek,kd +} + +PARAMETER { + gkca = 10 (mS/cm2) + ek = -90 (mV) + kd = 30 (mM) +} + +ASSIGNED { + cai (mM) + v (mV) + ik (mA/cm2) +} + +PROCEDURE iassign () { ik = (1e-3) * gkca * cai/(cai+kd) * (v-ek) } + +INITIAL { + iassign() +} + +BREAKPOINT { iassign() } diff --git a/examples/CA3model_RasterColoredbyPhase/mod/kdrbwb.mod b/examples/CA3model_RasterColoredbyPhase/mod/kdrbwb.mod new file mode 100644 index 000000000..fc52ae534 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/kdrbwb.mod @@ -0,0 +1,76 @@ +: $Id: kdrbwb.mod,v 1.4 2010/12/13 21:35:26 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) +} + +NEURON { + SUFFIX Kdrbwb + USEION k WRITE ik + RANGE phin,gkdr,ek + RANGE taon,ninf +} + +PARAMETER { + gkdr = 9 (mS/cm2) + ek = -90 (mV) + phin = 5 +} + +ASSIGNED { + v (mV) + ik (mA/cm2) + celsius (degC) + ninf (1) + taon (ms) +} + +STATE { n } + +PROCEDURE iassign () { ik = (1e-3) * gkdr * n^4 * (v-ek) } + +INITIAL { + rates(v) + n = ninf + iassign() +} + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + n' = (ninf-n)/taon +} + +PROCEDURE rates(v(mV)) { LOCAL an, bn, q10 + q10 = phin:^((celsius-27.0(degC))/10.0(degC)) + + an = fun3(v, -34, -0.01, -10) + bn = fun1(v, -44, 0.125, -80) + + ninf = an/(an+bn) + taon = 1./((an+bn)*q10) +} + +INCLUDE "aux_fun.inc" diff --git a/examples/CA3model_RasterColoredbyPhase/mod/nafbwb.mod b/examples/CA3model_RasterColoredbyPhase/mod/nafbwb.mod new file mode 100644 index 000000000..37281dc94 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/mod/nafbwb.mod @@ -0,0 +1,81 @@ +: $Id: nafbwb.mod,v 1.4 2010/12/13 21:35:08 samn Exp $ +COMMENT + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// +// NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE +// +// Copyright 2007, The University Of Pennsylvania +// School of Engineering & Applied Science. +// All rights reserved. +// For research use only; commercial use prohibited. +// Distribution without permission of Maciej T. Lazarewicz not permitted. +// mlazarew@seas.upenn.edu +// +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +ENDCOMMENT + +UNITS { + (mA) = (milliamp) + (mV) = (millivolt) + (mS) = (millisiemens) +} + +NEURON { + SUFFIX Nafbwb + USEION na WRITE ina + RANGE phih + RANGE gna, ena, taoh : testing +} + +PARAMETER { + gna = 35 (mS/cm2) + ena = 55 (mV) + phih = 5 +} + +ASSIGNED { + v (mV) + ina (mA/cm2) + minf (1) + hinf (1) + taoh (ms) + celsius (degC) +} + +STATE { h } + +PROCEDURE iassign () { ina = (1e-3) * gna * minf^3 * h * (v-ena) } + +INITIAL { + rates(v) + h = hinf + iassign() +} + +BREAKPOINT { + SOLVE states METHOD cnexp + iassign() +} + +DERIVATIVE states { + rates(v) + h' = (hinf-h)/taoh +} + +PROCEDURE rates(v(mV)) { LOCAL am, bm, ah, bh, q10 + + q10 = phih:^((celsius-27.0(degC))/10.0(degC)) + + am = fun3(v, -35, -0.1, -10) + bm = fun1(v, -60, 4, -18) + minf = am/(am+bm) + + ah = fun1(v, -58, 0.07, -20) + bh = fun2(v, -28, 1, -10) + hinf = ah/(ah+bh) + taoh = 1./((ah+bh)*q10) +} + +INCLUDE "aux_fun.inc" diff --git a/examples/CA3model_RasterColoredbyPhase/src/cfg.py b/examples/CA3model_RasterColoredbyPhase/src/cfg.py new file mode 100644 index 000000000..85483afd6 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/src/cfg.py @@ -0,0 +1,34 @@ +from netpyne import specs + +cfg = specs.SimConfig() + +cfg.duration = 750 +cfg.dt = 0.1 +cfg.hparams = {'v_init': -65.0} +cfg.verbose = False +cfg.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'}} # Dict with traces to record +cfg.recordStim = False +cfg.recordStep = 0.1 # Step size in ms to save data (eg. V traces, LFP, etc) +cfg.filename = '00' # Set file output name +cfg.savePickle = False # Save params, network and sim output to pickle file +cfg.saveDat = False +cfg.printRunTime = 0.1 +cfg.recordLFP = [[50, 50, 50]] + +cfg.analysis['plotRaster']={ + 'colorbyPhase':{ +# 'signal': LFP_array, # when signal is provided as a np.array +# 'signal': 'LFP_signal.pkl', # when signal is provided as a list in a .pkl +# 'fs': 10000, # in both cases, sampling frequency would be neccessary + 'signal': 'LFP', # internal signal, from the computation of LFPs + 'electrode':1, + 'filtFreq':[4,8], + 'filtOrder': 3, + 'pop_background': True, + 'include_signal': True + }, + 'include':['allCells'], + 'saveFig':True, 'timeRange': [100,600]} # Plot a raster +cfg.analysis['plotTraces'] = {'include': [0, 1, 800, 801, 1000, 1001], 'saveFig': True} # Plot recorded traces for this list of cells +cfg.analysis['plotLFPTimeSeries'] = {'showFig': True, 'saveFig': True} +#cfg.analysis['plotShape'] = {'includePre': ['all'],'includePost': [0,800,1000],'cvar':'numSyns','dist':0.7, 'saveFig': True} diff --git a/examples/CA3model_RasterColoredbyPhase/src/init.py b/examples/CA3model_RasterColoredbyPhase/src/init.py new file mode 100644 index 000000000..5c371b5c4 --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/src/init.py @@ -0,0 +1,10 @@ +""" +init.py + +Starting script to run NetPyNE-based CA3 model. +""" + +from netpyne import sim + +cfg, netParams = sim.loadFromIndexFile('index.npjson') +sim.createSimulateAnalyze(netParams, cfg) diff --git a/examples/CA3model_RasterColoredbyPhase/src/netParams.py b/examples/CA3model_RasterColoredbyPhase/src/netParams.py new file mode 100644 index 000000000..083a02dde --- /dev/null +++ b/examples/CA3model_RasterColoredbyPhase/src/netParams.py @@ -0,0 +1,322 @@ +from netpyne import specs +try: + from __main__ import cfg +except: + from cfg import cfg + +# Network parameters +netParams = specs.NetParams() # object of class NetParams to store the network parameters +netParams.defaultThreshold = 0.0 +netParams.defineCellShapes = True # sets 3d geometry aligned along the y-axis + + +############################################################################### +## Cell types +############################################################################### +# Basket cell +BasketCell = {'secs':{}} +BasketCell['secs']['soma'] = {'geom': {}, 'mechs': {}} +BasketCell['secs']['soma']['geom'] = {'diam': 100, 'L': 31.831, 'nseg': 1, 'cm': 1} +BasketCell['secs']['soma']['mechs'] = {'pas': {'g': 0.1e-3, 'e': -65}, 'Nafbwb': {}, 'Kdrbwb': {}} +netParams.cellParams['BasketCell'] = BasketCell + + +# OLM cell +OlmCell = {'secs':{}} +OlmCell['secs']['soma'] = {'geom': {}, 'mechs': {}} +OlmCell['secs']['soma']['geom'] = {'diam': 100, 'L': 31.831, 'nseg': 1, 'cm': 1} +OlmCell['secs']['soma']['mechs'] = { + 'pas': {'g': 0.1e-3, 'e': -65}, + 'Nafbwb': {}, + 'Kdrbwb': {}, + 'Iholmw': {}, + 'Caolmw': {}, + 'ICaolmw': {}, + 'KCaolmw': {}} +netParams.cellParams['OlmCell'] = OlmCell + + +# Pyramidal cell +PyrCell = {'secs':{}} +PyrCell['secs']['soma'] = {'geom': {}, 'mechs': {}} +PyrCell['secs']['soma']['geom'] = {'diam': 20, 'L': 20, 'cm': 1, 'Ra': 150} +PyrCell['secs']['soma']['mechs'] = { + 'pas': {'g': 0.0000357, 'e': -70}, + 'nacurrent': {}, + 'kacurrent': {}, + 'kdrcurrent': {}, + 'hcurrent': {}} +PyrCell['secs']['Bdend'] = {'geom': {}, 'mechs': {}} +PyrCell['secs']['Bdend']['geom'] = {'diam': 2, 'L': 200, 'cm': 1, 'Ra': 150} +PyrCell['secs']['Bdend']['topol'] = {'parentSec': 'soma', 'parentX': 0, 'childX': 0} +PyrCell['secs']['Bdend']['mechs'] = { + 'pas': {'g': 0.0000357, 'e': -70}, + 'nacurrent': {'ki': 1}, + 'kacurrent': {}, + 'kdrcurrent': {}, + 'hcurrent': {}} +PyrCell['secs']['Adend1'] = {'geom': {}, 'mechs': {}} +PyrCell['secs']['Adend1']['geom'] = {'diam': 2, 'L': 150, 'cm': 1, 'Ra': 150} +PyrCell['secs']['Adend1']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0} # here there is a change: connected to end soma(1) instead of soma(0.5) +PyrCell['secs']['Adend1']['mechs'] = { + 'pas': {'g': 0.0000357, 'e': -70}, + 'nacurrent': {'ki': 0.5}, + 'kacurrent': {'g': 0.072}, + 'kdrcurrent': {}, + 'hcurrent': {'v50': -82, 'g': 0.0002}} +PyrCell['secs']['Adend2'] = {'geom': {}, 'mechs': {}} +PyrCell['secs']['Adend2']['geom'] = {'diam': 2, 'L': 150, 'cm': 1, 'Ra': 150} +PyrCell['secs']['Adend2']['topol'] = {'parentSec': 'Adend1', 'parentX': 1, 'childX': 0} +PyrCell['secs']['Adend2']['mechs'] = { + 'pas': {'g': 0.0000357, 'e': -70}, + 'nacurrent': {'ki': 0.5}, + 'kacurrent': {'g': 0, 'gd': 0.120}, + 'kdrcurrent': {}, + 'hcurrent': {'v50': -90, 'g': 0.0004}} +PyrCell['secs']['Adend3'] = {'geom': {}, 'mechs': {}} +PyrCell['secs']['Adend3']['geom'] = {'diam': 2, 'L': 150, 'cm': 2, 'Ra': 150} +PyrCell['secs']['Adend3']['topol'] = {'parentSec': 'Adend2', 'parentX': 1, 'childX': 0} +PyrCell['secs']['Adend3']['mechs'] = { + 'pas': {'g': 0.0000714, 'e': -70}, + 'nacurrent': {'ki': 0.5}, + 'kacurrent': {'g': 0, 'gd': 0.200}, + 'kdrcurrent': {}, + 'hcurrent': {'v50': -90, 'g': 0.0007}} +netParams.cellParams['PyrCell'] = PyrCell + + +############################################################################### +## Synaptic mechs +############################################################################### + +netParams.synMechParams['AMPAf'] = {'mod': 'MyExp2SynBB', 'tau1': 0.05, 'tau2': 5.3, 'e': 0} +netParams.synMechParams['NMDA'] = {'mod': 'MyExp2SynNMDABB', 'tau1': 0.05, 'tau2': 5.3, 'tau1NMDA': 15, 'tau2NMDA': 150, 'r': 1, 'e': 0} +netParams.synMechParams['GABAf'] = {'mod': 'MyExp2SynBB', 'tau1': 0.07, 'tau2': 9.1, 'e': -80} +netParams.synMechParams['GABAs'] = {'mod': 'MyExp2SynBB', 'tau1': 0.2, 'tau2': 20, 'e': -80} +netParams.synMechParams['GABAss'] = {'mod': 'MyExp2SynBB', 'tau1': 20, 'tau2': 40, 'e': -80} + + +############################################################################### +## Populations +############################################################################### +netParams.popParams['PYR'] = {'cellType': 'PyrCell', 'numCells': 800} +netParams.popParams['BC'] = {'cellType': 'BasketCell', 'numCells': 200} +netParams.popParams['OLM'] = {'cellType': 'OlmCell', 'numCells': 200} + + +############################################################################### +# Current-clamp to cells +############################################################################### +netParams.stimSourceParams['IClamp_PYR'] = {'type': 'IClamp', 'del': 2*cfg.dt, 'dur': 1e9, 'amp': 50e-3} +netParams.stimSourceParams['IClamp_OLM'] = {'type': 'IClamp', 'del': 2*cfg.dt, 'dur': 1e9, 'amp': -25e-3} + +netParams.stimTargetParams['IClamp_PYR->PYR'] = { + 'source': 'IClamp_PYR', + 'sec': 'soma', + 'loc': 0.5, + 'conds': {'pop': 'PYR'}} + +netParams.stimTargetParams['IClamp_OLM->OLM'] = { + 'source': 'IClamp_OLM', + 'sec': 'soma', + 'loc': 0.5, + 'conds': {'pop': 'OLM'}} + + +############################################################################### +# Setting connections +############################################################################### + +# PYR -> X, NMDA +netParams.connParams['PYR->BC_NMDA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'BC'}, + 'convergence': 100, + 'weight': 1.38e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'NMDA'} + +netParams.connParams['PYR->OLM_NMDA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'OLM'}, + 'convergence': 10, + 'weight': 0.7e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'NMDA'} + +netParams.connParams['PYR->PYR_NMDA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'PYR'}, + 'convergence': 25, + 'weight': 0.004e-3, + 'delay': 2, + 'sec': 'Bdend', + 'loc': 1.0, + 'synMech': 'NMDA'} + +# PYR -> X, AMPA +netParams.connParams['PYR->BC_AMPA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'BC'}, + 'convergence': 100, + 'weight': 0.36e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'AMPAf'} + +netParams.connParams['PYR->OLM_AMPA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'OLM'}, + 'convergence': 10, + 'weight': 0.36e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'AMPAf'} + +netParams.connParams['PYR->PYR_AMPA'] = {'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'PYR'}, + 'convergence': 25, + 'weight': 0.02e-3, + 'delay': 2, + 'sec': 'Bdend', + 'loc': 1.0, + 'synMech': 'AMPAf'} + +# BC -> X, GABA +netParams.connParams['BC->BC_GABA'] = {'preConds': {'pop': 'BC'}, 'postConds': {'pop': 'BC'}, + 'convergence': 60, + 'weight':4.5e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'GABAf'} + +netParams.connParams['BC->PYR_GABA'] = {'preConds': {'pop': 'BC'}, 'postConds': {'pop': 'PYR'}, + 'convergence': 50, + 'weight': 0.72e-3, + 'delay': 2, + 'sec': 'soma', + 'loc': 0.5, + 'synMech': 'GABAf'} + + +# OLM -> PYR, GABA +netParams.connParams['OLM->PYR_GABA'] = {'preConds': {'pop': 'OLM'}, 'postConds': {'pop': 'PYR'}, + 'convergence': 20, + 'weight': 72e-3, + 'delay': 2, + 'sec': 'Adend2', + 'loc': 0.5, + 'synMech': 'GABAs'} + + +############################################################################### +# Setting NetStims +############################################################################### +# to PYR +netParams.stimSourceParams['NetStim_PYR_SOMA_AMPA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_PYR_SOMA_AMPA->PYR'] = { + 'source': 'NetStim_PYR_SOMA_AMPA', + 'conds': {'pop': 'PYR'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 4*0.05e-3, # different from published value + 'delay': 2*cfg.dt, + 'synMech': 'AMPAf'} + +netParams.stimSourceParams['NetStim_PYR_ADEND3_AMPA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_PYR_ADEND3_AMPA->PYR'] = { + 'source': 'NetStim_PYR_ADEND3_AMPA', + 'conds': {'pop': 'PYR'}, + 'sec': 'Adend3', + 'loc': 0.5, + 'weight': 4*0.05e-3, # different from published value + 'delay': 2*cfg.dt, + 'synMech': 'AMPAf'} + +netParams.stimSourceParams['NetStim_PYR_SOMA_GABA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_PYR_SOMA_GABA->PYR'] = { + 'source': 'NetStim_PYR_SOMA_GABA', + 'conds': {'pop': 'PYR'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 0.012e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAf'} + +netParams.stimSourceParams['NetStim_PYR_ADEND3_GABA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_PYR_ADEND3_GABA->PYR'] = { + 'source': 'NetStim_PYR_ADEND3_GABA', + 'conds': {'pop': 'PYR'}, + 'sec': 'Adend3', + 'loc': 0.5, + 'weight': 0.012e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAf'} + +netParams.stimSourceParams['NetStim_PYR_ADEND3_NMDA'] = {'type': 'NetStim', 'interval': 100, 'number': int((1000/100.0)*cfg.duration), 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_PYR_ADEND3_NMDA->PYR'] = { + 'source': 'NetStim_PYR_ADEND3_NMDA', + 'conds': {'pop': 'PYR'}, + 'sec': 'Adend3', + 'loc': 0.5, + 'weight': 6.5e-3, + 'delay': 2*cfg.dt, + 'synMech': 'NMDA'} + +# to BC +netParams.stimSourceParams['NetStim_BC_SOMA_AMPA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_BC_SOMA_AMPA->BC'] = { + 'source': 'NetStim_BC_SOMA_AMPA', + 'conds': {'pop': 'BC'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 0.02e-3, + 'delay': 2*cfg.dt, + 'synMech': 'AMPAf'} + +netParams.stimSourceParams['NetStim_BC_SOMA_GABA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_BC_SOMA_GABA->BC'] = { + 'source': 'NetStim_BC_SOMA_GABA', + 'conds': {'pop': 'BC'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 0.2e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAf'} + +# to OLM +netParams.stimSourceParams['NetStim_OLM_SOMA_AMPA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_OLM_SOMA_AMPA->OLM'] = { + 'source': 'NetStim_OLM_SOMA_AMPA', + 'conds': {'pop': 'OLM'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 0.0625e-3, + 'delay': 2*cfg.dt, + 'synMech': 'AMPAf'} + +netParams.stimSourceParams['NetStim_OLM_SOMA_GABA'] = {'type': 'NetStim', 'interval': 1, 'number': 1000*cfg.duration, 'start': 0, 'noise': 1} +netParams.stimTargetParams['NetStim_OLM_SOMA_GABA->OLM'] = { + 'source': 'NetStim_OLM_SOMA_GABA', + 'conds': {'pop': 'OLM'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 0.2e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAf'} + +# Medial Septal inputs to BC and OLM cells +netParams.stimSourceParams['Septal'] = {'type': 'NetStim', 'interval': 150, 'number': int((1000/150)*cfg.duration), 'start': 0, 'noise': 0} +netParams.stimTargetParams['Septal->BC'] = { + 'source': 'Septal', + 'conds': {'pop': 'BC'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 1.6e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAss'} + +netParams.stimTargetParams['Septal->OLM'] = { + 'source': 'Septal', + 'conds': {'pop': 'OLM'}, + 'sec': 'soma', + 'loc': 0.5, + 'weight': 1.6e-3, + 'delay': 2*cfg.dt, + 'synMech': 'GABAss'} diff --git a/netpyne/analysis/spikes.py b/netpyne/analysis/spikes.py index bfc510199..39bb9c403 100644 --- a/netpyne/analysis/spikes.py +++ b/netpyne/analysis/spikes.py @@ -49,7 +49,7 @@ def prepareSpikeData( fileDesc=None, fileType=None, fileDir=None, - calculatePhase=False, + colorbyPhase=None, **kwargs ): """ @@ -157,6 +157,105 @@ def prepareSpikeData( sel = pd.concat([sel, ns]) numNetStims += len(spkindsNew) + # Calculating Phase of spikes + if isinstance(colorbyPhase,dict): + + try: + Signal = colorbyPhase['signal'] + except: + print("Importing signal for coloring spikes - No information about the signal") + Signal = 'LFP' + + if isinstance(Signal, basestring) or isinstance(Signal,np.ndarray): + from scipy import signal, stats, interpolate + from scipy.signal import hilbert + from math import fmod, pi + + rawSignal = [] + if isinstance(Signal, basestring): + # signal provided as a list packed in a pkl + if Signal.endswith('.pkl'): + import pickle + + with open(Signal, 'rb') as input_file: + rawSignal = pickle.load(input_file) + + try: + fs = colorbyPhase['fs'] + except: + print("Importing signal for coloring spikes - No frequency sampling provided") + fs = 1000.0 # assumes data sampled in ms + + time = np.linspace(0,len(rawSignal)*1000/fs,len(rawSignal)+1) # in milliseconds + + elif Signal == 'LFP': + try: + electrode = colorbyPhase['electrode'] + if electrode > sim.net.recXElectrode.nsites: + print('Wrong electrode number for coloring spikes according to LFP phase - Assigning first element in LFP recording setup') + electrode = 1 + except: + electrode = 1 + + rawSignal = [sim.allSimData['LFP'][n][electrode-1] for n in range(len(sim.allSimData['LFP']))] + fs = 1000.0/sim.cfg.recordStep + time = np.linspace(0,len(rawSignal)*1000/fs,len(rawSignal)+1) # in milliseconds + + else: + print('No signal recovered to color spikes according to its phase') + + # it is an array + else: + rawSignal = Signal.tolist() + try: + fs = colorbyPhase['fs'] + except: + print("Importing signal for coloring spikes - No frequency sampling provided") + fs = 1000.0 # assumes data sampled in ms + + time = np.linspace(0,len(rawSignal)*1000/fs,len(rawSignal)+1) # in milliseconds + + # Processing rawSignal + rawSignal.append(2*rawSignal[-1]-rawSignal[-2]) # extrapolation for the last element + rawSignal = stats.zscore(np.float32(rawSignal)) + rawSignal_ = np.r_[rawSignal[-1::-1],rawSignal,rawSignal[-1::-1]] # Reflect signal to minimize edge artifacts + + nyquist = fs/2.0 + + # parameters provided to filter the signal - setting defaults otherwise + try: + filtOrder = colorbyPhase['filtOrder'] + except: + filtOrder = 3 + + try: + filtFreq = colorbyPhase['filtFreq'] + except: + filtFreq = [1,500] + + if isinstance(filtFreq, list): # bandpass + Wn = [filtFreq[0]/nyquist, filtFreq[1]/nyquist] + b, a = signal.butter(filtOrder, Wn, btype='bandpass') + + elif isinstance(filtFreq, Number): # lowpass + Wn = filtFreq/nyquist + b, a = signal.butter(filtOrder, Wn) + + rawSignalFiltered_ = signal.filtfilt(b, a, rawSignal_) + + analytic_signal = hilbert(rawSignalFiltered_)[len(rawSignal):-len(rawSignal)] + amplitude_envelope = np.abs(analytic_signal) + instantaneous_phase = np.unwrap(np.angle(analytic_signal)) + instantaneous_phase_mod = [(fmod(instantaneous_phase[nn]+pi,2*pi)-pi)*(180/pi) for nn in range(len(instantaneous_phase))] + instantaneous_phase = np.r_[instantaneous_phase_mod] + + f_Rhythm = interpolate.interp1d(time,instantaneous_phase) + + sel['spkPhase'] = sel['spkt'].apply(f_Rhythm) + + else: + print('No signal recovered to color spikes according to its phase') + if len(cellGids) > 0 and numNetStims: ylabelText = ylabelText + ' and NetStims (at the end)' elif numNetStims: @@ -277,6 +376,12 @@ def prepareSpikeData( 'axisArgs': axisArgs, 'legendLabels': legendLabels, } + + if colorbyPhase: + spikeData.update({'spkPhases': sel['spkPhase'].tolist()}) + if 'include_signal' in colorbyPhase and colorbyPhase['include_signal']==True: + spikeData.update({'signal': analytic_signal}) + spikeData.update({'time': time}) if saveData: saveFigData(spikeData, fileName=fileName, fileDesc='spike_data', fileType=fileType, fileDir=fileDir, sim=sim) @@ -292,6 +397,7 @@ def prepareRaster( maxSpikes=1e8, orderBy='gid', popRates=True, + colorbyPhase=None, saveData=False, fileName=None, fileDesc=None, @@ -311,6 +417,7 @@ def prepareRaster( maxSpikes=maxSpikes, orderBy=orderBy, popRates=popRates, + colorbyPhase=colorbyPhase, saveData=saveData, fileName=fileName, fileDesc=fileDesc if fileDesc else 'raster_data', diff --git a/netpyne/plotting/plotRaster.py b/netpyne/plotting/plotRaster.py index 9d37eb8f4..a5be18c9a 100644 --- a/netpyne/plotting/plotRaster.py +++ b/netpyne/plotting/plotRaster.py @@ -18,6 +18,7 @@ def plotRaster( popLabels=None, popColors=None, syncLines=False, + colorbyPhase = None, legend=True, colorList=None, orderInverse=False, @@ -111,6 +112,27 @@ def plotRaster( *Default:* ``False`` + colorbyPhase : dict + Dictionary specifying conditions to plot spikes colored by the phase of a simultaneous signal, filtered in a given range + + *Default:* ``None`` colors spikes according to other options (by populations) + + *Dictionary entries:* + + ``'signal'`` specifies the signal. Options are: ``'LFP'``, which takes the signal from the local fiel potential generated in the ongoing simulation, a numpy array of scalars (for example, an external signal used for stimulation), or an external pickle file, + + ``'fs'`` is the sampling frequency, which should be specified when the signal is obtained from external sources (pickle file or numpy array). Otherwise, it is assumed to be 1000 Hz. If the signal is specified by ``'LFP'``, then the sampling rate is obtained from the internal simulation (cfg.recordStep), + + ``'electrode'`` selects the electrode from the LFP setup. Default is electrode 1, + + ``'filtFreq'`` is a list specifying the range for filtering the signal (band-pass). For example, ``[4,8]`` to select theta rhythm. The default is a very broadband filtering (essentially, the raw signal) ``[1,500]``, + + ``'filtOrder'`` is the filter order (Butterworth) to process the signal, + + ``'pop_background'`` is a boolean option to color each population alternately with a gray background, for better visualization. The default is False, + + ``'include_signal'`` is a boolean option to plot the filtered signal below the raster plot. The default is False. + legend : bool Whether or not to add a legend to the plot. @@ -193,7 +215,8 @@ def plotRaster( sim = kwargs['sim'] rasterData = sim.analysis.prepareRaster( - timeRange=timeRange, maxSpikes=maxSpikes, orderBy=orderBy, popRates=popRates, **kwargs + timeRange=timeRange, maxSpikes=maxSpikes, orderBy=orderBy, + popRates=popRates, colorbyPhase=colorbyPhase, **kwargs ) print('Plotting raster...') @@ -208,6 +231,8 @@ def plotRaster( spkTimes = rasterData['spkTimes'] spkInds = rasterData['spkInds'] spkGids = rasterData['spkGids'] + if colorbyPhase: + spkPhases = rasterData['spkPhases'] if not popNumCells: popNumCells = rasterData.get('popNumCells') @@ -288,6 +313,16 @@ def plotRaster( else: timeRange = [0, np.ceil(max(spkTimes))] + # Set features for raster plot colored by phase + if colorbyPhase: + spkColors = spkPhases + legend = False + kwargs['colorbar'] = {'vmin': -180, 'vmax': 180} + kwargs['background'] = False + if 'pop_background' in colorbyPhase: + if colorbyPhase['pop_background'] == True: + kwargs['background'] = {'popLabels': popLabels, 'popNumCells': popNumCells, 'timeRange': timeRange} + # Create a dictionary with the inputs for a scatter plot scatterData = {} scatterData['x'] = spkTimes @@ -297,10 +332,16 @@ def plotRaster( scatterData['marker'] = '|' scatterData['markersize'] = 5 scatterData['linewidth'] = 2 - scatterData['cmap'] = None scatterData['norm'] = None scatterData['alpha'] = None scatterData['linewidths'] = None + scatterData['cmap'] = None + if colorbyPhase: + scatterData['cmap'] = 'hsv' + if 'include_signal' in colorbyPhase and colorbyPhase['include_signal']==True: + scatterData['time'] = rasterData.get('time') + scatterData['signal'] = rasterData.get('signal') + scatterData['timeRange'] = timeRange # If a kwarg matches a scatter input key, use the kwarg value instead of the default for kwarg in list(kwargs.keys()): @@ -326,7 +367,10 @@ def plotRaster( kwargs.pop(kwarg) # create Plotter object - rasterPlotter = ScatterPlotter(data=scatterData, kind='raster', axis=axis, **axisArgs, **kwargs) + if 'signal' in scatterData: + rasterPlotter = ScatterPlotter(data=scatterData, kind='raster&signal', axis=axis, **axisArgs, **kwargs) + else: + rasterPlotter = ScatterPlotter(data=scatterData, kind='raster', axis=axis, **axisArgs, **kwargs) metaFig = rasterPlotter.metafig # add spike lines diff --git a/netpyne/plotting/plotter.py b/netpyne/plotting/plotter.py index 82c45b501..be967d265 100644 --- a/netpyne/plotting/plotter.py +++ b/netpyne/plotting/plotter.py @@ -127,13 +127,26 @@ def __init__(self, kind, sim=None, subplots=None, sharex=False, sharey=False, au else: dpi = self.rcParams['figure.dpi'] + if 'constrained_layout' in kwargs: + constrained_layout = kwargs['constrained_layout'] + else: + constrained_layout = False + if autosize: maxplots = np.max([nrows, ncols]) figSize0 = figSize[0] + (maxplots - 1) * (figSize[0] * autosize) figSize1 = figSize[1] + (maxplots - 1) * (figSize[1] * autosize) figSize = [figSize0, figSize1] - self.fig, self.ax = plt.subplots(nrows, ncols, sharex=sharex, sharey=sharey, figsize=figSize, dpi=dpi) + gridspec_kw = None +# if 'height_ratios' in kwargs: +# gridspec_kw = {'height_ratios': kwargs['height_ratios'], 'right': 0.3} + if 'gridspec_kw' in kwargs: + gridspec_kw = kwargs['gridspec_kw'] + + self.fig, self.ax = plt.subplots(nrows, ncols, sharex=sharex, sharey=sharey, + figsize=figSize, dpi=dpi, gridspec_kw=gridspec_kw, + constrained_layout=constrained_layout) # Add a metafig attribute to the figure self.fig.metafig = self @@ -205,6 +218,9 @@ def saveFig(self, sim=None, fileName=None, fileDesc=True, fileType='png', fileDi if '.' in saveFig: fileName, fileType = os.path.splitext(saveFig) fileType = fileType[1:] # drop the dot + elif saveFig == 'movie': + from neuron import h + fileName = sim.cfg.filename + '_shape_movie_' + str(round(h.t, 1)) + '.png' else: fileName = saveFig @@ -490,7 +506,16 @@ def __init__(self, data, kind, axis=None, twinx=False, twiny=False, sim=None, me # If an axis is input, plot there; otherwise make a new figure and axis if self.axis is None: if self.metafig is None: - self.metafig = MetaFigure(kind=self.kind, **kwargs) + if self.kind == 'raster&signal': + kwargs.update({'constrained_layout': True}) + kwargs.update({'gridspec_kw': {'height_ratios': [2,1], + 'right': 0.2}}) + # 'left':0.2, + # 'top':0.3, + # 'bottom':0.2}}) + self.metafig = MetaFigure(kind=self.kind, subplots=2, sharex=True, **kwargs) + else: + self.metafig = MetaFigure(kind=self.kind, **kwargs) self.fig = self.metafig.fig self.axis = self.metafig.ax else: @@ -561,11 +586,14 @@ def saveData(self, fileName=None, fileDesc=None, fileType=None, fileDir=None, si self.data, fileName=fileName, fileDesc=fileDesc, fileType=fileType, fileDir=fileDir, sim=sim, **kwargs ) - def formatAxis(self, **kwargs): + def formatAxis(self, axis=None, **kwargs): """Method to format the axis Parameters ---------- + axis : None or object + the axis to format + title : str Title to add to the axis. @@ -589,33 +617,39 @@ def formatAxis(self, **kwargs): Whether to invert the y axis. """ + curAx = axis + if curAx==None: + curAx = self.axis if 'title' in kwargs: - self.axis.set_title(kwargs['title']) + curAx.set_title(kwargs['title']) if 'xlabel' in kwargs: - self.axis.set_xlabel(kwargs['xlabel']) + curAx.set_xlabel(kwargs['xlabel']) if 'ylabel' in kwargs: - self.axis.set_ylabel(kwargs['ylabel']) + curAx.set_ylabel(kwargs['ylabel']) if 'xlim' in kwargs: if kwargs['xlim'] is not None: - self.axis.set_xlim(kwargs['xlim']) + curAx.set_xlim(kwargs['xlim']) if 'ylim' in kwargs: if kwargs['ylim'] is not None: - self.axis.set_ylim(kwargs['ylim']) + curAx.set_ylim(kwargs['ylim']) if 'invert_yaxis' in kwargs: if kwargs['invert_yaxis'] is True: - self.axis.invert_yaxis() + curAx.invert_yaxis() def addLegend(self, handles=None, labels=None, **kwargs): """Method to add a legend to the axis Parameters ---------- + axis : None or object + the axis to add the legends + handles : list List of Matplotlib legend handles. @@ -686,6 +720,7 @@ def addLegend(self, handles=None, labels=None, **kwargs): def addScalebar( self, + axis=None, matchx=True, matchy=True, hidex=True, @@ -703,6 +738,9 @@ def addScalebar( Parameters ---------- + axis : None or object + the axis to add the scalebar + matchx : bool If True, set size of scale bar to spacing between ticks, if False, set size using sizex params. @@ -766,8 +804,12 @@ def addScalebar( """ + curAx = axis + if curAx==None: + curAx = self.axis + _add_scalebar( - self.axis, + curAx, matchx=matchx, matchy=matchy, hidex=hidex, @@ -782,17 +824,67 @@ def addScalebar( **kwargs ) - def addColorbar(self, **kwargs): + def addColorbar(self, axis=None, **kwargs): """Method to add a color bar to the axis Parameters ---------- + axis : None or object + the axis to add the colorbar + kwargs : str You can enter any Matplotlib colorbar parameter as a kwarg. See https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.colorbar.html """ - plt.colorbar(mappable=self.axis.get_images()[0], ax=self.axis, **kwargs) - def finishAxis(self, **kwargs): + curAx = axis + if curAx==None: + curAx = self.axis + + if 'vmin' in kwargs.keys(): + vmin = kwargs['vmin'] + kwargs.pop('vmin') + if 'vmax' in kwargs.keys(): + vmax = kwargs['vmax'] + kwargs.pop('vmax') + if 'vmin' in locals() and 'vmax' in locals(): + cbar = plt.colorbar(mappable=mpl.cm.ScalarMappable(norm=mpl.colors.Normalize(vmin=vmin, vmax=vmax), cmap=self.cmap), + ax=curAx, ticks=[vmin, vmin/2, 0, vmax/2, vmax], **kwargs) + cbar.set_label('Phase', rotation=270) + else: + plt.colorbar(mappable=self.axis.get_images()[0], ax=curAx, **kwargs) + + def addBackground(self, axis=None, **kwargs): + """Method to add striped gray background to populations - used in plotRaster with "colorbyPhase" + + Parameters + ---------- + axis : None or object + the axis to add the background + + kwargs : str + You can enter any Matplotlib colorbar parameter as a kwarg. See https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.colorbar.html + """ + from matplotlib.pyplot import yticks, barh + + curAx = axis + if curAx==None: + curAx = self.axis + + if 'popNumCells' in kwargs.keys(): + popSizes = kwargs['popNumCells'] + yTicksPos = [] + accum = 0 + for i, size in enumerate(popSizes): + yTicksPos.append(accum + popSizes[i] / 2) # yCenter of pop + accum += popSizes[i] + curAx.set_yticks(np.array(yTicksPos)) + curAx.set_yticklabels(kwargs['popLabels']) + curAx.set_xlim(kwargs['timeRange']) + curAx.set_ylim([0,accum]) + curAx.barh(yTicksPos, left=kwargs['timeRange'][0], width=kwargs['timeRange'][1]-kwargs['timeRange'][0]-1, + height=popSizes, align='center', color=['#E3E3E3', 'w'], alpha=0.5) + + def finishAxis(self, axis=None, **kwargs): """Method to finalize an axis Parameters @@ -819,7 +911,11 @@ def finishAxis(self, **kwargs): """ - self.formatAxis(**kwargs) + curAx = axis + if curAx==None: + curAx = self.axis + + self.formatAxis(axis=curAx, **kwargs) if 'saveData' in kwargs: if kwargs['saveData']: @@ -827,28 +923,33 @@ def finishAxis(self, **kwargs): if 'legend' in kwargs: if kwargs['legend'] is True: - self.addLegend(**kwargs) + self.addLegend(axis=curAx,**kwargs) elif type(kwargs['legend']) == dict: - self.addLegend(**kwargs['legend']) + self.addLegend(axis=curAx,**kwargs['legend']) if 'scalebar' in kwargs: if kwargs['scalebar'] is True: - self.addScalebar() + self.addScalebar(axis=curAx) elif type(kwargs['scalebar']) == dict: - self.addScalebar(**kwargs['scalebar']) + self.addScalebar(axis=curAx,**kwargs['scalebar']) if 'colorbar' in kwargs: if kwargs['colorbar'] is True: - self.addColorbar() + self.addColorbar(axis=curAx) elif type(kwargs['colorbar']) == dict: - self.addColorbar(**kwargs['colorbar']) + self.addColorbar(axis=curAx, **kwargs['colorbar']) if 'grid' in kwargs: - self.axis.minorticks_on() + curAx.minorticks_on() if kwargs['grid'] is True: - self.axis.grid() + curAx.grid() elif type(kwargs['grid']) == dict: - self.axis.grid(**kwargs['grid']) + curAx.grid(**kwargs['grid']) + + if 'background' in kwargs: + if type(kwargs['background']) == dict: + self.addBackground(axis=curAx, **kwargs['background']) + # If this is the only axis on the figure, finish the figure if (type(self.metafig.ax) != np.ndarray) and (type(self.metafig.ax) != list): @@ -866,6 +967,11 @@ def __init__(self, data, axis=None, **kwargs): super().__init__(data=data, axis=axis, **kwargs) self.kind = 'scatter' + if 'signal' in data: + self.kind = 'scatter&signal' + self.time = data.get('time') + self.signal = data.get('signal') + self.timeRange = data.get('timeRange') self.x = data.get('x') self.y = data.get('y') self.s = data.get('s') @@ -879,20 +985,46 @@ def __init__(self, data, axis=None, **kwargs): def plot(self, **kwargs): - scatterPlot = self.axis.scatter( - x=self.x, - y=self.y, - s=self.s, - c=self.c, - marker=self.marker, - linewidth=self.linewidth, - cmap=self.cmap, - norm=self.norm, - alpha=self.alpha, - linewidths=self.linewidths, - ) + if self.kind=='scatter': + scatterPlot = self.axis.scatter( + x=self.x, + y=self.y, + s=self.s, + c=self.c, + marker=self.marker, + linewidth=self.linewidth, + cmap=self.cmap, + norm=self.norm, + alpha=self.alpha, + linewidths=self.linewidths, + ) + self.finishAxis(**kwargs) + + elif self.kind=='scatter&signal': + scatterPlot = self.axis[0].scatter( + x=self.x, + y=self.y, + s=self.s, + c=self.c, + marker=self.marker, + linewidth=self.linewidth, + cmap=self.cmap, + norm=self.norm, + alpha=self.alpha, + linewidths=self.linewidths, + ) + + linePlot = self.axis[1].plot( + self.time, + self.signal, + ) + self.finishAxis(axis=self.axis[0],**kwargs) + self.axis[0].set_xlabel('') + self.axis[0].set_ylabel('Cells (grouped by populations)') + self.axis[1].set_xlabel('Time (ms)') + self.axis[1].set_ylabel('Filtered signal') + self.metafig.finishFig(**kwargs) - self.finishAxis(**kwargs) return self.fig diff --git a/netpyne/sim/setup.py b/netpyne/sim/setup.py index ab0d272c8..f5e864c50 100644 --- a/netpyne/sim/setup.py +++ b/netpyne/sim/setup.py @@ -453,7 +453,7 @@ def setupRecording(): # stim spike recording if 'plotRaster' in sim.cfg.analysis: if isinstance(sim.cfg.analysis['plotRaster'], dict) and 'include' in sim.cfg.analysis['plotRaster']: - netStimLabels = list(sim.net.params.stimSourceParams.keys()) + ['allNetStims'] + netStimLabels = list(sim.net.params.stimSourceParams.keys()) + ['allNetStims'] + ['all'] for item in sim.cfg.analysis['plotRaster']['include']: if item in netStimLabels: sim.cfg.recordStim = True diff --git a/netpyne/tutorials/voltage_movie_tut/voltage_movie_tut.py b/netpyne/tutorials/voltage_movie_tut/voltage_movie_tut.py index ae317bf45..dab55a4da 100644 --- a/netpyne/tutorials/voltage_movie_tut/voltage_movie_tut.py +++ b/netpyne/tutorials/voltage_movie_tut/voltage_movie_tut.py @@ -112,8 +112,10 @@ } ## Then we can replace `sim.runSim()` with: +def intervalFunc(t, **kwargs): + sim.analysis.plotShape(**kwargs) -sim.runSimWithIntervalFunc(1.0, sim.analysis.plotShape, timeRange=[10, 20], funcArgs=plotArgs) +sim.runSimWithIntervalFunc(1.0, intervalFunc, timeRange=[10, 20], funcArgs=plotArgs) ## This will execute `sim.analysis.plotShape` every 1.0 ms from 10 to 20 ms in the simulation and feed it the plotArgs dictionary we created above.