Skip to content

nsX files showing num_data_pts=0 #37

Description

@luiztauffer

Describe the bug
I'm getting an OverflowError error when trying to read from ns2 and ns6 files from he same recording session. File Spec 2.3

To Reproduce

import brpylib

ns2 = brpylib.NsxFile("H4.3_openField_PPX_091423001.ns2")

ns2.basic_header    # works fine
ns2.extended_headers[-5:]    # works fine
d = ns2.getdata(elec_ids=[10])    # breaks here

error:

---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[5], line 1
----> 1 d = ns2.getdata(elec_ids=[1])

File ~/anaconda3/envs/env_nelson/lib/python3.13/site-packages/brpylib/brpylib.py:1204, in NsxFile.getdata(self, elec_ids, start_time_s, data_time_s, downsample, zeropad, full_timestamps, elec_rows, force_srate)
   1202 timestamp = unpack(ts_type, self.datafile.read(ts_size))[0]
   1203 num_data_pts = unpack("<I", self.datafile.read(4))[0]
-> 1204 timestamp = timestamp + (clk_per_samp * np.arange(num_data_pts)).astype(np.int64 if ts_size==8 else np.int32)
   1205 bod = self.datafile.tell()  # Beginning of segment data
   1206 output["data_headers"].append({
   1207     "Timestamp": timestamp,
   1208     "NumDataPoints": num_data_pts,
   1209     "data_time_s": num_data_pts / output["samp_per_s"]
   1210 })

OverflowError: Python integer 3439329535 out of bounds for int32
  • OS: Linux (Ubuntu 20.04)
  • Python 3.13.2
  • Python-Utilities: main branch
  • Numpy 2.2.4

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