From 5a467f390a0f8f84e5213c0b6de1a7933a1c413a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:52:31 +0000 Subject: [PATCH 1/2] Initial plan From 6a406700804a5fede369f1d6d80418cd1999e5f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:54:38 +0000 Subject: [PATCH 2/2] Add .github/copilot-instructions.md with repository-specific Copilot guidance Agent-Logs-Url: https://github.com/LFPy/LFPykit/sessions/09c0e794-71fe-48ed-9190-335e40c6c491 Co-authored-by: espenhgn <2492641+espenhgn@users.noreply.github.com> --- .github/copilot-instructions.md | 113 ++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..24e1c93 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,113 @@ +# Copilot Instructions for LFPykit + +## Project Overview + +`LFPykit` is a Python library providing freestanding implementations of electrostatic forward models for computing extracellular potentials and related measures (EEG, MEG, LFP, CSD) from multicompartment neuron models. It is designed to be used independently of any specific neural simulation software (NEURON, Arbor, LFPy, etc.). + +The core design principle is that each forward model class exposes a `get_transformation_matrix()` method returning a 2D linear transformation matrix **M** such that measurements **Y** = **M** @ **I**, where **I** are transmembrane currents. + +## Repository Structure + +``` +LFPykit/ +├── .github/ # GitHub configuration (workflows, templates, instructions) +│ ├── workflows/ # CI/CD GitHub Actions workflows +│ ├── CONTRIBUTING.md # Contribution guidelines +│ └── ISSUE_TEMPLATE/ # Issue templates +├── lfpykit/ # Main package source code +│ ├── __init__.py # Package exports +│ ├── cellgeometry.py # CellGeometry base class +│ ├── models.py # LinearModel and derived forward model classes +│ ├── lfpcalc.py # Low-level LFP calculation routines +│ ├── eegmegcalc.py # EEG/MEG forward model classes +│ ├── version.py # Package version +│ └── tests/ # Unit tests (pytest) +├── doc/ # Documentation source (Sphinx) +├── examples/ # Example Jupyter notebooks +├── requirements.txt # pip dependencies +├── environment.yml # conda environment +├── setup.py / setup.cfg # Package setup +└── README.md # Project documentation +``` + +## Key Architecture Patterns + +- **`CellGeometry`** (`cellgeometry.py`): Represents the geometry of a multicompartment neuron (x, y, z coordinates and diameter `d` of each segment). +- **`LinearModel`** (`models.py`): Abstract base class for all forward models. Subclasses must implement `get_transformation_matrix()`. +- All classes (except `CellGeometry`) must implement `get_transformation_matrix()` returning a NumPy array of shape `(n_points, n_inputs)`. +- EEG/MEG classes in `eegmegcalc.py` operate on current dipole moments (output of `CurrentDipoleMoment.get_transformation_matrix()`). + +## Physical Units Convention + +| Quantity | Unit | +|---|---| +| Transmembrane currents | nA | +| Spatial coordinates | µm | +| Voltages / potentials | mV | +| Extracellular conductivities | S/m | +| Current dipole moments | nA µm | +| Magnetic fields | nA/µm | + +There are no explicit runtime checks for units — callers are responsible for consistency. + +## Coding Conventions + +- Follow **PEP 8** style guidelines for all Python code. +- Line length limit: **127 characters** (as configured in the flake8 workflow). +- Use descriptive variable names and add docstrings to all public classes and methods. +- Use NumPy-style docstrings. +- Imports: standard library first, then third-party (`numpy`, `scipy`, etc.), then local package imports. +- All new model classes must subclass `LinearModel` (or `Model`) and implement `get_transformation_matrix()`. +- Keep one idea/feature per pull request. + +## Installation + +```bash +# From source +pip install . + +# Development (editable) install +pip install -e . + +# Install dependencies only +pip install -r requirements.txt +``` + +## Linting + +```bash +# Check for syntax errors and undefined names (must pass — zero tolerance) +flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + +# Full style check (warnings allowed) +flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +``` + +## Running Tests + +```bash +# Run the full test suite +py.test -v + +# Run a specific test file +py.test lfpykit/tests/test_module.py -v + +# Run a specific test +py.test lfpykit/tests/test_module.py::TestLinearModel -v +``` + +Tests are located in `lfpykit/tests/` and use `pytest`. New features must include corresponding unit tests. + +## Dependencies + +- `numpy >= 1.15.2` — array operations and linear algebra +- `scipy` — special functions and numerical routines +- `sympy` — symbolic mathematics (used in some analytical derivations) +- `MEAutility` — multi-electrode array utilities + +## Contributing + +- Read `.github/CONTRIBUTING.md` before submitting changes. +- Always link PRs to a related open issue. +- Ensure all tests pass (`py.test -v`) and linting is clean before opening a PR. +- Use the PR template in `.github/PULL_REQUEST_TEMPLATE/pull_request_template.md`.