0

I'm following this tutorial: https://mne.tools/dev/auto_tutorials/forward/35_eeg_no_mri.html#sphx-glr-auto-tutorials-forward-35-eeg-no-mri-py

but can't figure out how to plot the dynamic image in a tkinter frame python 3.8

Besides when plotting outside tkinter it changes the resolution and size of fullscreen tkinter window to a smaller size.

I want to plot mne.viz.plot_alignment... in a tkinter frame

Any suggestions are welcome.

import os.path as op
import numpy as np

import mne
from mne.datasets import eegbci
from mne.datasets import fetch_fsaverage

# Download fsaverage files
fs_dir = fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)

# The files live in:
subject = 'fsaverage'
trans = 'fsaverage'  # MNE has a built-in fsaverage transformation
src = op.join(fs_dir, 'bem', 'fsaverage-ico-5-src.fif')
bem = op.join(fs_dir, 'bem', 'fsaverage-5120-5120-5120-bem-sol.fif')

raw_fname, = eegbci.load_data(subject=1, runs=[6])
raw = mne.io.read_raw_edf(raw_fname, preload=True)

# Clean channel names to be able to use a standard 1005 montage
new_names = dict(
    (ch_name,
     ch_name.rstrip('.').upper().replace('Z', 'z').replace('FP', 'Fp'))
    for ch_name in raw.ch_names)
raw.rename_channels(new_names)

# Read and set the EEG electrode locations
montage = mne.channels.make_standard_montage('standard_1005')
raw.set_montage(montage)
raw.set_eeg_reference(projection=True)  # needed for inverse modeling

# Check that the locations of EEG electrodes is correct with respect to MRI
mne.viz.plot_alignment(
    raw.info, src=src, eeg=['original', 'projected'], trans=trans,
    show_axes=True, mri_fiducials=True, dig='fiducials')
TheLizzard
  • 7,248
  • 2
  • 11
  • 31
pkanda
  • 151
  • 3
  • 10
  • Please post a [mre]. I can't see anything to do with `tkinter` in your code. Also if you want to put a gif inside `tkinter` look at [this](https://stackoverflow.com/a/43770948/11106801) – TheLizzard Aug 17 '21 at 14:42
  • Sorry, but this is the example from the link above. For instance, If you past it in jupiter, it will work as it is (if you have mne installed). It works. The problem is to insert the 'plot' in a tkinter frame. mne.viz.plot_alignment( raw.info, src=src, eeg=['original', 'projected'], trans=trans, show_axes=True, mri_fiducials=True, dig='fiducials') I thank you in advance for your patience and understanding – pkanda Aug 17 '21 at 23:22
  • This is the image the code above generates in pycharm: https://drive.google.com/file/d/1-GRtB8MLI1oFVTGjmy4TNVGiuIZHs-ut/view?usp=sharing – pkanda Aug 17 '21 at 23:32

0 Answers0