Skip to content

NsxFile.getdata() returns only the first segment for a multi-segment .ns3 file #43

Description

@Zippereden

Summary

NsxFile.getdata() returns only the first segment from a .ns3 file that contains three segments according to MATLAB NPMK openNSx(..., 'noread').

This may cause underestimation of recording duration and incorrect NSx/NEV timestamp alignment.

File information

  • File type: .ns3
  • Sampling frequency: 2000 Hz
  • Number of channels: 128

Python / brpylib

# Python: 3.10.20
# NumPy: 1.26.4
# brpylib version: 2.0.3
from brpylib import NsxFile

nsx = NsxFile(r"path/to/file.ns3")
data = nsx.getdata()

print(len(data["data"]))
print(data["data"][0].shape)
print(data["data_headers"])

nsx.close()

output:

1
(128, 222453)
[{'Timestamp': 102417735, 'NumDataPoints': 222453, 'data_time_s': 111.2265}]

MATLAB / NPMK comparison

Using the same file:

nsx = openNSx('path/to/file.ns3', 'noread');

disp(nsx.MetaTags.Timestamp(:))
disp(nsx.MetaTags.DataPoints(:))

Output:

Timestamp:
102417735
105754560
155579445

DataPoints:
222453
3321658
170053

Question

Is NsxFile.getdata() expected to support multi-segment / multi-data-packet NSx files? If yes, this appears to be a parsing bug. If not, it may be useful to document this limitation explicitly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions