Iām using MNE .22 with Python 3.9.2 on a Mac running OS 10.15.4. I switched from Matlab to Python a couple years ago and have been using Idle as my IDE up to now, but have to decided to transition to PyCharm. Iāve discovered something peculiar when creating a plot of my raw data:
import mne as mn
import matplotlib.pyplot as plt
plt.switch_backend('TkAgg')
plt.ion()
raw = mn.io.read_raw_edf("my_file.edf", preload=True)
raw.plot()
It couldnāt be any simpler. This works fine when I run it from the shell in Idle and Iām able to scroll through my data. In PyCharm, I get the data plot, but it closes immediately. No chance to scroll, remove bad channels, or annotate.
is the listed interpreter, although I understand little about venv and virtual environments.
I should mention that many plot tools Iāve created using Matplotlib, which utilize MNE for loading data, extracting raw.info, etc. work fine. when I run them from PyCharm.
I apologize if this question isnāt really appropriate for this forum. Also, if any MNE users have a preferred IDE, Iād enjoy hearing suggestions.
The Python interpreter closes immediately after opening the plot window, because the end of your script is reached. You have two ways to work around this:
Ensure execution is halted after plotting by passing block=True, i.e. raw.plot(block=True)
Or edit your PyCharm run configuration such that your script is run in interactive mode (which might be something you want when working with data interactively anyway!) by ticking the āRun with Python Consoleā box. See Create and edit run/debug configurationsāPyCharm for more info on run configurations in PyCharm
Personally I started out on Spyder, then switched to Atom after a couple years, and a couple years later switched to VSCode. Several other MNE-Python devs also use VSCode, some use PyCharm, at least one was using emacs (as of 2019 at least). A lot of the folks in my research institute (MNE-Python users, not devs) prefer Spyder (which is much better nowadays than it was when I stopped using it).