Skip to content

BlackrockRawIO: load_nev=False drops the scaling of spec 2.1 recordings #1942

Open

Description

@h-mayorquin

With load_nev=False, spec 2.1 recordings come back unscaled and every spec loses its recording date:

from neo.rawio.blackrockrawio import BlackrockRawIO

for load_nev in (True, False):
    reader = BlackrockRawIO(filename="blackrock/blackrock_2_1/l101210-001", nsx_to_load=2, load_nev=load_nev)
    reader.parse_header()
    channels = reader.header["signal_channels"]
    print(load_nev, set(channels["units"]), set(channels["gain"]), reader.raw_annotations["blocks"][0]["rec_datetime"])
True {np.str_('uV')} {np.float64(152.592547)} 2010-12-10 10:50:10.156000
False {np.str_('')} {np.float64(1.0)} None

load_nev=False marks the .nev as absent, but a 2.1 .nsX takes its scaling from the .nev headers and rec_datetime comes from there for every spec:

if not load_nev:
self._avail_files["nev"] = False

if self._avail_files["nev"]:
# Workaround for DigitalFactor overflow in buggy Cerebus systems
# Fix from NPMK toolbox (openNEV, line 464, git rev d0a25eac902704a3a29fa5dfd3aed0744f4733ed)
dig_factor = self._nev_params("digitization_factor")[elid]
if dig_factor == 21516:
dig_factor = 152592.547
units = "uV"
else:
dig_factor = float("nan")
units = ""
if i == 0: # Only warn once
warnings.warn("Cannot rescale to voltage, raw data will be returned.", UserWarning)

SpikeInterface always passes load_nev=False and every 2.1 recording read through it has this problem:
https://github.com/SpikeInterface/spikeinterface/blob/0c287eb8193ce963426e13b280976880dc64d97d/src/spikeinterface/extractors/neoextractors/blackrock.py#L47

The fix is to read the .nev headers whenever the file is on disk and keep only the spikes and events behind load_nev.

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions