Skip to content

Refactor channel inference in inferSubEpochChannels function to impro… - #26

Merged
yoshihito-saito merged 1 commit into
masterfrom
fix-mergepoints-waveform-fallback
Jul 31, 2026
Merged

Refactor channel inference in inferSubEpochChannels function to impro…#26
yoshihito-saito merged 1 commit into
masterfrom
fix-mergepoints-waveform-fallback

Conversation

@yoshihito-saito

Copy link
Copy Markdown
Collaborator

Summary

This PR updates NeuroScope2 sub-epoch dat handling so that the channel count comes from session.extracellular.nChannels instead of being inferred from the timestamp-derived sample count.

Motivation

Some Intan datasets can have small timestamp gaps in time.dat. In those cases, MergePoints.timestamps_samples / session.epochs may report a sample span that is slightly longer than the actual number of samples stored in amplifier.dat.

For example, one dataset had:

  • amplifier.dat: 157,831,296 actual samples at 128 channels int16
  • MergePoints/session: 157,831,323 expected samples
  • time.dat: timestamp jump from 152,339,682 to 152,339,711

The raw file size was valid for 128 channels, but channel inference failed because it used the timestamp-derived sample count.

Changes

  • Treat session.extracellular.nChannels as the authoritative channel count for sub-epoch dat files.
  • Validate that file size is divisible by nChannels * sampleBytes.
  • Derive sub-epoch sample count from file size.
  • Warn, rather than error, when metadata sample count differs from file-derived sample count.

Validation

  • Confirmed NeuroScope2.m parses successfully with MATLAB mtree.
  • Tested against the real failing dataset:

…ve file size validation and sample count handling
@yoshihito-saito
yoshihito-saito merged commit 54694a0 into master Jul 31, 2026
1 check 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.

1 participant