Skip to content

Blackrock ns6 OverflowError: Python integer out of bounds for uint32 #1689

Closed

Description

@luiztauffer
import neo

base_path = ".../H0.2_openField_PPX_062723001"
r6 = neo.rawio.BlackrockRawIO(filename=base_path, nsx_to_load=[6], load_nev=False)
r6.parse_header()
r6.header
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[13], line 2
      1 r6 = neo.rawio.BlackrockRawIO(filename=base_path, nsx_to_load=[6], load_nev=False)
----> 2 r6.parse_header()
      3 r6.header

File ~/anaconda3/envs/env_nelson/lib/python3.13/site-packages/neo/rawio/baserawio.py:211, in BaseRawIO.parse_header(self)
    197 """
    198 Parses the header of the file(s) to allow for faster computations
    199 for all other functions
    200 
    201 """
    202 # this must create
    203 # self.header['nb_block']
    204 # self.header['nb_segment']
   (...)    208 # self.header['spike_channels']
    209 # self.header['event_channels']
--> 211 self._parse_header()
    212 self._check_stream_signal_channel_characteristics()
    213 self.is_header_parsed = True

File ~/anaconda3/envs/env_nelson/lib/python3.13/site-packages/neo/rawio/blackrockrawio.py:394, in BlackrockRawIO._parse_header(self)
    392 else:
    393     _data_reader_fun = self.__nsx_data_reader[spec]
--> 394 self.nsx_datas[nsx_nb] = _data_reader_fun(nsx_nb)
    396 sr = float(self.main_sampling_rate / self.__nsx_basic_header[nsx_nb]["period"])
    397 self.sig_sampling_rates[nsx_nb] = sr

File ~/anaconda3/envs/env_nelson/lib/python3.13/site-packages/neo/rawio/blackrockrawio.py:1061, in BlackrockRawIO.__read_nsx_data_variant_a(self, nsx_nb)
   1058 filename = ".".join([self._filenames["nsx"], f"ns{nsx_nb}"])
   1060 # get shape of data
-> 1061 shape = (self.__nsx_params["2.1"](nsx_nb)["nb_data_points"], self.__nsx_basic_header[nsx_nb]["channel_count"])
   1062 offset = self.__nsx_params["2.1"](nsx_nb)["bytes_in_headers"]
   1064 # read nsx data
   1065 # store as dict for compatibility with higher file specs

File ~/anaconda3/envs/env_nelson/lib/python3.13/site-packages/neo/rawio/blackrockrawio.py:2010, in BlackrockRawIO.__get_nsx_param_variant_a(self, nsx_nb)
   2005 else:
   2006     units = "uV"
   2008 nsx_parameters = {
   2009     "nb_data_points": int(
-> 2010         (self.__get_file_size(filename) - bytes_in_headers)
   2011         / (2 * self.__nsx_basic_header[nsx_nb]["channel_count"])
   2012         - 1
   2013     ),
   2014     "labels": labels,
   2015     "units": np.array([units] * self.__nsx_basic_header[nsx_nb]["channel_count"]),
   2016     "min_analog_val": -1 * np.array(dig_factor, dtype="float"),
   2017     "max_analog_val": np.array(dig_factor, dtype="float"),
   2018     "min_digital_val": np.array([-1000] * self.__nsx_basic_header[nsx_nb]["channel_count"]),
   2019     "max_digital_val": np.array([1000] * self.__nsx_basic_header[nsx_nb]["channel_count"]),
   2020     "timestamp_resolution": 30000,
   2021     "bytes_in_headers": bytes_in_headers,
   2022     "sampling_rate": 30000 / self.__nsx_basic_header[nsx_nb]["period"] * pq.Hz,
   2023     "time_unit": pq.CompoundUnit(f"1.0/{30000 / self.__nsx_basic_header[nsx_nb]['period']}*s"),
   2024 }
   2026 # Returns complete dictionary because then it does not need to be called so often
   2027 return nsx_parameters

OverflowError: Python integer 45999298976 out of bounds for uint32

Environment:

  • OS: Linux
  • Python 3.13.2
  • Neo 0.15.0.dev0 (master branch)
  • NumPy 2.2.4
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions