Skip to content

NsxFile() incorrectly loads data when indexing for less than a full file #6

@tlancaster-blackrock

Description

@tlancaster-blackrock

Issue originally raised by Lukas Kunz:

It seems to me that this function reads the data with flipped dimensions. Hence, the output is not channels x time, but rather time x channels. This is not really problematic when reading all channels at once, because one can then simply transpose the data array to obtain the correct dimensions. However, when reading only one channel (e.g., nsxFileContent = nsxFileObj.getdata(1, 0)), then incorrect data is returned because getdata() internally seems to index the data as if they had the correct dimensions (channels x time), although they do not, as described above (time x channels).

  • identify ns5 file
    microFile = glob.glob(sessions[iSess] + '\Micro*.ns5')
  • read the ns5 file
    nsxFileObj = NsxFile(microFile[0])
    nsxFileContent = nsxFileObj.getdata('all', 0)
    nsxFileObj.close()
  • obtain the raw data in the ns5 file, organized as N-by-M array with
  • N = number of channels and M = number of samples
    microData = nsxFileContent['data'][0].T

The python utilities only load the correct data when loading the entire file at once (which can be a problem when the ns5 file is very large).
Loading only a subset of channels (1, 2, ..., n-1) will lead to incorrect data based on internal incorrect indexing (the data for channel i will represent a mixture of data from various channels and various time points). This cannot be corrected by the user post-hoc.

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