Skip to content

Adding support for Nicolet .e files - #1750

Open
MureziCapaul wants to merge 132 commits into
NeuralEnsemble:masterfrom
Swiss-Epilepsy-Center:master
Open

MureziCapaul wants to merge 132 commits into
NeuralEnsemble:masterfrom
Swiss-Epilepsy-Center:master

Conversation

@MureziCapaul

Copy link
Copy Markdown

The reader for .e files as mentioned in #1510

MureziCapaul and others added 30 commits August 2, 2024 15:26
This reverts commit d8584b0001985f08ff1dc3db21b5c9fd372ea181, reversing
changes made to ac6aeda64635a2aae50a20b990cbab667d74734f.
@zm711

zm711 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@MureziCapaul, the data is in our data repo. So if you could resolve conflicts and we can run tests again we can move forward with reviewing this.

@MureziCapaul

Copy link
Copy Markdown
Author

@zm711 , thanks for uploading the data. The tests now pass, so you may continue.

Comment thread neo/rawio/nicoletrawio.py Resolved
Comment thread neo/rawio/nicoletrawio.py Resolved
Comment thread neo/rawio/nicoletrawio.py Resolved
Comment thread neo/rawio/nicoletrawio.py Resolved
Comment thread neo/rawio/nicoletrawio.py Resolved
Comment thread neo/io/nicoletio.py Resolved
Comment thread neo/io/nicoletio.py Resolved
Comment thread neo/test/iotest/test_nicoletio.py Resolved

@h-mayorquin h-mayorquin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @MureziCapaul,
Thanks for fixing the two points from the last round (and for keeping this alive for more than a year, we just don't have a lot of human resources as you can see by the sate of the library but I try to keep it alive). I took a second pass and ran the reader against the three files on gin (scalp_eeg.e, multi_segment.e and intracranial_high_rate.e). The tests pass locally for me too. GitHub still shows conflicts with master though.

I added some inline comments and I have some general points:

  • I would remove _get_buffer_descriptions and _get_analogsignal_buffer_description. The reader doesn't enable the buffer API (_has_buffer_description_api stays False) so nothing uses them. And the description is not correct: the data is stored in per-channel sections and not as one (samples, channels) C-order block. I memmapped the description and it does not match get_analogsignal_chunk in any of the three files, and for intracranial_high_rate.e the described shape runs past the end of the file.
  • _get_index_instances catches every exception and returns a placeholder with offset 0. A missing section then gets read from the start of the file and produces garbage silently. I think it is better to throw an error, or to return an empty list and let the caller decide.
  • _get_analogsignal_chunk calls _create_signal_channels on every read. That rebuilds the channel table, reassigns self.signal_streams as a side effect and repeats the timestream warning on every read of segments 1 and 2 of multi_segment.e. Can this be computed once in _parse_header?
  • What is the use case for set_signal_channels? neo assumes the channels are the same across segments, and a public method that rewrites header is easy to misuse. If files with different channels per segment exist, I would prefer to throw an error for now.
  • The timestream packets are matched to segments by position. multi_segment.e has one timestream packet for three segments, so every parse warns No timestream found for segment 1. The packets carry a date. Wouldn't matching by date be more accurate?
  • The dates are built with tzinfo=timezone.utc, but the docstring of _convert_ole_to_datetime says the timezone offset is already integrated. If the stored value is local time, labeling it UTC is wrong. Is it local time?
  • I compared HC_EVENT with the event types in the MATLAB reader. Three of them are missing here: Amplifier Disconnect, Amplifier Reconnect and Recording Paused. And 33 of the entries are not in the MATLAB code, some of them in German (Zaehneputzen, Kratzt, Anfall). How are you getting those?
  • The class docstring should say that the format is closed and that the reader is reverse-engineered from the MATLAB code, so users know what to expect.

Let me know if I am missing something.

MureziCapaul and others added 16 commits November 16, 2026 14:54
Co-authored-by: Heberto Mayorquin <h.mayorquin@gmail.com>
Co-authored-by: Heberto Mayorquin <h.mayorquin@gmail.com>
Co-authored-by: Heberto Mayorquin <h.mayorquin@gmail.com>
…between segments and the use case was changing signal channels between segments
…s and convert them to the correct overall channel id
…id across all segments, and ignore the channels that changed between segments
@MureziCapaul

Copy link
Copy Markdown
Author

Hi @h-mayorquin ,
Thank you very much for your thorough feedback.

I have addressed the inline-comments, sometimes with my own comment as well.

Regarding the general issues:

  1. That makes sense, for now I removed the buffer descriptions.
  2. I changed it to throw an IOError.
  3. and 4. The file format allows for adding and removing channels without creating a new file, only a new segment is created. This results in varying channels per file. Initially, the idea to solve this was to re-calculate self.signal_channels (and streams) for every segment from the timestream-info of the channel, and also expose this functionality for the user with set_signal_channels . But changing channels between segments is a huge headache, as I am not sure which tag corresponds to which channel when channel IDs are changing. Therefore, I changed the behaviour of _parse_header to parse the signal channels of every segment, and then only keep the channels that are present in all segments, and have the same id in all segments. All other channels are not added to self.signal_channels, and cannot be read. I believe this is the best compromise. Let me know if you'd rather have the reader throw an error. Out of a sample of about 1200 clinical EEG-recordings i tested on, 63 result in a warning about incongruent channels.
  4. It appears that a new timestream is sometimes created when a new segment is created, but not always. Impedance measurements create a new segment, but no timestream, while disconneting the amplifier result in a new segment and a new timestream. Likely, a new timestream is created when the channels could have been changed. As per your suggestion, the reader now always takes the most recent timestream using the datetime in self.ts_packets. self.channel_properties is still used as ground truth for channels. Using self.ts_properties as ground truth works as well, however it also reads some automated analysis channels with weird units, which causes issues down the line.
  5. The time is always recorded in local time. _convert_ole_to_datetime returns a timezone-naive datetime object now. I documented this in the docstring of the class
  6. I got all entries in HC_EVENT either from the MATLAB code or by opening the same file with my neo-module and with the commercial viewer software, and looking at events at the same time. Hence the german words. Upon further investigation I found a local database that comes with the viewer software that contains the default annotations and their GUID. Additionaly, we have an internal database that stores custom-defined events used in our centre, mostly german annotations.
    I also found the portion of the file that contains almost all of the annotations and their matching GUID. However, it is at the end of the file, and therefore not available in scalp_eeg.e. The pointer points to 6919718 while the file itself is only 430548 long. So to use this, we would need a file that almost exceeds your 10 MB threshold.
    As an alternative, I can also add all entries of the database containing the default annotations as a simple dictionary. Let me know.
  7. I added this notice to the docstring of the class. According to the developers of the MATLAB code, much if it is based on looking at the file using a hex-editor, combined with knowledge of the recording system. I added to the docstring of the module that the MATLAB-version itself is also reverse-engineered, and not based on official file specs.

I also noticed that the signal_streams were only differentated by sampling rate, but not by unit. Neo splits signal from the same stream but with different units, but I thought it easier to simply assign a seperate stream for every combination of unit and sampling rate.

In summary, there is only the issue of how to handle the events? Do you want a large dictionary, or a large testing file (or 3 in our case)?

I have the code to read the internal event key-value table in a branch, but not commited yet.

@h-mayorquin

Copy link
Copy Markdown
Contributor

Hi @MureziCapaul,
Thanks for all the other changes.

On 7, the test files on gin did not have the event type table (EVENTTYPEINFOGUID), my fault, I only kept what the reader used at the time. I made them again keeping the table and the rest of the sections, and added three more recordings:
https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/pulls/201
So now you can read the event names from the file in the tests. The old files stay where they are for now but they will be removed later, so could you move the tests to the new paths?

On 3 and 4, I need to think a bit more about it. I ran out of time today, but I will come back to you soon.

@MureziCapaul

Copy link
Copy Markdown
Author

Hi @h-mayorquin ,

Thank you for modifying the text file. I pushed the changes regarding the events.
One behaviour I did not elaborate on is that if the Module finds event-GUIDs that cannot be matched to an existing event description, they event description will be that GUID. This is the case for very few events that are likely embedded in our local annotation database.

This branch has not been deployed

No deployments
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.

5 participants