mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.71k stars 1.32k forks source link

ENH: import ANT Neuro .CNT files (some code available) #3609

Closed behinger closed 2 months ago

behinger commented 8 years ago

ANT Neuro has a special fileformat (.cnt and .trg files). I could not find any support to import them in MNE. They do have a c-library libeep which you can compile for python. They were so nice to send me a precompiled 64bit linux version (thus I did not really try to compile myself, but should be straight forward) and I did an early sketch of an importer script for MNE-python. You can find this script here. For me this script seems to work nicely. So far without any preload capacities, but using libeep should be straight forward.

As I don't have much experience in mne-python I did not really know any guides to follow. I adapted a mix between the read_eeglab and the read_cnt functions.

If you do use the libeep-tool be sure to include a link to the source somewhere.

Best, Benedikt

larsoner commented 2 months ago

.info won't have support for it, would be better maybe to have a utility function in mne.io.ant.<something> that allowed you to get extra information that can't safely/properly be stored in raw.info yet.

mh105 commented 2 months ago

@larsoner Does MNE have a built-in format to store impedance values from electrodes? Given that impedances is one of the BIDS-EEG recommended fields for electrodes, I wonder whether there is ongoing effort to create a space for storing such information?

mscheltienne commented 2 months ago

@proloyd Thanks a lot for the interest and addition! For information, the RawANT object and the associated reader function mne.io.read_raw_ant are being added in this PR #12792. MNE 1.8 will be shortly out and will NOT include the reader. Once MNE 1.8 will be out, the version will be bumped to 1.9.devXXXX at which point #12792 will be merged and the development version will be available to use the reader. The reader will be available in the stable version 1.9 in a couple of months. That also gives us time to parse all the metadata you want, to add tests files, and so on :wink:

For the metadata (patient id, date of birth, machine info, channel types, start time etc etc.), my approach would be to extract everything we can in antio.libeep and eventually in parsing functions in antio.parser. Then, we can use those parsing function in MNE as a PR after #12792 to move those informations into appropriate fields of mne.Info.

@proloyd @mh105 For the impedances, in #12792 I parse them in raw.impedances, similarly to what mne.io.read_raw_brainvision does. It don't think it will survive an I/O roundtrip (meaning raw.save("fname.fif") followed by read_raw("fname.fif") will drop the field), but at least you get access to them after reading a .cnt file. As ANT does multiple impedances measurements, raw.impedances contains a list[dict[str, float]]. mne.io.read_raw_brainvision impedance field stores a dict[str, float] with the key as channel name and the float as impedance value, thus I re-used this structure for ANT.

@larsoner Am I missing an I/O roundtrip compatible impedance field?

mh105 commented 2 months ago

@mscheltienne thanks a lot for your great work on this. One quick question, what happened to @agramfort 's initial concern that we want to keep MNE-Python a pure Python source code and don't distribute c libraries along with MNE that would make it OS dependent? Are you using some workaround for this or are you shipping the entire libeep as part of MNE now?

mscheltienne commented 2 months ago

@mh105 The compiled binaries are distributed in antio, at the moment on Pypi and soon on conda-forge. antio becomes an optional dependency of mne required to run mne.io.read_raw_ant.