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

Get annotations from TRC file

Open RojanAsl opened this issue 1 year ago • 2 comments

Proposed documentation enhancement

Hi,

I am working with Micromed data, in which I only have access to TRC and video files. Is there a way I can extract the annotations along with their timestamps from the TRC file?

Thanks in advance!

RojanAsl avatar Feb 20 '24 19:02 RojanAsl

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

welcome[bot] avatar Feb 20 '24 19:02 welcome[bot]

Hello, this is related to https://github.com/mne-tools/mne-python/issues/10524 At the moment, I don't believe MNE offers a TRC (micromed) reader. You can look into neo (https://pypi.org/project/neo/) to read this file format and then you can create MNE's datastructure from the loaded file.

I did so a couple of days ago, this is the code snippet I ended up with:

import numpy as np
from mne import create_info
from mne.io import RawArray
from neo.io import MicromedIO


fname = r"/home/scheltie/Downloads/micromed_data.TRC"
reader = MicromedIO(fname)
data = reader.read()[0].segments[0].analogsignals[0]  # (n_samples, n_channels), 31 chs
sfreq = reader.get_signal_sampling_rate()
ch_names = [elt[0] for elt in reader.header["signal_channels"]]
info = create_info(ch_names, sfreq, "eeg")
raw = RawArray(np.array(data.T), info)

mscheltienne avatar Feb 27 '24 09:02 mscheltienne