Skip to content

Add multi-file recording support for Intan RHD2000 format#101

Merged
stevevanhooser merged 5 commits into
mainfrom
claude/rhd-multi-file-timestamps-MeY84
May 6, 2026
Merged

Add multi-file recording support for Intan RHD2000 format#101
stevevanhooser merged 5 commits into
mainfrom
claude/rhd-multi-file-timestamps-MeY84

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR adds support for reading Intan RHD2000 recordings that span multiple files. The Intan acquisition software saves new files when reaching a file-length threshold, and this implementation allows the reader to transparently treat such multi-file recordings as a single continuous recording.

Key Changes

  • New utility function getRHD2000FileList(): Discovers and sorts RHD2000 files by timestamp when given a single file from a multi-file recording set. Supports both 'singleFile' and 'multiFile' modes.

  • Enhanced header reading: read_Intan_RHD2000_header() now accepts a 'fileMode' parameter and attaches multi-file metadata (file list, sizes, header size) to the returned header structure for downstream use.

  • Block info aggregation: Intan_RHD2000_blockinfo() now returns per-file block counts and aggregates block/byte information across all files in a multi-file recording.

  • Transparent data reading: read_Intan_RHD2000_datafile() now handles multi-file recordings by dispatching read requests to constituent files and concatenating results, allowing time indices to refer to the concatenated recording.

  • Reader auto-detection: intan_rhd.reader now detects when multiple .rhd files are provided in epochstreams and automatically switches to multi-file mode, treating them as a single continuous recording.

  • Comprehensive test coverage: Added testMultiFileMode() test that verifies file discovery, ordering, header parsing, block aggregation, and data reading across file boundaries.

Implementation Details

  • Files are identified by the Intan naming convention: <prefix>_YYMMDD_HHMMSS.rhd
  • Files are sorted chronologically by timestamp to ensure correct concatenation order
  • Multi-file metadata is stored in header.fileinfo.multifile for use by block and data readers
  • Data reads that span file boundaries are handled by reading the tail of one file and head of the next, then concatenating
  • The implementation assumes identical acquisition parameters across all files in a multi-file set (only the first file's header is parsed)

https://claude.ai/code/session_01JoFTRhGXNeLWtLJxG1nYDC

Intan's acquisition software splits long recordings into multiple .rhd
files that share a common prefix and a YYMMDD_HHMMSS timestamp. Add a
new getRHD2000FileList helper plus a 'fileMode' option on the header
and data-file readers that, when set to 'multiFile', expose the entire
set as a single recording: aggregated block counts, total samples and
time, and reads that transparently span file boundaries. The reader
class auto-detects multi-file epochs when more than one .rhd is in the
epochstreams.
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Analyzer found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Test Results

128 tests  +2   128 ✅ +2   5s ⏱️ ±0s
 16 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit fd544b4. ± Comparison against base commit 0ec206b.

♻️ This comment has been updated with latest results.

github-actions Bot and others added 4 commits May 6, 2026 12:43
Add a detectRHD2000FileMode helper that returns 'multiFile' when an
.rhd file has at least one sibling matching the
<prefix>_<YYMMDD>_<HHMMSS>.rhd pattern in the same directory, and
'singleFile' otherwise. Wire it into getRHD2000FileList,
read_Intan_RHD2000_header, and read_Intan_RHD2000_datafile as a new
'detect' fileMode and make 'detect' the default. The reader class
also defaults to 'detect' for single-file epochstreams so multi-file
recordings are picked up without callers passing fileMode.
@stevevanhooser stevevanhooser merged commit a06afbc into main May 6, 2026
@stevevanhooser stevevanhooser deleted the claude/rhd-multi-file-timestamps-MeY84 branch May 6, 2026 16:59
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.

3 participants