-
Notifications
You must be signed in to change notification settings - Fork 2
Fix synapse replay matching with population #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| from unittest.mock import MagicMock, patch | ||
| import uuid | ||
|
|
||
| from bluecellulab.circuit.node_id import CellId | ||
| from bluecellulab.circuit.synapse_properties import SynapseProperty | ||
| import neuron | ||
| import numpy as np | ||
| import pytest | ||
|
|
@@ -923,3 +925,63 @@ def test_add_currents_recordings_with_point_process(self): | |
| called = [c.args[0] for c in mock_add.call_args_list] | ||
| assert "ina" in called | ||
| assert "i_ExpSyn" in called | ||
|
|
||
|
|
||
| @pytest.mark.v6 | ||
| def test_add_synapse_replay_matches_population_and_node_id(monkeypatch, tmp_path): | ||
| """Cell: test add_synapse_replay matches using population and node_id.""" | ||
| import h5py | ||
|
|
||
| spike_file = tmp_path / "spikes.h5" | ||
| with h5py.File(spike_file, "w") as f: | ||
| spikes = f.create_group("spikes") | ||
|
|
||
| vpm = spikes.create_group("VPM") | ||
| vpm.create_dataset("timestamps", data=np.array([10.0, 20.0])) | ||
| vpm.create_dataset("node_ids", data=np.array([14, 14])) | ||
|
|
||
| class DummyStimulus: | ||
| def __init__(self, spike_file): | ||
| self.spike_file = str(spike_file) | ||
| self.config_dir = None | ||
| self.delay = 0.0 | ||
| self.duration = 100.0 | ||
|
|
||
| class DummySynapse: | ||
| def __init__(self, source_population, pre_gid): | ||
| self.syn_description = { | ||
| "source_population_name": source_population, | ||
| SynapseProperty.PRE_GID: pre_gid, | ||
| } | ||
|
|
||
| class DummyConnection: | ||
| def __init__( | ||
| self, | ||
| synapse, | ||
| pre_spiketrain, | ||
| pre_cell, | ||
| stim_dt, | ||
| spike_threshold, | ||
| spike_location, | ||
| ): | ||
| self.synapse = synapse | ||
| self.pre_spiketrain = pre_spiketrain | ||
|
|
||
| monkeypatch.setattr(bluecellulab, "Connection", DummyConnection) | ||
|
|
||
| cell = Cell.__new__(Cell) | ||
| cell.sonata_proxy = object() | ||
| cell.cell_id = CellId("S1nonbarrel_neurons", 3) | ||
| cell.record_dt = 0.1 | ||
| cell.connections = {} | ||
| cell.synapses = { | ||
| ("vpm", 0): DummySynapse("VPM", 14), | ||
| ("s1", 0): DummySynapse("S1nonbarrel_neurons", 14), | ||
| } | ||
|
|
||
| stimulus = DummyStimulus(spike_file) | ||
| Cell.add_synapse_replay(cell, stimulus, -20.0, "soma") | ||
|
|
||
| assert set(cell.connections.keys()) == {("vpm", 0)} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick question to be sure that I understand how this works correctly. Here, we have only
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes exactly, the replay file only contains VPM (L939) spikes, so only the synapse coming from VPM should get connected. The S1 synapse has the same pre_gid but since its source population is different, it should not match. That’s why we only expect {("vpm", 0)} here. |
||
| conn = cell.connections[("vpm", 0)] | ||
| assert np.allclose(conn.pre_spiketrain, [10.0, 20.0]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to keep this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good idea, I added it back and updated it.