Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] remove indexing along channel axis in AnalogSignalGap.load() #12357

Merged
merged 6 commits into from
Jan 16, 2024

Conversation

KristijanArmeni
Copy link
Contributor

Reference issue

Fixes #12356.

What does this implement/fix?

Removing indexing along channel dimension with idx in AnalogSignalGap.load() on zero-arrays representing the gap data in self.signal (commit: 1aa66). These arrays are constructed on the fly using the idx variable and hence have the appropriate channel dimension to begin with. In case of a single channel, slicing a 1-dimensional array with slice(1:2) slice yields a 0-dimensional array which breaks the concatenation downstream in l. 359.

@larsoner
Copy link
Member

pip-pre will fail until pyvista/pyvista#5460 lands so you can ignore it

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have a test that would have caught this, something to keep in mind if you ever come across a suitably small dataset @KristijanArmeni !

@KristijanArmeni
Copy link
Contributor Author

Thanks, @larsoner!

Can write a test at this point -- we already have 2 Neuralynx channels that simulate gaps, so I can reproduce this bug on the testing dataset.

The code below fails on current main (but will pass on this branch):

(3 durations < 0.005s hidden.  Use -vv to show these durations.)
===================================== short test summary info ======================================
FAILED mne/io/neuralynx/tests/test_neuralynx.py::test_neuralynx_gaps - Failed: Failed to load data after picking one channel with gaps: all the input array dimensions...
# test that channel selection works
raw = read_raw_neuralynx(
    fname=testing_path,
    preload=False,
    exclude_fname_patterns=ignored_ncs_files,
)

raw.pick("LAHC2")
try:
    raw.load_data()
except Exception as e:
    pytest.fail(f"Failed to load data after picking one channel with gaps: {e}")

@larsoner
Copy link
Member

Can write a test at this point -- we already have 2 Neuralynx channels that simulate gaps, so I can reproduce this bug on the testing dataset.

Great, feel free to push a version of that here then!

@KristijanArmeni
Copy link
Contributor Author

Great, feel free to push a version of that here then!

Ok, added test in edaee01. @larsoner

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking for merge when green, thanks in advance @KristijanArmeni !

@larsoner larsoner enabled auto-merge (squash) January 16, 2024 16:14
@larsoner larsoner merged commit 8583885 into mne-tools:main Jan 16, 2024
29 checks passed
@KristijanArmeni KristijanArmeni deleted the bugfix branch January 16, 2024 17:58
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] read_raw_neuralynx() fails when a single channel is picked prior to loading data with temporal gaps
2 participants