Skip to content

Importing a window shorter than the channel count fails with "Cannot determine channel-major orientation" #485

Closed

Description

@suraj-ranganath

pop_biosig("eeglab_tests/unittesting_binary/testfiles/BDF/jo1_3.bdf", blockrange=[3, 4]) raises ValueError: Cannot determine channel-major orientation… from functions/popfunc/_file_io.py:141.

On develop d70be54a, every 1-second window fails ([0,1], [1,2], [3,4], [0.5,1.5]), because each has 256 samples and the file has 257 channels. The window [1,5] loads. EEGLAB pop_biosig loads all of these windows.

Cause: _file_io.mne_raw_to_eeg calls eeg_from_data without nbchan, so the orientation has to be guessed from the array shape. pop_biosig and pop_fileio both use that function. pop_read_erpss and pop_snapread also leave out nbchan.

Fix:

  • Pass nbchan=len(raw.ch_names) in mne_raw_to_eeg.
  • Pass the known channel count in pop_read_erpss and pop_snapread.
  • Add a regression test on jo1_3.bdf with blockrange=[3,4], compared against MATLAB pop_biosig.

Found while verifying #484. The bug was already on develop before that PR.

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