-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: read_raw_eyelink() fails to find and drop status column
#13568
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: read_raw_eyelink() fails to find and drop status column
#13568
Conversation
Fix TypeError when read_raw_eyelink() processes .asc files with multiple recording segments where a segment starts with null data. The error occurred because _drop_status_col assumed all column values were strings, but pandas fills missing columns with None when sample lines have varying column counts. The fix checks for None values and looks for the first non-None value in the column to determine if it's a status column. If all values are None, the column is dropped. Closes mne-tools#13567 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> Signed-off-by: majiayu000 <[email protected]>
mne/io/eyelink/_utils.py
Outdated
| # Handle None values - can occur in files with multiple recording segments | ||
| # where a segment starts with null data. See gh-13567. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has nothing to do with multi-block data but blocks that start with fewer columns than after
mne/io/eyelink/_utils.py
Outdated
| status_cols.append(col) | ||
| continue | ||
| first_val = non_null.iloc[0] | ||
| if first_val[0].isnumeric(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if first_val is a float it is not subscriptable and will cause error
| # Check if there's any non-None value to determine column type | ||
| non_null = samples_df[col].dropna() | ||
| if len(non_null) == 0: | ||
| # All values are None, drop this column | ||
| status_cols.append(col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend using first_valid_index = samples_df[col].first_valid_index() as suggested in my issue comment. first_valid_index will be None when the entire column is empty. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.first_valid_index.html. The logic here seems a bit redundant
|
Hi @majiayu000, thanks for putting together the PR. However, I have some comments on the etiquette and contents of the PR. |
- Update comment to accurately describe the issue as "blocks that start with fewer columns than after" instead of "multiple recording segments" - Add isinstance check before calling isnumeric() to handle float values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Thank for the suggestion. I will close this pr :) |
Summary
This PR fixes #13567
Changes
mne/io/eyelink/_utils.pymne/io/eyelink/tests/test_eyelink.py