Skip to content

Intan "one-file-per-channel-map" does not map channel to file names correctly #1599

Closed

Description

@h-mayorquin

The following should work but says False:

from neo.rawio import IntanRawIO
from pathlib import Path

neo_test_dir = Path("/home/heberto/neuroconv_testing_data/ephy_testing_data")

folder_path = neo_test_dir  / "intan" / "intan_fpc_test_231117_052630"
assert folder_path.is_dir()
filename = folder_path / "info.rhd"

reader = IntanRawIO(filename=filename)
reader.parse_header()
data_from_neo = reader.get_analogsignal_chunk(channel_ids=["A-001"], stream_index=0).squeeze()

file_path = folder_path / "amp-A-000.dat"
assert file_path.is_file()
data_raw = np.fromfile(file_path, dtype=np.int16).squeeze()

np.allclose(data_raw, data_from_neo)

The problem is here:

# for one-file-per-channel we have one memory map / channel stored as a list / neo stream
elif self.file_format == "one-file-per-channel":
self._raw_data = {}
for stream_index, (stream_index_key, stream_datatype) in enumerate(memmap_data_dtype.items()):
self._raw_data[stream_index] = []
num_channels = channel_number_dict[stream_index_key]
for channel_index in range(num_channels):
file_path = raw_file_paths_dict[stream_index_key][channel_index]
channel_memmap = np.memmap(file_path, dtype=stream_datatype, mode="r")
self._raw_data[stream_index].append(channel_memmap)

Where the files are mapped to memmaps, the order does not match the order of the header. See here on my debugger:

image

An easy solution in this case is to order the file_paths but I think this speaks that the current solution of relying on an implicit matching index is brittle. I will push a fix soon

Activity

  1. added this to the 0.14.0 milestone on Dec 13, 2024
  2. modified the milestones: 0.14.0, 0.14.1 on Mar 28, 2025
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions