Skip to content

Commit

Permalink
made a new example that makes a pyloric net
Browse files Browse the repository at this point in the history
cleaned up some demos
  • Loading branch information
sg-s committed Aug 28, 2019
1 parent 1c18f35 commit 9d37a36
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 102 deletions.
64 changes: 64 additions & 0 deletions +xolotl/+examples/PyloricNet.m
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions @xolotl/add.m
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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
Expand All @@ -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\n<a href="https://xolotl.readthedocs.io/en/master/reference/matlab/xolotl/#add">Click here to read the documentation on how to use this method</a>'];
assert(nargin > 2,'xolotl:add:no_label',msg)

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/run-simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/voltage-clamp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions docs/reference/matlab/xolotl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/built-in-demos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
4 changes: 2 additions & 2 deletions docs/tutorials/first-network.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.
52 changes: 52 additions & 0 deletions examples/demo_pyloric_net.m
Original file line number Diff line number Diff line change
@@ -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()
97 changes: 0 additions & 97 deletions examples/demo_stg.m

This file was deleted.

0 comments on commit 9d37a36

Please sign in to comment.