From 9d37a3676e8b8688ccdea91ce4bb8948f11abe6f Mon Sep 17 00:00:00 2001 From: Srinivas Gorur-Shandilya Date: Tue, 27 Aug 2019 21:58:42 -0400 Subject: [PATCH] made a new example that makes a pyloric net cleaned up some demos --- +xolotl/+examples/PyloricNet.m | 64 +++++++++++++++++++++ @xolotl/add.m | 4 ++ docs/how-to/run-simulations.md | 2 +- docs/how-to/voltage-clamp.md | 2 +- docs/reference/matlab/xolotl.md | 3 + docs/tutorials/built-in-demos.md | 2 +- docs/tutorials/first-network.md | 4 +- examples/demo_pyloric_net.m | 52 +++++++++++++++++ examples/demo_stg.m | 97 -------------------------------- 9 files changed, 128 insertions(+), 102 deletions(-) create mode 100644 +xolotl/+examples/PyloricNet.m create mode 100644 examples/demo_pyloric_net.m delete mode 100644 examples/demo_stg.m diff --git a/+xolotl/+examples/PyloricNet.m b/+xolotl/+examples/PyloricNet.m new file mode 100644 index 00000000..40d4ee6f --- /dev/null +++ b/+xolotl/+examples/PyloricNet.m @@ -0,0 +1,64 @@ + + +%{ + _ _ _ + __ _____ | | ___ | |_| | + \ \/ / _ \| |/ _ \| __| | + > < (_) | | (_) | |_| | + /_/\_\___/|_|\___/ \__|_| + +## PyloricNet + +**Syntax** + +```matlab +x = xolotl.examples.PyloricNet(); +``` + +**Description** + +makes a three-cell model of the pyloric network +following Prinz et al. Nat. Neuro. + + +%} + + +function x = PyloricNet() + + +% the order here doesn't matter -- everything will be re-arranged +% alphabetically +channels = {'prinz/NaV','prinz/CaT','prinz/CaS','prinz/ACurrent','prinz/KCa','prinz/Kd','prinz/HCurrent','Leak'}; + + +x = xolotl; + +x.add('compartment','AB'); +x.AB.add('prinz/CalciumMech'); + +for i = 1:length(channels) + x.AB.add(channels{i}); +end + +x.add(copy(x.AB),'LP') +x.add(copy(x.AB),'PY') + +% configure gbars +x.AB.set('*gbar', [500, 60, 25, .1, 50, 1000, 0, 1000]) +x.LP.set('*gbar', [200, 40, 0, .5, 0, 250, 0.3, 1000]) +x.PY.set('*gbar', [500, 20, 24, .5, 0, 1250, 0.1, 1000]) + +x.set('*Leak.E',-50) + + +% set up synapses as in Fig. 2e +x.connect('AB','LP','Chol','gmax',30); +x.connect('AB','PY','Chol','gmax',3); +x.connect('AB','LP','Glut','gmax',30); +x.connect('AB','PY','Glut','gmax',10); +x.connect('LP','PY','Glut','gmax',1); +x.connect('PY','LP','Glut','gmax',30); +x.connect('LP','AB','Glut','gmax',30); + +x.t_end = 5e3; \ No newline at end of file diff --git a/@xolotl/add.m b/@xolotl/add.m index 6359c7ba..a49e9e9c 100644 --- a/@xolotl/add.m +++ b/@xolotl/add.m @@ -14,6 +14,7 @@ % x.add('compartment','comp_name') % x.add(compartment,'comp_name') % x.add('compartment','comp_name',...) +% x.add(Compartment,'comp_name') % ``` % % **Description** @@ -26,6 +27,8 @@ % % - **`x.add('compartment','comp_name',...)`** adds a compartment to the xolotl object and names it `comp_name`. The compartment is then additionally configured using the parameters specified using Name Value syntax. % +% - **`x.add(Compartment, 'comp_name')`** adds a pre-defined cpplab object of class "compartment" to the xolotl object and names it `comp_name`. You cannot pass additional name-value arguments using this syntax. +% % **Technical Details** % % `xolotl.add` checks that the compartment being added has a legal name @@ -41,6 +44,7 @@ function add(self,obj_type, obj_name,varargin) + msg = ['You tried to add a compartment without a label, which is not allowed. Every compartment must be labeled. \n\nClick here to read the documentation on how to use this method']; assert(nargin > 2,'xolotl:add:no_label',msg) diff --git a/docs/how-to/run-simulations.md b/docs/how-to/run-simulations.md index b75dcc3c..d97ab1de 100644 --- a/docs/how-to/run-simulations.md +++ b/docs/how-to/run-simulations.md @@ -74,7 +74,7 @@ Currents are ordered exactly the same as in the `xolotl` object, meaning by compartment and then alphabetically. !!! Note "Plotting mechanisms and currents" - The example script `demo_stg` contains code that plots currents vs. time and `demo_integral_control` contains code that plots mechanisms vs. time. + The example script `demo_pyloric_net` contains code that plots currents vs. time and `demo_integral_control` contains code that plots mechanisms vs. time. ## Inject current into compartments Injected current is mediated by the `I_ext` property of the `xolotl` object. diff --git a/docs/how-to/voltage-clamp.md b/docs/how-to/voltage-clamp.md index 83b81234..c7bac956 100644 --- a/docs/how-to/voltage-clamp.md +++ b/docs/how-to/voltage-clamp.md @@ -69,7 +69,7 @@ We can also voltage clamp a single cell in a network. To demonstrate this, we wi ```matlab xolotl.go_to_examples -demo_stg +demo_pyloric_net ``` Here, let's voltage clamp one cell to another cell's voltage dynamics. diff --git a/docs/reference/matlab/xolotl.md b/docs/reference/matlab/xolotl.md index a3e0651e..107ee828 100644 --- a/docs/reference/matlab/xolotl.md +++ b/docs/reference/matlab/xolotl.md @@ -209,6 +209,7 @@ the model. x.add('compartment','comp_name') x.add(compartment,'comp_name') x.add('compartment','comp_name',...) +x.add(Compartment,'comp_name') ``` **Description** @@ -221,6 +222,8 @@ Adds a `cpplab` object to a `xolotl` object. The `add` method is the most import - **`x.add('compartment','comp_name',...)`** adds a compartment to the xolotl object and names it `comp_name`. The compartment is then additionally configured using the parameters specified using Name Value syntax. +- **`x.add(Compartment, 'comp_name')`** adds a pre-defined cpplab object of class "compartment" to the xolotl object and names it `comp_name`. You cannot pass additional name-value arguments using this syntax. + **Technical Details** `xolotl.add` checks that the compartment being added has a legal name diff --git a/docs/tutorials/built-in-demos.md b/docs/tutorials/built-in-demos.md index 75236dec..732ef60c 100644 --- a/docs/tutorials/built-in-demos.md +++ b/docs/tutorials/built-in-demos.md @@ -55,5 +55,5 @@ Xolotl comes with several example scripts that illustrate various features of th | [demo_multi_compartment](https://github.com/sg-s/xolotl/blob/master/examples/demo_multi_compartment.m) | This example sets up a multi-compartment model, where different compartments have different levels of channels | | [demo_finite_size](https://github.com/sg-s/xolotl/blob/master/examples/demo_finite_size.m) | This example varies the size of a neuron, and shows that smaller neurons are more dominated by noise due to the finite number of ion channels | | [demo_rk4](https://github.com/sg-s/xolotl/blob/master/examples/demo_rk4.m) | This demo shows you how to use the [`solver_order`](https://xolotl.readthedocs.io/en/master/reference/xolotl/#solver_order) property of xolotl to use a Runge-Kutta 4 ODE solver to simulate the model| -| [demo_stg](https://github.com/sg-s/xolotl/blob/master/examples/demo_stg.m) | In this example, we set up a small network of three neurons, demonstrating how synapses work in xolotl | +| [demo_pyloric_net](https://github.com/sg-s/xolotl/blob/master/examples/demo_pyloric_net.m) | In this example, we set up a small network of three neurons, demonstrating how synapses work in xolotl | | [demo_stg_temperature](https://github.com/sg-s/xolotl/blob/master/examples/demo_stg_temperature.m) | Here, we vary the temperature of the simulation, showing how we can make the model sensitive to temperature. | diff --git a/docs/tutorials/first-network.md b/docs/tutorials/first-network.md index dea6e46d..26a05166 100644 --- a/docs/tutorials/first-network.md +++ b/docs/tutorials/first-network.md @@ -1,6 +1,6 @@ In this tutorial, we will walk through the process of creating a network model of three neurons connected together by synapses. We will integrate the model to find the membrane potential over time and view the output. -Code equivalent to this tutorial can be found in `../xolotl/examples/demo_stg.m`. +Code equivalent to this tutorial can be found in `../xolotl/examples/demo_pyloric_net.m`. ### A high-level view of the network @@ -199,4 +199,4 @@ You should see something like this: ![](../images/stg-trace.png) !!! Note "A shortcut through this tutorial" - You can reproduce the model we created here by running the `demo_stg` script. Make sure you run `xolotl.go_to_examples` first so that you're in the right folder. + You can reproduce the model we created here by running the `demo_pyloric_net` script. Make sure you run `xolotl.go_to_examples` first so that you're in the right folder. diff --git a/examples/demo_pyloric_net.m b/examples/demo_pyloric_net.m new file mode 100644 index 00000000..3c48c7e0 --- /dev/null +++ b/examples/demo_pyloric_net.m @@ -0,0 +1,52 @@ +% test script for matlab wrapper + +% this sets up the pyloric network +% as in Fig 2e of this paper: +% Prinz ... Marder Nat Neuro 2004 +% http://www.nature.com/neuro/journal/v7/n12/abs/nn1352.html + +x = xolotl.examples.PyloricNet; + +x.integrate; + + +[V, ~, ~, currs, syns] = x.integrate; + + +C = x.find('compartment'); + +x.plot; +drawnow + +figure('outerposition',[100 100 1000 900],'PaperUnits','points','PaperSize',[1000 900]); hold on +subplot(3,1,1); hold on +plot(currs(:,1:7)) +ylabel('I (nA)') +title(C{1}) +legend(x.(C{1}).find('conductance')) + +subplot(3,1,2); hold on +plot(currs(:,8:15)) +title(C{2}) +ylabel('I (nA)') +legend(x.(C{2}).find('conductance')) + +subplot(3,1,3); hold on +plot(currs(:,16:23)) +title(C{3}) +ylabel('I (nA)') +legend(x.(C{3}).find('conductance')) + + +drawnow + +figure('outerposition',[100 100 1000 500],'PaperUnits','points','PaperSize',[1000 500]); hold on + +plot(syns) +ylabel('I (nA)') +title('synaptic currents') + +drawnow + + +figlib.pretty() \ No newline at end of file diff --git a/examples/demo_stg.m b/examples/demo_stg.m deleted file mode 100644 index 6f7c0aeb..00000000 --- a/examples/demo_stg.m +++ /dev/null @@ -1,97 +0,0 @@ -% test script for matlab wrapper - -% this sets up the STG network -% as in Fig 2e of this paper: -% Prinz ... Marder Nat Neuro 2004 -% http://www.nature.com/neuro/journal/v7/n12/abs/nn1352.html - - -% conversion from Prinz to phi -A = 0.0628; - -channels = {'NaV','CaT','CaS','ACurrent','KCa','Kd','HCurrent'}; -prefix = 'prinz/'; -gbar(:,1) = [1000 25 60 500 50 1000 .1]; -gbar(:,2) = [1000 0 40 200 0 250 .5]; -gbar(:,3) = [1000 24 20 500 0 1250 .5]; -E = [50 30 30 -80 -80 -80 -20]; - -x = xolotl; - -x.add('compartment','AB','Cm',10,'A',A); -x.add('compartment','LP','Cm',10,'A',A); -x.add('compartment','PY','Cm',10,'A',A); - -compartments = x.find('compartment'); -for j = 1:length(compartments) - - % add Calcium mechanism - x.(compartments{j}).add('prinz/CalciumMech'); - - for i = 1:length(channels) - x.(compartments{j}).add([prefix channels{i}],'gbar',gbar(i,j),'E',E(i)); - end -end - -x.LP.add('Leak','gbar',.3,'E',-50); -x.PY.add('Leak','gbar',.1,'E',-50); - -x.connect('AB','LP','Chol'); - -% set up synapses as in Fig. 2e - -x.connect('AB','PY','Chol','gmax',3); -x.connect('AB','LP','Glut','gmax',30); -x.connect('AB','PY','Glut','gmax',10); -x.connect('LP','PY','Glut','gmax',1); -x.connect('PY','LP','Glut','gmax',30); -x.connect('LP','AB','Glut','gmax',30); - -x.t_end = 5e3; - - - - -x.integrate; - - -[V, ~, ~, currs, syns] = x.integrate; - - -C = x.find('compartment'); - -x.plot; -drawnow - -figure('outerposition',[100 100 1000 900],'PaperUnits','points','PaperSize',[1000 900]); hold on -subplot(3,1,1); hold on -plot(currs(:,1:7)) -ylabel('I (nA)') -title(C{1}) -legend(x.(C{1}).find('conductance')) - -subplot(3,1,2); hold on -plot(currs(:,8:15)) -title(C{2}) -ylabel('I (nA)') -legend(x.(C{2}).find('conductance')) - -subplot(3,1,3); hold on -plot(currs(:,16:23)) -title(C{3}) -ylabel('I (nA)') -legend(x.(C{3}).find('conductance')) - - -drawnow - -figure('outerposition',[100 100 1000 500],'PaperUnits','points','PaperSize',[1000 500]); hold on - -plot(syns) -ylabel('I (nA)') -title('synaptic currents') - -drawnow - - -figlib.pretty() \ No newline at end of file