Add multi-file recording support for Intan RHD2000 format#101
Merged
Conversation
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.
There was a problem hiding this comment.
Code Analyzer found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Contributor
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.
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 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.readernow 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
<prefix>_YYMMDD_HHMMSS.rhdheader.fileinfo.multifilefor use by block and data readershttps://claude.ai/code/session_01JoFTRhGXNeLWtLJxG1nYDC