Trying to graph 1 second of a bdf file

Hi, I am new to MNE and trying to graph 1 second of an OpenBCI bdf file
and the file is 28 KB. When I run the code, there is no error message, but
the popup for the graph is just empty, and nothing happens
(even when waiting for 15 minutes).
Would really appreciate any suggestions.

NME version: 1.7.0
Operating system: Windows 10 22H2
IDE: Thonny
Code:
import mne
bdf_raw = mne.io.read_raw_bdf(‘C:\MyEEG\OpenBCI-BDF-2023-28KB.bdf’)
bdf_raw.plot(duration=1, n_channels=1)

1 Like

Can you share the file so I can take a look?

1 Like

Hi Clemens

Thanks, and here is the link:

https://drive.google.com/drive/folders/1nE0itiwgbTk0EuoN6rirRP1KpatLtTBl?usp=sharing

I tried that code with both:

OpenBCI-BDF-2023-28KB.bdf

OpenBCI-BDF-2023-93KB.bdf

I have no problem plotting the data, so there is probably something wrong with your setup. How did you install MNE? Did you use the standalone installer?

2 Likes

Thank you Clemens for checking the bdf file, glad that that is not the issue.
I did use the standalone installer for MNE, and perhaps that is the problem?
Looking at the MNE website, they recommend the MNE-Python installer,
so will give that a try…

Well no luck :frowning:

I uninstalled ThonnyIDE and Python, and then installed Anaconda (which includes Python and Spyder),
and then created a MNE environment:
conda create --channel=conda-forge --strict-channel-priority --name=mne mne
Then opened Spyder and no error message in the console (and updated mne environment as the default)

Then I tried my 1 second bdf code and got an error message. So I went to the
Anaconda Prompt and checked the list of packages in the MNE environment,
and there was mne-base, but no mne. So then went back to the Anaconda Prompt and entered:
conda activate mne conda install -c conda-forge mne
Got a message that some packages would need to be replaced with older versions (including Python), said to continue, and MNE was installed.

But then when I opened Spyder again, there was an error message in the console “python.exe doesn’t have the spyder‑kernels module or the right version of it installed (>= 2.4.0 and < 2.5.0). Without this module is not possible for Spyder to create a console for you.”

So anyway, any solutions you can come up with would be most appreciated !

I think you should try the standalone installer again. I’m pretty sure that you were using a different Python env, because Thonny is not included in the standalone installer.

2 Likes

Thanks Clemens, excellent idea.

So I unistalled Anaconda and python and spyder.
Then installed PyCharm, and reinstalled Python, and MNE.
Then within pyCharm created a MNE environment and
started a new project, and added MNE.

Then I ran that code, but got an error message, so with help of Bing, changed to:

import mne
bdf_file_path = r’C:\MyEEG\OpenBCI-BDF-2023-28KB.bdf’
raw_data = mne.io.read_raw_bdf(bdf_file_path, preload=True)
raw_data.plot(duration=1, n_channels=1)
raw_data.plot()


So this time no error, it said:
Extracting EDF parameters from C:\MyEEG\OpenBCI-BDF-2023-28KB.bdf…
BDF file detected
Setting channel info structure…
Creating raw.info structure…
Reading 0 … 2199 = 0.000 … 10.995 secs…
Using matplotlib as 2D backend.
Channels marked as bad:
none
Channels marked as bad:
none
Process finished with exit code 0


But what is strange is that what looks like a graph
very briefly pops up and then disappears.
So googled and found someone with the same problem,
and with a solution:

python - Unable to scroll through raw data plot in MNE - Stack Overflow

New version:

import mne
import matplotlib.pyplot as plt
bdf_file_path = r’C:\MyEEG\OpenBCI-BDF-2023-28KB.bdf’
raw_data = mne.io.read_raw_bdf(bdf_file_path, preload=True)
raw_data.plot(duration=1, n_channels=1)
plt.show()

And now have a graph! Yay!

And definitely your suggestions very helpful, thank you !

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