• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openbraininstitute / libsonata / 29263983785

13 Jul 2026 03:51PM UTC coverage: 92.975% (+0.1%) from 92.87%
29263983785

push

github

web-flow
Add ElectrodeReader for SONATA electrode weight files (#56)

Adds an `ElectrodeReader` to libsonata for reading SONATA electrode weight HDF5 files (produced by BlueRecording, consumed by neurodamus for LFP computation).

## What

- **`ElectrodeReader`** class following the `ReportReader`/`SpikeReader` pattern: lazy population loading, sorted index for unsorted node_ids, `openPopulation()` + `getPopulationNames()`
- **`ElectrodeDataFrame`** struct for returning scaling factor submatrices with row/column identity
- **`Population::get(node_ids, electrode_ids)`** — Selection-based access on both axes (`nullopt` = all)
- **Electrode metadata** accessors: names, positions, types
- **Python bindings** with zero-copy numpy arrays (`.ids`, `.electrodes`, `.data`)
- **Test fixture** with two populations (unsorted + sorted node_ids)

## Usage (Python)

```python
from libsonata import ElectrodeReader, Selection

reader = ElectrodeReader('electrode_weights.h5')
pop = reader['NodeA']

df = pop.get()                                         # all nodes, all electrodes
df = pop.get(node_ids=Selection([0, 1, 5]))            # specific nodes
df = pop.get(electrode_ids=Selection([0, 2]))          # specific electrodes
df = pop.get(Selection([0, 1]), Selection([0]))        # both

df.ids         # numpy (n_rows, 2): [node_id, compartment_index]
df.electrodes  # numpy (n_cols,): electrode column indices
df.data        # numpy (n_rows, n_cols): scaling factors
```

## Status

- [x] C++ implementation + Python bindings
- [x] Build verified (all 32 existing C++ tests + 115 Python tests pass)
- [x] C++ tests (in progress)
- [x] Python tests (in progress)

Fix: https://github.com/openbraininstitute/libsonata/issues/54

199 of 211 new or added lines in 1 file covered. (94.31%)

2713 of 2918 relevant lines covered (92.97%)

49.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.31
/src/electrode_reader.cpp


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc