Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cleo/registry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Code for orchestrating inter-device interactions.
"""Code for orchestrating inter-device interactions.

This should only be relevant for developers, not users, as this code is used
under the hood when interacting devices are injected (e.g., light and opsin)."""

from __future__ import annotations

from typing import Tuple
Expand Down Expand Up @@ -51,7 +52,7 @@ class DeviceInteractionRegistry:
epsilon : 1
Ephoton : joule
Irr_post = epsilon * T * Irr0_pre : watt/meter**2 (summed)
phi_post = Irr_post / Ephoton : 1/second/meter**2 (summed)
phi_post = epsilon * T * Irr0_pre / Ephoton : 1/second/meter**2 (summed)
"""
"""Model used in light propagation synapses"""

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/PI_ctrl.ipynb

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions docs/tutorials/advanced_lfp.ipynb

Large diffs are not rendered by default.

27 changes: 12 additions & 15 deletions docs/tutorials/all_optical.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/tutorials/electrodes.ipynb

Large diffs are not rendered by default.

66 changes: 38 additions & 28 deletions docs/tutorials/multi_opto.ipynb

Large diffs are not rendered by default.

38 changes: 12 additions & 26 deletions docs/tutorials/neo.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/tutorials/on_off_ctrl.ipynb

Large diffs are not rendered by default.

709 changes: 621 additions & 88 deletions docs/tutorials/optimal_ctrl.ipynb

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions docs/tutorials/optogenetics.ipynb

Large diffs are not rendered by default.

684 changes: 653 additions & 31 deletions docs/tutorials/video_visualization.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dev = [
"sphinx-favicon>=0.2,<0.3",
"furo>=2024.1.29,<2025.0.0",
"nbdev>=2.3.12,<3.0.0",
# not including elephant (used in Neo export tutorial) because of dep issues
"elephant",
"seaborn>=0.13.0,<0.14.0",
"ruff>=0.1.15,<1.0.0",
"pytest-xdist>=3.5.0,<4.0.0",
Expand Down
38 changes: 37 additions & 1 deletion tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from brian2 import Network, NeuronGroup, mm, mm2, ms, mV, mwatt, nmeter, np, umeter

from cleo import CLSimulator
from cleo.coords import assign_coords_grid_rect_prism
from cleo.coords import assign_coords, assign_coords_grid_rect_prism
from cleo.light import Light, fiber473nm
from cleo.opto import Opsin, chr2_4s, vfchrimson_4s

Expand Down Expand Up @@ -146,6 +146,42 @@ def test_multi_channel(sim_ng1_ng2, ops1):
assert np.all(v_base_x > v_yz)


def test_light_Irr_phi_aggregation():
"""Tests that both Irr and phi are aggregated correctly for multiple light sources"""
sim = CLSimulator(Network())
light_agg_ngs = []

for coords in (
[[0, 0, 0]] * mm,
[[0, 0, 0], [1, 0, 0]] * mm,
[[0, 0, 0], [1, 0, 0], [1, 0, 0]] * mm,
):
light = Light(
coords=coords, light_model=fiber473nm(), name=f"light_{len(coords)}"
)
ng = NeuronGroup(len(coords), "v: volt \n Iopto : amp")
assign_coords(ng, coords + (0, 0, 100) * umeter)
sim.network.add(ng)
ops = chr2_4s()
ops.name = f"ops_{len(coords)}"
sim.inject(ops, ng)
sim.inject(light, ng)
light.update(1 * mwatt / mm2)

light_agg_ngs.append(ops.light_agg_ngs[ng.name])

sim.run(0.1 * ms)

irrs = [agg.Irr for agg in light_agg_ngs]
phis = [agg.phi for agg in light_agg_ngs]

for var in [irrs, phis]:
assert var[0][0] == var[1][0] == var[1][1] == var[2][0], (
f"{var} should be same for each neuron regardless of how many sources are present"
)
assert var[2][1] == var[0][0] * 2, f"{var} should be double for 2 sources"


@pytest.mark.slow
def test_multi_light_opsin(sim_ng1_ng2):
sim, ng1, ng2 = sim_ng1_ng2
Expand Down
Loading