Port NDR reader framework from MATLAB to Python#1
Merged
stevevanhooser merged 2 commits intomainfrom Mar 17, 2026
Merged
Conversation
- Create repo structure mirroring MATLAB +namespace paths - Port ndr.reader.base abstract base class with all method signatures - Port ndr.reader wrapper (reader_wrapper.py) with read(), delegation - Implement Intan RHD format reader with binary file parsing - Implement Axon ABF reader (pyabf backend) - Implement CED SMR reader (neo backend) - Add stub readers: BJG, Dabrowska, Neo, SpikeGadgets, TDT, WhiteMatter - Port utility packages: time (clocktype, samples2times, times2samples), data (colvec, rowvec), string (channelstring2channels, str2intseq), file (textfile2char), fun (ndrpath, ndrresource, bitDepth) - Port globals, known_readers with ndr_reader_types.json resource - Create bridge YAML files for reader and format/intan packages - Create developer notes: porting guide, xlang principles, bridge spec, symmetry test docs - Create symmetry test framework (make_artifacts, read_artifacts) - Add 50 unit tests covering base class, Intan static methods, channel strings, time functions, known readers, and wrapper - All tests pass, black formatted, ruff clean https://claude.ai/code/session_01QGdJXLDUuQGSiDw8ZggEMU
- Lint job: black --check and ruff check - Test job: pytest across Python 3.10, 3.11, 3.12 with fail-fast disabled https://claude.ai/code/session_01QGdJXLDUuQGSiDw8ZggEMU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive Python port of the NDR (Neuroscience Data Reader) MATLAB library, establishing the core reader framework and format-specific handlers for reading neural data files.
Key Changes
Core Reader Framework
ndr/reader/base.py: Abstract base class for all format-specific readers with concrete utility methods for channel validation, type conversion, and time/sample conversionsndr/reader_wrapper.py: High-levelReaderclass providing unified interface to format-specific readers with dynamic loader based on data format typeFormat-Specific Readers
ndr/reader/intan_rhd.py: Complete reader for Intan RHD2000 format with channel mapping, header parsing, and data block handlingndr/reader/axon_abf.py: Reader for Axon ABF format (pyabf-based)ndr/reader/ced_smr.py: Reader for CED Spike2 SMR format (neo-based)ndr/reader/neo.py: Generic neo library wrapper for multiple formatstdt_sev.py,bjg.py,dabrowska.py,spikegadgets_rec.py,whitematter.pyfor future implementationIntan RHD Format Handler
ndr/format/intan/read_Intan_RHD2000_header.py: Binary header parsing with Qt QString supportndr/format/intan/read_Intan_RHD2000_datafile.py: Data block structure calculation and file I/OUtility Modules
ndr/time/clocktype.py,ndr/time/fun/samples2times.py,ndr/time/fun/times2samples.pyfor time/sample conversionsndr/string/channelstring2channels.py,ndr/string/str2intseq.py,ndr/string/intseq2str.pyfor channel specification parsingndr/data/colvec.py,ndr/data/rowvec.pyfor array reshapingndr/fun/ndrpath.py,ndr/fun/ndrresource.py,ndr/fun/bitDepth.py,ndr/fun/getDataTypeString.pyndr/file/textfile2char.pyConfiguration & Resources
ndr/resource/ndr_reader_types.json: Registry mapping format identifiers to reader class implementationsndr/globals.py: Global path and configuration managementndr/known_readers.py: Public API for discovering available readersTesting & Documentation
tests/test_reader_base.py,tests/test_readers.pywith comprehensive coverage of static methods and channel type conversionstests/symmetry/with artifact generation and validation for MATLAB/Python parityndr_matlab_python_bridge.yamlfiles documenting MATLAB-to-Python mapping contractsPYTHON_PORTING_GUIDE.md,ndr_xlang_principles.md,symmetry_tests.mdfor cross-language developmentProject Configuration
pyproject.toml: Package metadata, dependencies (numpy, pydantic, vhlab-toolbox-python), and optional dev dependenciesREADME.md: Updated with comprehensive overview of NDR architecture and capabilitiesImplementation Details
https://claude.ai/code/session_01QGdJXLDUuQGSiDw8ZggEMU