Synaptipy Developer Guide
This guide is intended for developers who want to understand, modify, or contribute to Synaptipy.
Table of Contents
Development Environment Setup
Prerequisites
Python 3.10-3.12 (
requires-python = ">=3.10,<3.13")Git
pip or conda package manager
Setting Up Your Development Environment
Clone the repository:
git clone https://github.com/anzalks/synaptipy.git cd synaptipy
Create and activate the conda environment:
conda env create -f environment.yml conda activate synaptipy
Install in development mode:
pip install -e ".[dev]"
This installs Synaptipy in editable mode with all development and testing dependencies.
Project Structure
The Synaptipy codebase is organized into strict architectural layers (core/, infrastructure/, application/, and shared/):
src/synaptipy/ # Main package
├── __init__.py # Package initialization and __version__
├── __main__.py # Entry point for `synaptipy` / `python -m synaptipy`
├── application/ # GUI and CLI application layer
│ ├── __main__.py # GUI entry point (run_gui)
│ ├── cli/ # Headless command-line interface
│ │ └── main.py # Entry point for `synaptipy-batch`
│ ├── controllers/ # MVC controllers
│ │ ├── analysis_formatter.py # Format analysis results for display
│ │ ├── analysis_plot_manager.py # Manage plot overlays for analysis
│ │ ├── file_io_controller.py # File open/save coordination
│ │ ├── live_analysis_controller.py # Real-time spike detection
│ │ └── shortcut_manager.py # Keyboard shortcut bindings
│ ├── data_loader.py # Background file loading (QThread)
│ ├── gui/ # Main GUI components
│ │ ├── main_window.py # MainWindow (Explorer, Analyser, Exporter tabs)
│ │ ├── analyser_tab.py # Dynamic 5-pillar analysis tab manager
│ │ ├── exporter_tab.py # NWB/CSV export tab
│ │ ├── about_dialog.py # About and citation dialog
│ │ ├── analysis_config_dialog.py # Global analysis parameter defaults dialog
│ │ ├── analysis_worker.py # Worker thread for asynchronous analysis
│ │ ├── batch_dialog.py # Interactive batch analysis dialog
│ │ ├── help_window.py # Offline Qt Help (.qhc) viewer window
│ │ ├── nwb_dialog.py # NWB metadata configuration dialog
│ │ ├── plot_customization_dialog.py # Global plot styling customization dialog
│ │ ├── plot_save_dialog.py # Plot image/vector save dialog
│ │ ├── preferences_dialog.py # Application preferences dialog
│ │ ├── session_summary_dialog.py # Session summary dialog
│ │ ├── ui_generator.py # Dynamic UI generation from registry metadata
│ │ ├── welcome_screen.py # Demo data and plugin download banner
│ │ ├── analysis_tabs/ # Analysis tab framework
│ │ │ ├── base.py # BaseAnalysisTab (ABC)
│ │ │ └── metadata_driven.py # MetadataDrivenAnalysisTab
│ │ ├── dialogs/ # Specialized modal dialogs
│ │ │ ├── export_manager.py # Unified export coordination dialog
│ │ │ ├── plot_export_dialog.py # Publication plot export options
│ │ │ ├── protocol_map_dialog.py # Trial/segment ProtocolMap editor
│ │ │ └── trial_selection_dialog.py # Per-trial inclusion/exclusion selector
│ │ ├── explorer/ # Data Explorer tab components
│ │ │ ├── config_panel.py # Preprocessing and display controls
│ │ │ ├── explorer_tab.py # Explorer container widget
│ │ │ ├── plot_canvas.py # Multi-channel trace canvas
│ │ │ ├── sidebar.py # File tree and recording metadata panel
│ │ │ ├── toolbar.py # Navigation and zoom toolbar
│ │ │ └── y_controls.py # Per-channel Y-axis scale controls
│ │ └── widgets/ # Reusable GUI widgets
│ │ ├── log_streamer.py # Live analysis log window
│ │ ├── plot_canvas.py # SynaptipyPlotCanvas wrapper
│ │ ├── preprocessing.py # Preprocessing control widget
│ │ └── preprocessing_comparison.py # Raw vs processed trace preview
│ ├── services/ # Application services layer
│ │ ├── data_loader_service.py # Service wrapper around data loading
│ │ ├── methods_generator.py # Automated Materials & Methods text builder
│ │ └── parameter_templates.py # Saved analysis parameter presets
│ ├── plugin_manager.py # Plugin discovery, consent, and hot-reload
│ ├── session_manager.py # Session state persistence
│ └── startup_manager.py # Application startup and update checks
├── core/ # Pure logic and domain models (zero GUI imports)
│ ├── averaging.py # TimeAlignedAverage and physical-time averaging
│ ├── constants.py # Physical and numerical domain constants
│ ├── data_model.py # Recording, Channel, UndoStack, Experiment
│ ├── error_handler.py # Crash reporter and install_excepthook
│ ├── processing_pipeline.py # SignalProcessingPipeline and apply_trace_corrections
│ │ # (immutable 5-step A -> B -> C -> D -> E order)
│ ├── protocols.py # ProtocolMap, ProtocolAssignment, validation
│ ├── results.py # Typed result dataclasses (RinResult, etc.)
│ ├── signal_processor.py # Pure NumPy/SciPy DSP filters and quality checks
│ ├── source_interfaces.py # SourceHandle protocol for lazy I/O decoupling
│ ├── trial_qc.py # TrialQCDecision and auditable sweep eligibility
│ └── analysis/ # Analysis algorithms and registry
│ ├── registry.py # AnalysisRegistry (@register, @register_processor)
│ ├── contracts.py # Canonical AnalysisResult (schema v1) contract
│ ├── preprocessing.py # 7 registered batch/CLI signal preprocessors
│ ├── batch_engine.py # Parallel BatchAnalysisEngine
│ ├── epoch_manager.py # EpochManager for TTL and manual epochs
│ ├── cross_file_utils.py # Cross-file trial averaging and compatibility report
│ ├── passive_properties.py # Pillar 1: RMP, Rin, Tau, Sag, I-V, Capacitance
│ ├── single_spike.py # Pillar 2: Spike detection and phase plane
│ ├── firing_dynamics.py # Pillar 3: Excitability, burst, train dynamics
│ ├── synaptic_events.py # Pillar 4: Threshold and deconvolution events
│ └── evoked_responses.py # Pillar 5: Evoked Sync, PPR, Stimulus Train (STP)
├── infrastructure/ # File I/O and external format adapters
│ ├── file_readers/ # Neo and rescue file readers
│ │ ├── neo_adapter.py # Header-first NeoAdapter
│ │ ├── neo_source_handle.py # Lazy trial loader handle
│ │ ├── abf_reader.py # ABF helper utilities
│ │ └── format_support.py # Explicit validation tier map per extension
│ ├── exporters/ # Scientific data exporters
│ │ ├── csv_exporter.py # Summary, tidy, events, recording, Prism CSV + JSON provenance
│ │ └── nwb_exporter.py # NWB:N 2.0 / DANDI exporter (NWBExporter)
│ └── neo_patches.py # Upstream Neo compatibility patches
├── shared/ # Cross-cutting utilities and plot styling
│ ├── constants.py # Application-wide constants (APP_NAME, etc.)
│ ├── cursor_manager.py # Interactive plot cursor management
│ ├── data_cache.py # Recording cache singleton
│ ├── error_handling.py # Custom exception hierarchy
│ ├── logging_config.py # Logging setup and boot.log stdio guard
│ ├── plot_customization.py # PlotCustomizationManager pens and brushes
│ ├── plot_exporter.py # Plot export logic (PNG, PDF, SVG)
│ ├── plot_factory.py # SynaptipyPlotFactory (mandatory widget factory)
│ ├── plot_zoom_sync.py # Cross-tab zoom synchronization
│ ├── scroll_settings.py # Scroll direction preferences
│ ├── styling.py # Qt widget styling helpers (style_button)
│ ├── theme_manager.py # Light/dark/system theme state management
│ ├── utils.py # General shared utilities
│ ├── viewbox.py # Custom pyqtgraph ViewBox subclass
│ ├── xlsx_exporter.py # Dependency-free XLSX workbook writer
│ └── zoom_theme.py # Zoom state theming utilities
├── resources/ # Icons and compiled offline help (.qhc/.qch)
└── templates/ # Reference archetypes and starter templates
├── analysis_template.py # Annotated two-layer analysis template
├── plugin_template.py # Starter user plugin template
├── tab_template.py # Custom GUI analysis tab template
└── test_template.py # Pytest unit test template
tests/ # Pytest test suite
├── conftest.py # Session fixtures, QSettings isolation, offscreen guards
├── application/ # Application, CLI, and controller tests
├── core/ # Core analysis, DSP, and golden master tests
├── gui/ # Headless Qt/pyqtgraph widget tests
├── infrastructure/ # File reader and NWB/CSV exporter tests
└── shared/ # Shared utility tests
scripts/ # Developer and CI automation scripts
├── verify_ci.py # Full local CI gate (black, isort, flake8, pytest, emoji scan)
├── run_tests.py # Convenient test runner wrapper
├── bump_version.py # Atomic version updater (pyproject.toml, Inno Setup, environment.yml)
├── build_offline_help.py # Compiles Sphinx QtHelp (.qhc/.qch) offline manual
├── check_published_docs.py # Validates built HTML documentation output
├── capture_screenshots.py # Deterministic offscreen UI screenshot generator
└── build_icons.py # Cross-platform icon builder (.icns / .ico)
docs/ # Sphinx + MyST documentation source
examples/ # Example scripts, notebooks, data, and 5 plugins
5-Pillar Analyser Architecture
The Synaptipy Analyser UI is strictly fixed to five core pillar tabs. Each
pillar corresponds to a module-level aggregator entry in AnalysisRegistry,
covering 16 built-in leaf analysis routines in total (alongside 7 registered
signal preprocessors in core/analysis/preprocessing.py). Sub-analyses are
exposed via method_selector drop-downs inside each pillar tab and are never
added as separate core top-level tabs.
Pillar |
Module file |
Registry key |
Sub-analyses (16 total) |
|---|---|---|---|
1 - Passive Properties |
|
|
Baseline (RMP), Input Resistance, Tau, Sag Ratio, I-V Curve, Capacitance |
2 - Single Spike Kinetics |
|
|
Spike Detection, Phase Plane |
3 - Firing Dynamics |
|
|
Excitability, Burst Analysis, Spike Train Dynamics |
4 - Synaptic Events |
|
|
Amplitude (Threshold), Template (Deconvolution) |
5 - Evoked Responses |
|
|
Evoked Sync, Paired-Pulse Ratio, Stimulus Train (STP) |
Specialized or domain-specific analyses are implemented as standalone plugins
in examples/plugins/ (or ~/.synaptipy/plugins/), which appear after the
five core pillars when custom plugins are enabled.
Immutable Trace Correction Pipeline
All backend trace conditioning runs through apply_trace_corrections() in
src/synaptipy/core/processing_pipeline.py. Regardless of the order in which a
user toggles controls in the GUI, apply_trace_corrections() enforces an
immutable five-step sequence (A -> B -> C -> D -> E):
Step A - Unit-Aware LJP Voltage Offset: Subtracts the liquid junction potential on voltage traces (
V_true = V_recorded - ljp_mvinmV, with automatic scaling forVanduV; skipped on current channels).Step B - P/N Leak Subtraction: Computes the per-sample mean across sub-threshold P/N sweeps (
pn_traces), scales bypn_scale, and subtracts capacitive transients and steady-state leak currents.Step C - Pre-Event Noise Floor Zeroing: Subtracts the scalar median of the specified pre-event baseline window (
pre_event_window_s = (t_start, t_end)).Step D - Pre-Filter Linear Artifact Interpolation: Linearly interpolates across stimulus artifact windows (
artifact_interp_steps) after Steps A-C and before filtering so sharp transient edges cannot induce Gibbs ringing.Step E - DSP Filtering: Applies digital filter steps (
filter_steps) throughSignalProcessingPipeline.process().
See Algorithmic Definitions for the mathematical specification of each stage.
Writing Custom Analysis Plugins
Synaptipy supports two ways to add analysis functionality:
Standalone plugins (recommended for new metrics): Place a
.pyfile in~/.synaptipy/plugins/(or contribute reusable domain examples toexamples/plugins/). Because the core UI is locked to the five pillar tabs, novel standalone metrics belong in plugins rather than new core tabs.Core pillar sub-analyses (core contributors): When extending one of the five existing pillars, add a pure logic function (returning a typed dataclass from
src/synaptipy/core/results.py) and an@AnalysisRegistry.registerwrapper inside the appropriate pillar module insrc/synaptipy/core/analysis/, wire it into that pillar’smethod_selector, and add unit tests intests/core/.
Four example plugins are available from Help > Download Example Plugins….
They are saved to ~/.synaptipy/plugins/ and load when Enable Custom
Plugins is checked under Edit > Preferences (Extensions group).
Source checkouts and desktop bundles also include these files in
examples/plugins/:
Plugin file |
Tab label |
Purpose |
|---|---|---|
|
Synaptic Charge (AUC) |
Integrates postsynaptic current ( |
|
Opto Latency Jitter |
Trial-to-trial evoked response latency variability after TTL pulses |
|
miniML Events |
Deep-learning event detection via miniML (optional dependency; requires TensorFlow and cloned miniML repository) |
|
Spike Detection (SpikeInterface) |
Extracellular spike detection via SpikeInterface (optional dependency; |
A starter template is provided at src/synaptipy/templates/plugin_template.py.
For the complete plugin specification - including ui_params widgets, plots
overlays, @AnalysisRegistry.register_processor, return-dict conventions, and
annotated examples - see Writing Custom Analysis Plugins.
Architecture and Performance Patterns
Asynchronous UI and Background Loading
Synaptipy uses QThread and QRunnable for background data loading and
analysis. Recording files (.abf, .wcp, .nwb, etc.) are loaded
asynchronously so large multi-sweep files do not block the Qt event loop.
Because of this asynchronous architecture, direct UI assertions in tests must
synchronize with background worker completion using qtbot.waitUntil rather
than time.sleep().
UI Interaction Debouncing and Plot Factory
Mandatory Plot Factory: Never instantiate
pg.PlotWidgetorpg.GraphicsLayoutWidgetdirectly. Always create plot widgets viaSynaptipyPlotFactory(src/synaptipy/shared/plot_factory.py) to preserve cross-platform OpenGL safety and theme consistency.Debouncing: Rapid zoom and pan signals in
explorer_tab.pyand real-time parameter updates are debounced to prevent flooding the main GUI thread.
UI and Styling Guidelines
Synaptipy prioritizes visual accessibility. Multi-trial plotting uses colorblind-safe palettes (such as Okabe-Ito or Viridis).
When extending the UI or configuring plugin overlays:
Do not hardcode overlapping red and green traces.
Use
get_plot_customization_manager()(src/synaptipy/shared/plot_customization.py) andtheme_manager.pyrather than hardcoded widget stylesheets.Use
style_button(button)for standard controls andstyle_button(button, "primary")for at most one primary action per visible panel. See the Styling Guide for details.
Development Workflow
Feature Development
Create a branch: Create a feature or fix branch from
main:git checkout -b feature/your-feature-name
Implement changes: Follow the separation-of-concerns rules (
core/must never importPySide6,PyQt6, ormatplotlib.pyplot).Add tests: Place unit tests in
tests/core/and headless GUI tests intests/gui/.Run local CI verification: Verify formatting, linting, emoji checks, and headless test coverage before pushing:
conda run -n synaptipy python scripts/verify_ci.py
Submit a pull request: Push your branch and open a pull request against
main.
Code Review Process
All contributions undergo review for:
Architectural boundaries (
core/purity,SourceHandlelazy loading,channel.get_data(trial_index))Scientific accuracy and unit safety (epsilon guards,
np.nansentinels, provenance recording)Test coverage and headless cross-platform stability
Formatting, complexity (
<= 10), and documentation standards
Testing
Running Tests
Run the full local CI verification gate (recommended before every push):
conda run -n synaptipy python scripts/verify_ci.py
Run the test suite via scripts/run_tests.py:
conda run -n synaptipy python scripts/run_tests.py
Run a specific test module:
conda run -n synaptipy python scripts/run_tests.py --test test_main_window
Run with coverage reporting:
conda run -n synaptipy python scripts/run_tests.py --coverage
CI Test Matrix
CI runs on all three major operating systems across Python 3.10, 3.11, and 3.12:
Platform |
Python Versions |
|---|---|
Ubuntu (latest) |
3.10, 3.11, 3.12 |
Windows (latest) |
3.10, 3.11, 3.12 |
macOS (latest) |
3.10, 3.11, 3.12 |
CI enforces black --check, isort --check, flake8, and the zero-emoji
policy. Pull requests that fail any check are rejected.
The CI coverage gate enforces a minimum of 90% coverage across src/synaptipy,
while new engineering changes target 95% coverage. On macOS, run the full GUI
suite with QT_QPA_PLATFORM=offscreen and use targeted non-offscreen pytest
runs when inspecting local coverage.py reports on individual modules, because
the intentional offscreen force-exit bypasses Python atexit handlers. CI’s
Linux runner generates the canonical coverage.xml report.
Documentation Screenshot Refresh
Published screenshots are deterministic UI captures generated from the pinned environment:
conda run --no-capture-output -n synaptipy env QT_QPA_PLATFORM=offscreen \
python scripts/capture_screenshots.py
The capture runner applies a deterministic dark theme, isolates bundled example
plugins from ~/.synaptipy/plugins/, and refreshes independent screenshot
groups in fresh Qt processes while preserving hand-authored figures.
scripts/verify_ci.py --with-screenshots validates screenshot generation within
a 180-second timeout.
Additional release-safety jobs run automatically in CI:
minimum-viable: Python 3.10 with lower-bound dependency versions (numpy==2.0.0,scipy==1.14.0,neo==0.14.0,pyqtgraph==0.13.3,PySide6==6.7.3).latest-dependencies: Python 3.12 with all upgradable dependencies at their latest compatible releases (PySide6remains pinned to6.7.3).hidpiandnotebooks: High-DPI Qt/pyqtgraph verification and executable tutorial notebook checks.wheel-install: Builds the wheel and verifies installation in a clean virtual environment, including compiled offline documentation checks viascripts/build_offline_help.pyandscripts/check_published_docs.py.security: Audits packaged sources for security issues.
Golden Master Tests
tests/core/test_golden_master.py freezes floating-point outputs from core
algorithms against reference ABF recordings in examples/data/ and synthetic
traces. If a dependency update alters a computed metric beyond tolerance
(rel=1e-5 for most metrics, rel=1e-2 for exponential tau fits), these
tests fail and identify the drifting metric.
When to update golden master values:
If you intentionally revise an algorithm (for example, refining initial-guess
estimation in calculate_tau), inspect the updated output on an example ABF
recording and update tests/core/test_golden_master.py in a dedicated commit:
conda run -n synaptipy python -c "
from pathlib import Path
from synaptipy.infrastructure.file_readers.neo_adapter import NeoAdapter
from synaptipy.core.analysis.passive_properties import calculate_rmp
adapter = NeoAdapter()
rec = adapter.read_recording(Path('examples/data/2023_04_11_0018.abf'))
ch = list(rec.channels.values())[0]
v = ch.get_data(0)
t = ch.get_relative_time_vector(0)
print(calculate_rmp(v, t, baseline_window=(0.0, 0.5)))
"
# Update tests/core/test_golden_master.py with the verified reference value
# and commit with a clear message, e.g.: 'test: update golden masters for revised tau fit'
Do not loosen golden master tolerances without documented numerical justification.
Writing Tests
Place tests in the matching subdirectory of
tests/(core/,gui/,application/,infrastructure/,shared/).Name all test files
test_*.pysopytestdiscovers them automatically.Use
pytestfixtures (qtbotfor GUI widgets; never importPySide6insidetests/core/).Use
pathlib.Pathfor all filesystem paths andencoding="utf-8"when reading or writing text files.
CI Behaviour and Platform-Specific Test Rules
The test suite runs PySide6 (==6.7.3) and pyqtgraph widgets under
QT_QPA_PLATFORM=offscreen. Several platform-specific crash patterns have been
eliminated; the safeguards below must not be removed.
PyInstaller console=False and faulthandler.enable()
Windowed executables built with console=False may set sys.stdout and
sys.stderr to None or to streams lacking an OS file descriptor. Standard
library faulthandler.enable() calls sys.stderr.fileno(); replacing None
with io.StringIO still raises io.UnsupportedOperation. Entry points call
ensure_stdio_streams_support_fileno() in synaptipy.shared.logging_config
before importing Qt. When either stream is missing or lacks fileno(), it is
pointed at an append handle to ~/.synaptipy/logs/boot.log (or
SYNAPTIPY_LOG_DIR/boot.log) so early startup crashes and C tracebacks are
preserved on disk, falling back to os.devnull only if the log directory is
not writable.
Analysis Registry import rule - DO NOT import only registry.py
To populate AnalysisRegistry, always import the full analysis package:
import synaptipy.core.analysis # triggers __init__.py -> passive_properties, single_spike, preprocessing, etc.
Never rely on from synaptipy.core.analysis.registry import AnalysisRegistry
alone when looking up built-in analyses: importing registry.py defines the
class without executing the @AnalysisRegistry.register and
@AnalysisRegistry.register_processor decorators in the sibling modules.
Both startup_manager._begin_loading() and
analyser_tab._load_analysis_tabs() import synaptipy.core.analysis before
querying AnalysisRegistry.list_registered() so Windows and macOS populate
identical registry snapshots regardless of prior import order.
Editable install must point to the active workspace
pip install -e . records the editable source path in .pth metadata. If the
repository is moved or cloned to a second directory, an older editable install
continues resolving imports from the previous checkout. Re-run
pip install -e ".[dev]" from the active workspace whenever switching worktrees.
Symptom: newly added modules visible on disk (such as contracts.py,
preprocessing.py, or protocols.py) raise ModuleNotFoundError because
Python imports synaptipy from a stale checkout. Verify the active path with:
pip show synaptipy | grep "Editable project location"
Offscreen pytest_sessionfinish teardown on POSIX and Windows
PySide6 and pyqtgraph leave C++ scene-graph wrappers partially alive at
interpreter shutdown. Allowing normal C++/CRT teardown after an offscreen GUI
session dereferences freed C++ pointers. pytest_sessionfinish in
tests/conftest.py therefore terminates the process explicitly when
QT_QPA_PLATFORM=offscreen is set:
macOS and Linux (POSIX): Calls
os._exit(exitstatus), invoking libc_exit()directly to bypass C++ static destructors,atexithandlers, and cyclic garbage collection. On macOS,conda runmay print anAbort trap: 6orQThreadmessage even whenexitstatus == 0; inspect pytest’s summary line (N passed, zeroFAILED/ERROR) rather than conda’s wrapper message:conda run -n synaptipy python -m pytest tests/ 2>&1 | grep -c PASSED conda run -n synaptipy python -m pytest tests/ 2>&1 | grep "FAILED\|ERROR "
Windows (
sys.platform == "win32"): Calls Win32kernel32.TerminateProcess(ctypes.c_void_p(-1), int(exitstatus))with explicit 64-bitargtypes. On Windows,os._exit()callsExitProcess(), which still dispatchesDLL_PROCESS_DETACHto loaded Qt DLLs and triggers access violations;TerminateProcessbypassesDLL_PROCESS_DETACHwhile preserving the exactpytestexit status code.
GC must be disabled in offscreen mode
pytest_configure in tests/conftest.py disables Python’s cyclic garbage
collector (gc.disable()) when QT_QPA_PLATFORM=offscreen. Do not remove this
guard: cyclic GC can invoke tp_dealloc on PySide6 wrapper objects mid-way
through Qt’s C++ destructor chain, causing SIGBUS on macOS and access
violations on Windows.
processEvents() before addPlot() in offscreen mode
SynaptipyPlotCanvas.add_plot() calls QCoreApplication.processEvents()
before widget.addPlot() when QT_QPA_PLATFORM=offscreen. Deferred callbacks
queued by an earlier widget.clear() or widget construction must execute before
PlotItem.__init__() runs; otherwise they fire mid-constructor and dereference
freed C++ pointers on Windows.
Executing pending events with processEvents() rather than discarding them with
removePostedEvents() is required because removePostedEvents on macOS drops
internal pyqtgraph AllViews range and geometry events, corrupting subsequent
widget.clear() calls.
removePostedEvents() must skip macOS
The _drain_qt_events_after_test fixture in tests/conftest.py guards
QCoreApplication.removePostedEvents(None, 0) with
if sys.platform != "darwin":. Keep this platform guard intact so macOS
ViewBox geometry caches remain consistent across session-scoped tests.
Plot teardown order
SynaptipyPlotCanvas.clear_plots() executes six steps in strict order:
_unlink_all_plots()- breaksetXLink/setYLinkconnections before teardown._close_all_plots()- disconnect control signals and callPlotItem.close()while the scene is valid._cancel_pending_qt_events()- discard stale posted events (Windows/Linux only).widget.clear()- destroy C++ layout children via Qt’s scene graph.plot_items.clear()- drop Python references after C++ teardown completes._flush_qt_registry()- clear residual registry references posted bywidget.clear().
Dropping Python references (step 5) before widget.clear() (step 4) causes
PySide6 >= 6.7 to segfault on macOS when C++ destructors reach back into
collected Python wrappers.
NeoAdapter ABF rescue path
src/synaptipy/infrastructure/file_readers/neo_adapter.py reads
electrophysiology recordings via neo. Certain .abf files report truncated
single-character unit prefixes ("p", "n", "m" instead of "pA", "nA",
"mV") or fail inside AxonIO chunking. When this occurs, NeoAdapter falls
back to pyabf (_pyabf_to_neo_block):
The
pyabfrescue path runs before the genericlazy=Truefallback so brokenAnalogSignalProxyobjects do not mask unit or chunking errors._ABF_PREFIX_UNITSmaps truncated SI prefixes toquantitiesunits ("p" -> pq.pA,"n" -> pq.nA,"m" -> pq.mV).Rescue activation logs at
DEBUG/INFOlevel rather thanERROR, as fallback recovery is an expected code path for affected ABF headers.
Coding Standards
Formatting: Code is formatted with black and isort (
--profile black).Linting: flake8 enforces style and cyclomatic complexity (
max-complexity = 10;.flake8setsmax-line-length = 120onsrc/andtests/, and CI also checks syntax/line limits up to 127 characters). Zero unused imports (F401) or unused variables (F841) are permitted.Zero Emojis and Typography: Emojis, Dingbats, em dashes, and en dashes are strictly prohibited across code, docstrings, and documentation (
scripts/verify_ci.pyfails on any match).Docstrings and Type Hints: Public classes, functions, and methods require docstrings and explicit Python type annotations.
Explicit Error Handling: Catch specific exception classes (
ValueError,KeyError,OSError, orSynaptipyErrorsubclasses inshared/error_handling.py) rather than bareexcept:or broadexcept Exception:blocks in core logic.
Formatting Your Code
Run formatters, linter, and the full CI verifier before committing:
# Format imports and code
conda run -n synaptipy isort src/ tests/ scripts/
conda run -n synaptipy black src/ tests/ scripts/
# Lint for style and cyclomatic complexity
conda run -n synaptipy flake8 src/ tests/ --count --statistics
# Run the complete local CI gate (format check, flake8, headless pytest, emoji scan)
conda run -n synaptipy python scripts/verify_ci.py
Verify formatting non-destructively (matching GitHub Actions):
conda run -n synaptipy black --check --diff src/ tests/
conda run -n synaptipy isort --check --diff src/ tests/
License Compliance
Synaptipy is licensed under the GNU Affero General Public License Version 3 (AGPL-3.0-or-later).
License Requirements
Contributors must:
Include license notice: Reference the AGPL-3.0 license in new source files.
Preserve copyright notices: Retain existing copyright attributions.
Document changes: Record user-visible additions, fixes, and breaking changes under
[Unreleased]inCHANGELOG.md.Share modifications: Distribute complete corresponding source code when deploying modified builds.
Adding New Files
Include the standard license header in new Python modules:
#!/usr/bin/env python3
"""
Brief description of the module.
Detailed description of the module's purpose and functionality.
This file is part of Synaptipy, licensed under the GNU Affero General Public License v3.0.
See the LICENSE file in the root of the repository for full license details.
"""
Third-Party Dependencies
All Python dependencies must be declared in pyproject.toml (the single source
of truth), and requirements.txt must be regenerated via
pip-compile pyproject.toml -o requirements.txt rather than edited manually.
Any new dependency must carry an AGPL-3.0-compatible license:
GPL-3.0 and AGPL-3.0 are directly compatible.
Permissive licenses (LGPL, MIT, BSD, Apache 2.0) are compatible alongside AGPL-3.0.
Proprietary or non-commercial-only licenses are incompatible and must not be added.
Discuss proposed dependencies with the maintainers before opening a pull request,
and evaluate whether dynamic imports or data files require entries in synaptipy.spec.