Skip to content

Fix synapse replay matching with population#77

Merged
ilkilic merged 2 commits intomainfrom
fix-synapse-replay-pop
Apr 9, 2026
Merged

Fix synapse replay matching with population#77
ilkilic merged 2 commits intomainfrom
fix-synapse-replay-pop

Conversation

@ilkilic
Copy link
Copy Markdown
Collaborator

@ilkilic ilkilic commented Apr 8, 2026

Fix synapse replay matching by including population in CellId.

Previously, replay spikes were matched only by node_id which caused incorrect behavior with multiple populations.

  • Use CellId(population, node_id) for replay keys
  • Update matching logic in add_synapse_replay
  • Add tests for multi-population cases

@ilkilic ilkilic self-assigned this Apr 8, 2026
@ilkilic ilkilic requested a review from AurelienJaquier April 8, 2026 15:37
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bluecellulab/cell/core.py 83.33% 1 Missing ⚠️
bluecellulab/circuit/simulation_access.py 83.33% 1 Missing ⚠️
Files with missing lines Coverage Δ
tests/test_cell/test_core.py 99.44% <100.00%> (+78.14%) ⬆️
tests/test_circuit/test_simulation_access.py 100.00% <100.00%> (+74.13%) ⬆️
bluecellulab/cell/core.py 78.92% <83.33%> (+78.92%) ⬆️
bluecellulab/circuit/simulation_access.py 70.47% <83.33%> (+70.47%) ⬆️

... and 119 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

AurelienJaquier
AurelienJaquier previously approved these changes Apr 9, 2026
Copy link
Copy Markdown
Collaborator

@AurelienJaquier AurelienJaquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just have a couple of comments/questions

spikes["t"].clip(lower=0., inplace=True)
spikes["t"] = spikes["t"].clip(lower=0.0)

# Group spikes by node_id and ensure spike times are sorted in ascending order.
Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Collaborator Author

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.

stimulus = DummyStimulus(spike_file)
Cell.add_synapse_replay(cell, stimulus, -20.0, "soma")

assert set(cell.connections.keys()) == {("vpm", 0)}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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 vpm and we do not have s1 because the only stimulus we gave to add_synapse_replay comes from an h5 file that only has VPM as the population.
Is that correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator

@AurelienJaquier AurelienJaquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanations.
I approve this PR!

@ilkilic ilkilic merged commit 5354c8e into main Apr 9, 2026
9 checks passed
@ilkilic ilkilic deleted the fix-synapse-replay-pop branch April 9, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants