Skip to content

Add Intan RHD2000 file header reader#17

Merged
stevevanhooser merged 3 commits intomainfrom
claude/pip-installable-intan-rhd-9sc0o
Mar 16, 2026
Merged

Add Intan RHD2000 file header reader#17
stevevanhooser merged 3 commits intomainfrom
claude/pip-installable-intan-rhd-9sc0o

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR adds support for reading Intan RHD2000 file headers, porting the MATLAB implementation to Python. It includes a complete header parser and comprehensive test coverage.

Key Changes

  • New module vlt/hardware/intan.py: Implements read_Intan_RHD2000_header() function that parses RHD2000 binary file headers

    • Reads magic number validation, version info, sample rates, and frequency parameters
    • Parses Qt-style QString format used in RHD files
    • Extracts channel information (amplifier, aux input, supply voltage, ADC, digital I/O)
    • Computes total number of samples from file size and data block structure
    • Supports both RHD version 1.x (60 samples/block) and 2.x (128 samples/block)
  • Comprehensive test suite tests/vlt/hardware/test_intan.py:

    • Helper function to create synthetic RHD files for testing
    • Tests for basic header reading, sample rate calculations, channel info parsing
    • Tests for frequency parameters, version compatibility, and error handling
    • Validates magic number validation and edge cases (empty files, no data blocks)
  • Project configuration:

    • Added pyproject.toml with package metadata and dependencies
    • Added GitHub Actions CI workflow for linting and testing across Python 3.10-3.12
    • Updated .gitignore to exclude egg-info directories

Implementation Details

  • The header parser correctly handles version-dependent fields (temp sensors, eval board mode, reference channel)
  • Properly computes bytes per data block accounting for different channel types and their sampling rates
  • Returns a comprehensive dictionary with all header information needed for subsequent data reading
  • Includes proper error handling for invalid file formats

https://claude.ai/code/session_01AQ3fUwbRvMsTS2pyJpQXRk

claude added 3 commits March 16, 2026 23:29
Make vhlab-toolbox-python pip-installable by adding pyproject.toml with
setuptools build backend and proper dependencies (numpy, pandas, scipy, h5py).

Port read_Intan_RHD2000_header from MATLAB to vlt/hardware/intan.py,
supporting both v1.x (60 samples/block) and v2.x (128 samples/block)
RHD files. The function reads binary headers including magic number
verification, sample rate, frequency parameters, channel definitions,
and computes num_samples from file size.

Add comprehensive tests with synthetic .rhd file generation covering
header reading, t0/t1 computation, channel info, frequency parameters,
invalid files, version 2 format, and header-only files.

https://claude.ai/code/session_01AQ3fUwbRvMsTS2pyJpQXRk
Ignore setuptools egg-info build artifacts generated by pip install -e.

https://claude.ai/code/session_01AQ3fUwbRvMsTS2pyJpQXRk
Add GitHub Actions CI workflow with:
- Lint job using ruff with rules configured to pass on existing codebase
- Test job with matrix strategy for Python 3.10, 3.11, and 3.12

Also add matplotlib to dependencies, pytest as optional test dependency,
and configure pytest importlib mode to resolve test name collisions.

https://claude.ai/code/session_01AQ3fUwbRvMsTS2pyJpQXRk
@stevevanhooser stevevanhooser merged commit b073185 into main Mar 16, 2026
4 checks passed
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.

2 participants