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

Add MED wrapper #1288

Merged
merged 6 commits into from
Jul 27, 2023
Merged

Add MED wrapper #1288

merged 6 commits into from
Jul 27, 2023

Conversation

dancrepeau
Copy link
Contributor

Hello,

This is the third attempt to add MED format (medformat.org) support into Neo. After the previous pull request, my colleague Matt Stead and I re-worked the code for determining Neo streams, and addressed all the comments from the second pull request. We also verified that multiple MED wrappers can point to the same dataset.

Please let us know if there any questions or comments! Thanks.

Copy link
Member

@JuliaSprenger JuliaSprenger left a comment

Choose a reason for hiding this comment

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

Hi @dancrepeau!
Thanks for reworking the IO a second time. Now the structure and mapping to neo streams looks perfect.
I left a couple of small suggestions, comments and questions.
It also seems that you are only considering a part of record data to be loaded into events if these are of type Note or Nlx - is there potentially more data in those records that could be exposed via Neo?
Currently the tests are still failing due to a segmentation fault. Do you get the same error on your system and do you have any idea what's going wrong there?

neo/io/__init__.py Show resolved Hide resolved
# found a match, so add it!
add_to_existing_stream_info = True
stream_info['chan_list'].append((chan_idx, chan_info['metadata']['channel_name']))
stream_info['raw_chans'].append(chan_info['metadata']['channel_name'])
Copy link
Member

Choose a reason for hiding this comment

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

This is not a big performance improvement, but you could stop iterating here once you found the matching stream

Suggested change
stream_info['raw_chans'].append(chan_info['metadata']['channel_name'])
stream_info['raw_chans'].append(chan_info['metadata']['channel_name'])
break

Copy link
Member

Choose a reason for hiding this comment

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

@dancrepeau Does this make sense to you or would you rather keep the code at it is?

Copy link
Member

Choose a reason for hiding this comment

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

ok, let's put this also on the list of potential improvements for the future.

neo/rawio/medrawio.py Outdated Show resolved Hide resolved
neo/rawio/medrawio.py Outdated Show resolved Hide resolved
neo/rawio/medrawio.py Outdated Show resolved Hide resolved
neo/test/iotest/test_medio.py Outdated Show resolved Hide resolved
neo/test/rawiotest/test_medrawio.py Outdated Show resolved Hide resolved
neo/test/rawiotest/test_medrawio.py Outdated Show resolved Hide resolved
neo/test/rawiotest/test_medrawio.py Outdated Show resolved Hide resolved
neo/test/rawiotest/test_medrawio.py Outdated Show resolved Hide resolved
@JuliaSprenger JuliaSprenger added this to the 0.12.1 milestone May 30, 2023
@dancrepeau
Copy link
Contributor Author

Hi @JuliaSprenger!

As always, thanks for the feedback! I will look into the segfault in the next day or two and try to figure out what is going on. I do most of my testing on Mac (M1 chip) and everything is passing for me. Since this appears to be segfaulting on Ubuntu I will try to reproduce the problem there.

@JuliaSprenger JuliaSprenger self-assigned this Jun 14, 2023
@JuliaSprenger
Copy link
Member

Hi @dancrepeau Any news on the segfault? Do you have access to an ubuntu system to test this or is gh actions sufficient for you to tests this?

@dancrepeau
Copy link
Contributor Author

Hi @JuliaSprenger!

Yes, we tracked down the segfault and fixed it. The newest dhn_med_py version is 1.1.1 which has the fix in it. Thank you for being patient!

I will go through the rest of your comments and update the MED wrapper in the near future.

thanks!

@dancrepeau
Copy link
Contributor Author

Hi @JuliaSprenger,

We fixed the segfault in the dhn_med_py library, and I believe I have made the suggested adjustments to the code. Both RawIO and IO are passing the tests in my local testing. Any comments are welcome. Thanks!

neo/rawio/medrawio.py Outdated Show resolved Hide resolved
neo/rawio/medrawio.py Outdated Show resolved Hide resolved
@samuelgarcia
Copy link
Contributor

Hi @dancrepeau.
thank you for this.
I made a few comments.
I do not understand totally the neuralynx story of the med format. I let Julia having closer eyes on this part.

@JuliaSprenger JuliaSprenger modified the milestones: 0.12.1, 0.13.0 Jul 19, 2023
@apdavison
Copy link
Member

@dancrepeau Is this ready to merge, or are there still comments you plan to address?

@dancrepeau
Copy link
Contributor Author

Hi @apdavison, as far as I know, it is ready to be merged. Julia had a question about why MED is using the subset of events that we do (which I think I addressed) and suggested a speed-up for counting the number of events, although the only way I can think to perform that speedup in the parse_header routine would involve duplicating data that is already part of the MedSession python object.

So it's your call - I'm happy with it, and if everyone else is, I'd say let's merge. Thanks!

@JuliaSprenger JuliaSprenger merged commit 071efb1 into NeuralEnsemble:master Jul 27, 2023
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants