Skip to content

Add SONATA support for spatially_uniform_e_field stimulus#82

Open
darshanmandge wants to merge 16 commits into
mainfrom
uniform_e_field_stimulus
Open

Add SONATA support for spatially_uniform_e_field stimulus#82
darshanmandge wants to merge 16 commits into
mainfrom
uniform_e_field_stimulus

Conversation

@darshanmandge
Copy link
Copy Markdown
Collaborator

- Merged main into uniform_e_field_stimulus branch
- Re-applied SpatiallyUniformEField stimulus pattern and class
- Re-applied ElectrodeSource integration in circuit_simulation.py
- Re-applied compute_segment_coordinates() to Cell class
- Ported axon/myelin interpolation methods from neurodamus
- Updated _add_extracellular_stimulus to use coordinate interpolation
- Added unit tests for coordinate helpers (interp_axon_positions, interp_myelin_positions)
- All pytest tests pass
- Import Callable from typing instead of using builtins.callable
- Add proper type annotation for func_loc2glob parameter
- Change return type to Optional[np.ndarray] for get_segment_position
- Add type annotation for cell_targets dict in circuit_simulation.py
- Remove unused variable post_sec_id (ruff F841)
- Add spatially_uniform_e_field to test_pattern_from_sonata_valid test
- Fix docformatter issue in circuit_simulation.py (wrap docstring)
- All 68 stimulus tests pass
- All 58 cell core tests pass
- Add tests for ElectrodeSource.__iadd__() edge cases (delay, non-overlapping, concatenation)
- Add test for cleanup() method
- Add tests for Pattern.from_blueconfig() method
- Add tests for SINUSOIDAL and SECLAMP patterns in from_sonata()
- Coverage increased from 93% to 94%
@darshanmandge darshanmandge self-assigned this Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 97.11538% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bluecellulab/circuit_simulation.py 79.76% 17 Missing ⚠️
bluecellulab/cell/core.py 97.91% 2 Missing ⚠️
...ab/circuit/circuit_access/sonata_circuit_access.py 91.66% 1 Missing ⚠️
...ecellulab/stimulus/circuit_stimulus_definitions.py 96.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
bluecellulab/stimulus/extracellular.py 100.00% <100.00%> (ø)
tests/test_cell/test_segment_coordinates.py 100.00% <100.00%> (ø)
...test_stimulus/test_circuit_stimulus_definitions.py 100.00% <100.00%> (ø)
tests/test_stimulus/test_efield_integration.py 100.00% <100.00%> (ø)
tests/test_stimulus/test_extracellular.py 100.00% <100.00%> (ø)
...ab/circuit/circuit_access/sonata_circuit_access.py 95.59% <91.66%> (-0.22%) ⬇️
...ecellulab/stimulus/circuit_stimulus_definitions.py 93.37% <96.00%> (+5.21%) ⬆️
bluecellulab/cell/core.py 81.75% <97.91%> (+2.83%) ⬆️
bluecellulab/circuit_simulation.py 83.84% <79.76%> (-0.92%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Previously _add_extracellular_stimulus only iterated over the soma
segments from the resolved targets list (seg_list), causing the
e-field displacement to be ~zero and producing no visible effect.

Neurodamus iterates over all sections/segments of each target cell.
This fix replaces the seg_list loop with iteration over all sections
and segments of each cell, matching the neurodamus implementation.

Verified: voltage difference with vs without e-field increased from
~0 mV to >48 mV.
- Add Cell.set_local_to_global_matrix() and local_to_global_coord_mapping()
  with quaternion->rotation matrix construction (no scipy dependency).
- Rename compute_segment_coordinates -> compute_segment_local_coordinates;
  add compute_segment_global_coordinates that applies the cell transform.
- Switch _add_extracellular_stimulus to iterate the resolved seg_list
  (honoring compartment_set or node_set->all sections per neurodamus
  target_point_list semantics).
- Set soma displacement to zero in _add_extracellular_stimulus.
- Pass a local-to-global closure to get_segment_position for axon/myelin
  sections that lack 3D points.
- Populate the cell transform during instantiate_gids using a new
  SonataCircuitAccess.get_cell_position_rotation helper.
- Make Cell.delete robust against partially-initialized cells.
- Add unit tests for cell coordinate helpers, integration tests for the
  e-field stimulus glue, and additional ElectrodeSource coverage.
@darshanmandge darshanmandge marked this pull request as ready for review April 30, 2026 12:25
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.

1 participant