Skip to content

Commit

Permalink
tweak overview docs, increase test cell timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnsen committed Sep 18, 2024
1 parent 3566ac4 commit ede7deb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Perhaps the biggest change you may have to make to an existing model to make it
You'll need your model in a Brian {class}`~brian2.core.network.Network` object before you move on. E.g.,:

```{code-cell} python
import brian2 as b2
ng = b2.NeuronGroup( # a simple population of 100 LIF neurons
import brian2.only as b2
ng = b2.NeuronGroup( # a simple population of LIF neurons
500,
"""dv/dt = (-v - 70*mV + (500*Mohm)*Iopto + 2*xi*sqrt(tau_m)*mvolt) / tau_m : volt
Iopto : amp""",
Expand All @@ -99,7 +99,7 @@ cleo.coords.assign_coords_rand_rect_prism(

Once you have a network model, you can construct a {class}`~cleo.CLSimulator` object:

```{code-cell} ipython3
```{code-cell} python
sim = cleo.CLSimulator(net)
```

Expand All @@ -113,7 +113,7 @@ The recorder will only record from the neuron groups specified on injection, all
Some extremely simple implementations (which do little more than wrap Brian monitors) are available in the {mod}`cleo.recorders` module.
See the {doc}`tutorials/electrodes` and {doc}`tutorials/all_optical` tutorials for more detail on how to record from a simulation more realistically, but here's a quick example of how to record multi-unit spiking activity with an electrode:

```{code-cell} ipython3
```{code-cell} python
# configure and inject a 32-channel shank
coords = cleo.ephys.linear_shank_coords(
array_length=1*b2.mm, channel_count=32, start_location=(0, 0, 0.2)*b2.mm
Expand All @@ -132,7 +132,7 @@ sim.inject(probe, ng)
Optogenetics (1P and 2P) is the main stimulation modality currently implemented by Cleo.
This requires injection of both a light source and an opsin---see the {doc}`tutorials/optogenetics` and {doc}`tutorials/all_optical` tutorials for more detail.

```{code-cell} ipython3
```{code-cell} python
fiber = cleo.light.Light(
coords=(0, 0, 0.5)*b2.mm,
light_model=cleo.light.fiber473nm(),
Expand Down Expand Up @@ -161,7 +161,7 @@ If you are only recording, you may want to use the {class}`~cleo.ioproc.RecordOn
Otherwise you will want to implement the {class}`~cleo.ioproc.LatencyIOProcessor`, which not only takes samples at the specified rate, but processes the data and delivers input to the network after a user-defined delay, emulating the latency inherent in real experiments.
This is done by creating a subclass and defining the {meth}`~cleo.ioproc.LatencyIOProcessor.process` function:

```{code-cell} ipython3
```{code-cell} python
class MyProcessor(cleo.ioproc.LatencyIOProcessor):
def process(self, state_dict, t_samp):
# state_dict contains a {'recorder_name': value} dict of network.
Expand All @@ -179,13 +179,14 @@ The {doc}`tutorials/on_off_ctrl`, {doc}`tutorials/PI_ctrl`, and {doc}`tutorials/
### Visualization
{func}`cleo.viz.plot` allows you to easily visualize your experimental configuration:

```{code-cell} ipython3
```{code-cell} python
:tags: [remove-cell]
cleo.utilities.style_plots_for_docs()
b2.prefs.codegen.target = 'numpy'
b2.prefs.codegen.target = "numpy"
b2.defaultclock.dt = 0.5 * b2.ms
```

```{code-cell} ipython3
```{code-cell} python
cleo.viz.plot(ng, colors=['#c500cc'], sim=sim, zlim=(200, 1000))
```

Expand All @@ -194,22 +195,22 @@ Cleo also features some {doc}`video visualization capabilities <tutorials/video_

### Running experiments

Use {meth}`cleo.CLSimulator.run` function with the desired duration.
This wrap's Brian's {meth}`brian2.core.network.Network.run` function:
Use {meth}`~cleo.CLSimulator.run` function with the desired duration.
This wrap's Brian's {meth}`~brian2.core.network.Network.run` function:

```{code-cell} ipython3
```{code-cell} python
:tags: [hide-output]
sim.run(50 * b2.ms) # kwargs are passed to Brian's run function
```

Use {meth}`~cleo.CLSimulator.reset` to restore the default state (right after initialization/injection) for the network and all devices.
This could be useful for running a simulation multiple times under different conditions.

To facilitate access to data after the simulation, devices offer a {attr}`cleo.InterfaceDevice.save_history` option on construction, by default `True`.
To facilitate access to data after the simulation, devices offer a {attr}`~cleo.InterfaceDevice.save_history` option on construction, by default `True`.
If true, that object will store relevant variables as attributes.
For example:

```{code-cell} ipython3
```{code-cell} python
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
ax1.scatter(mua.t / b2.ms, mua.i, marker='.', c='white', s=2)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_overview_notebook_execution():
with open(notebook_path, "r") as file:
nb = read_myst_markdown_notebook(file.read())

result = single_nb_execution(nb, cwd=current_dir, timeout=30, allow_errors=False)
result = single_nb_execution(nb, cwd=current_dir, timeout=60, allow_errors=False)
assert result.err is None, result.err

for cell in nb["cells"]:
Expand Down

0 comments on commit ede7deb

Please sign in to comment.