Importing and plotting .XDF file into MNE

  • MNE version: 1.7.0
  • operating system: Windows 11

Is there any other way to import and plot .xdf file that is recorded from the Lab Recorder onto MNE?

Hello,

I have been trying to import a .xdf file containing 180 seconds of EEG data on 2 channels from Lab Recorder for Mock LSL streaming and preprocessing on MNE.
I could load the file using these codes as per the tutorials on MNE:

import pyxdf
import mne
xdf_file_path = "C:/Users/varsh/.spyder-py3/alpha_eyeclosing.xdf"
streams, header = pyxdf.load_xdf(xdf_file_path)
eeg_stream = streams[0]
data = eeg_stream['time_series'].T
eeg_times = eeg_stream['time_stamps']
ch_names = ['Ch1', 'Ch2', 'Ch3', 'Ch4', 'Ch5', 'Ch6', 'Ch7', 'Ch8']
sfreq = 250
info = mne.create_info(ch_names, sfreq=sfreq, ch_types='eeg')
raw = mne.io.RawArray(data, info)
raw.plot()

But I am unable to plot the EEG data for visualization. I am getting only 2 flat lines even though the variable array dimensions are (8, 45480).

Also, I tried the MNE-LAB which has the GUI for MNE and there too I got a blank plot.

Please advice me as to how to proceed further?

Hi @varsha108 ,

This is probably a scaling issue. MNE expects that the EEG amplitude values are reported in Volts, but the EEG data unit in your XDF file might be microvolts, for example.

Can you see the EEG channel traces if you do raw.plot(scalings="auto") ?

You could also try MNELAB, which supports importing XDF:

from mnelab.io import read_raw

raw = read_raw(xdf_file_path, stream_ids=stream_ids)

Note that you need to provide the stream IDs you want to import (it needs to be a list, even if you want to import only a single stream). You can get a list of all stream IDs contained in the file with:

import pyxdf

pyxdf.resolve_streams(xdf_file_path)

Marker streams are automatically imported. If you select more than one non-marker stream, you have to perform resampling by passing fs_new=xxx.

Thank you so much for your response!

I did try raw.plot(scalings="auto"). I still got a flat line like I did for the code I mentioned. no difference.

Should I be changing the scalings value?

I really appreciate your response!

I tried using MNELAB and got the same result, flatlines in two electrodes which have EEG recording. It seems like there is data but Iā€™m unable to visual it as the usual EEG signal.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.