A bit of a niche use-case, but I am having trouble getting this to work: plot with the 2D browser backend in blocking mode in a child process.
For my use-case, I want to plot ICA sources; with something like that:
from pathlib import Path
import multiprocessing as mp
import mne
directory = Path(mne.datasets.sample.data_path())/'MEG'/'sample'
fname = directory/'sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(fname, preload=True)
raw.apply_proj()
raw.pick_types(eeg=True)
ica = mne.preprocessing.ICA(method='picard')
ica.fit(raw)
def plot(ica, raw):
ica.plot_sources(raw, block=True, show=True)
if __name__ == '__main__':
process = mp.Process(target=plot, args=(ica, raw))
process.start()
input('Press ENTER to kill process..')
process.kill()
I do get in the IPython console:
Using matplotlib as 2D backend.
Figure(1679x995)
But no figureβ¦
Same with a raw.plot()
:
from pathlib import Path
import multiprocessing as mp
import mne
# mne.viz.set_browser_backend('pyqtgraph')
directory = Path(mne.datasets.sample.data_path())/'MEG'/'sample'
fname = directory/'sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(fname, preload=True)
raw.apply_proj()
raw.pick_types(eeg=True)
def plot(raw):
raw.plot(block=True, show=True)
if __name__ == '__main__':
process = mp.Process(target=plot, args=(raw, ))
process.start()
input('Press ENTER to kill process..')
process.kill()
Any idea what is making this difficult?