Add support for VECTORIZED orientation in BrainVisionRawIO#1797
Conversation
Fixes KAN-43: https://eeglab.atlassian.net/browse/KAN-43 Previously, BrainVisionRawIO only supported MULTIPLEXED data orientation (interleaved channels), causing a NeoReadWriteError when attempting to read files with VECTORIZED orientation (sequential channel data). Changes: - Modified data orientation check to accept both MULTIPLEXED and VECTORIZED - Added custom _get_analogsignal_chunk() method to handle VECTORIZED reading - For VECTORIZED files, reads each channel's data from its sequential location in the binary file - Maintains backward compatibility with MULTIPLEXED files (uses parent class implementation) Testing: - Validated against MNE-Python on real-world VECTORIZED dataset (ds004621) with 127 channels × 740,360 samples - results match exactly (correlation=1.0) - Tested both MULTIPLEXED and VECTORIZED orientations with synthetic data - All existing functionality preserved for MULTIPLEXED files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks @Kkuntal990. We will try to review this soon. I've run the tests now. |
|
Can you open an issue here in neo? I can't see the jira board. |
Done |
|
Thanks a lot for adding the other data layout in brainvision. 2 points:
|
- Replace np.fromfile() with np.memmap for multiprocessing compatibility - Minimize code changes in _get_analogsignal_chunk() - Remove file handle caching logic (memmap handles this) - All tests still pass with identical results
Moved VECTORIZED orientation logic to BaseRawIO as suggested by @samuelgarcia: - Added time_axis parameter to buffer_description (0=MULTIPLEXED, 1=VECTORIZED) - Extended BaseRawIO._get_analogsignal_chunk() to handle time_axis=1 for raw buffers - Removed custom _get_analogsignal_chunk() override from BrainVisionRawIO - Fixed _get_signal_size() to correctly handle raw buffers with time_axis=1 Benefits: - Cleaner, more general solution applicable to other readers - Consistent with existing HDF5 time_axis pattern - Reduced code duplication - All tests pass with identical MNE-Python validation
When time_axis=1, shape should be (channels, time) not (time, channels). This makes raw binary handling consistent with HDF5: - time_axis=0: shape is (time, channels) - MULTIPLEXED - time_axis=1: shape is (channels, time) - VECTORIZED Changes: - BrainVisionRawIO: Set shape as (channels, time) when VECTORIZED - BaseRawIO: Use shape[time_axis] consistently for i_stop default - Removed duplicate time_axis retrieval All tests pass with identical MNE-Python validation.
Latest Updates: Refactored to use time_axis pattern in BaseRawIOThanks @samuelgarcia for the suggestion! I've refactored the implementation to move the logic into BaseRawIO using the Changes Made1. Replaced np.fromfile() with np.memmap()
2. Extended BaseRawIO with time_axis support for raw buffers
3. Simplified BrainVisionRawIO
4. Fixed shape convention consistency
Please review when you can |
|
@samuelgarcia @h-mayorquin if possible could you please review the PR ? Thank you for your time. |
|
Hi @Kkuntal990. |
Hi, could you please review if you get time |
|
Could we merge this branch because it is a blocker for us. Tx |
|
Désolé. J'ai battu mon record de procratstination... |
|
once we fix our testing I'll be doing the next release (early January). Could you let me know if you want to be included in our author list? I would need the name you want to appear and any affiliations that should be included. |
Description
Github Issue
This PR adds support for VECTORIZED data orientation in BrainVisionRawIO, which was previously causing a
NeoReadWriteError.Problem
BrainVision files can store data in two orientations:
Previously, Neo only supported MULTIPLEXED orientation, causing imports to fail on VECTORIZED files such as those in OpenNeuro dataset ds004621.
Solution
_get_analogsignal_chunk()method that:Testing
✅ Validation against MNE-Python: Tested on real-world VECTORIZED dataset (ds004621, 127 channels × 740,360 samples)
✅ Synthetic tests: Created test files in both orientations and verified correct data reading
✅ Backward compatibility: MULTIPLEXED files continue to work as before
Changes
neo/rawio/brainvisionrawio.py:self._data_orientationto track orientation type_get_analogsignal_chunk()for VECTORIZED readingRelated Issue