mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Micromed TRC file reader

Open jungju69 opened this issue 3 years ago • 5 comments

Hello, I have several datasets based on micromed eeg files (scalp EEG, SEEG, ERP). Do you think it could be possible to develop file readers for that format (TRC files), quite commonly used ? thank you again for your nice software !

jungju69 avatar Apr 13 '22 17:04 jungju69

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

welcome[bot] avatar Apr 13 '22 17:04 welcome[bot]

see this old discussion https://github.com/mne-tools/mne-python/issues/1605

@jungju69 would you up for writing such a reader?

agramfort avatar Apr 13 '22 19:04 agramfort

I would love to … But my python programming skills are too light. I can convert trc files to edf format and use MNE but I was looking for a more direct approach. Any other suggestion ? best JJ

Le 13 avr. 2022 à 21:31, Alexandre Gramfort @.@.>> a écrit :

see this old discussion #1605https://github.com/mne-tools/mne-python/issues/1605

@jungju69https://github.com/jungju69 would you up for writing such a reader?

— Reply to this email directly, view it on GitHubhttps://github.com/mne-tools/mne-python/issues/10524#issuecomment-1098407271, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYUXF5SBFV4MHHOLM67P57LVE4OI7ANCNFSM5TLNFLLQ. You are receiving this because you were mentioned.Message ID: @.***>

ATTENTION : Ce message a été envoyé par un expéditeur externe, en dehors des Hospices Civils de Lyon. Ne cliquez pas sur les liens ou n’ouvrez pas les pièces jointes… sauf si vous connaissez l’expéditeur et que vous lui faites confiance !

jungju69 avatar Apr 13 '22 20:04 jungju69

Any other suggestion ?

see my gist in the issue I linked to

otherwise find someone to help. Maybe some engineer in your lab?

agramfort avatar Apr 13 '22 21:04 agramfort

or you could find a documentation of micromed's .trc file format and post it here, maybe someone in the future will implement this.

sappelhoff avatar Sep 01 '22 09:09 sappelhoff

see this old discussion #1605

@jungju69 would you up for writing such a reader?

Hello MNE community,

I also work with Micromed files from time to time. I wrote a reader that uses python3 and numpy, it is based on the fieldtrip Micromed reader.

I'm not sure how you can integrate this reader into the MNE infrastructure, I could send you the script if this helps.

Done:

  • I compared the read data with the MATLAB reader and it's running fine.
  • I can plot the individual channels using matplotlib and this is also running fine.
  • I created an MNE Raw Array and this also works

ToDo:

  • The mne.io.RawArray.plot() is not working for some reason. I don't know if I need to define something else when creating the RawArray from scratch.

Daniel-Lachner-Piza avatar Oct 17 '23 00:10 Daniel-Lachner-Piza

I also work with Micromed files from time to time. I wrote a reader that uses python3 and numpy, it is based on the fieldtrip Micromed reader.

Unfortunately as far as I understand it FieldTrip is GPL licensed and you cannot use a GPL implementation (FieldTrip) as a reference when adding an implementation to a BSD package (MNE-Python). You'd have to ask permission from the FieldTrip folks to relicence as BSD.

But if you manage to do that, it does sound like you're close to having a workable solution that we could add!

larsoner avatar Oct 17 '23 01:10 larsoner

My reader is based on the fieldtrip reader in the sense that I used it to know how the data bytes are organized in the TRC files. The reader itself is quite simple and just goes through the file byte by byte sorting the data. I have no experience with Licensing but I would think that it is too simple for there to be any risk of Licensing infringement.

Daniel-Lachner-Piza avatar Oct 17 '23 01:10 Daniel-Lachner-Piza

I have no experience with Licensing but I would think that it is too simple for there to be any risk of Licensing infringement.

Translations of code from one language to another are specifically mentioned in the GPL. https://www.gnu.org/licenses/gpl-faq.html#TranslateCode

@robertoostenveld one of our users has translated the FieldTrip MicroMed file reader code into Python and is proposing to add it to MNE-Python. Requesting permission to re-license as BSD 3-clause.

drammock avatar Oct 17 '23 14:10 drammock

I don't personally hold the copyright over the https://github.com/fieldtrip/fieldtrip/blob/master/fileio/private/read_micromed_trc.m code. It was given to me by researchers in Utrecht (their first names are mentioned in the code, I suspect https://www.umcutrecht.nl/en/research/researchers/van-steensel-mj is the original author - I could not find her on GitHub) and I suspect that they don't care too much how and where it gets reused.

Using the original implementation to learn the file structure and byte order and using that to make a Python implementation would IMHO not constitute a translation. Asking ChatGPT to make a matlab-to-python translation would be. But if your code looks sufficiently dissimilar to that included in FieldTrip, I won't complain.

However, why not use the Neo implementation here? That is in Python and BSD licensed already. Or use that to learn how the file structure is, and then write your own. Nobody will be able to tell it apart from the version that you could have written based on the FieldTrip MATLAB code 😉.

robertoostenveld avatar Oct 20 '23 15:10 robertoostenveld

+1 for using Neo if it has what we want, we are doing something similar for Neuralynx data in #11969 which could be followed as a template

larsoner avatar Oct 20 '23 16:10 larsoner

thanks @robertoostenveld for the info and suggestions.

drammock avatar Oct 20 '23 18:10 drammock

Thank you @robertoostenveld for your suggestion, the micromed reader from Neo (this one) extracts more information from the files than the fieldtrip reader. It was actually helpful for my project to participate in this topic, I can extract the EEG date and time from the micromed files now!

Daniel-Lachner-Piza avatar Oct 24 '23 20:10 Daniel-Lachner-Piza