Head outline did not show when using plot_sensor

  • MNE version: 1.7.0
  • operating system: Windows 10

Both plot_sensors and ica.plot_components work in my code.

However, when i tired set_montage to my own data(Dreamer dataset). It only showed the points of electrode but not outline of head.

Another question is there anyway to change the color of head outline in ica.plot_components?

Below is my fail code. If need more information please let me know. Thank you!

import scipy
import tensorflow
import numpy as np
import matplotlib.pyplot as plt
import mne
sfreq = 128
ch_types = ['eeg', 'eeg', 'eeg', 'eeg' ,'eeg', 'eeg', 'eeg', 'eeg', 'eeg', 'eeg', 'eeg', 'eeg', 'eeg', 'eeg']
ch_names = ['AF3', 'F7', 'F3', 'FC5', 'T7', 'P7', 'O1', 'O2', 'P8', 'T8', 'FC6', 'F4', 'F8', 'AF4']

data_mne = np.transpose(subject_eeg_baseline[0,0][:,:])
biosemi32 = mne.channels.make_standard_montage('biosemi32')

biosemi32.plot(); ### NO HEAD OUTLINE

info_mne = mne.create_info(ch_names=ch_names, sfreq=sfreq, ch_types=ch_types)
info_mne.set_montage(biosemi32)

info_mne.plot_sensors(); ### NO HEAD OUTLINE

raw_mne = mne.io.RawArray(data_mne, info_mne)
raw_mne.plot_sensors(show_names=True, sphere='auto');
notch_mne = raw_mne.notch_filter(50)
bandpass_mne = notch_mne.filter(1, 50)

ica = mne.preprocessing.ICA(max_iter='auto', random_state=97)
ica.fit(bandpass_mne)
ica.plot_components(show_names=True, outlines='head', sphere=(0, 0.025, 0.01, 0.095), colorbar=True); ### COLOR IS WHITE


I can not reproduce. Can you share the output of mne.sys_info() especially to have a look at the matplotlib backend.

Mathieu

1 Like

Hi Mathieu,
Thanks for your feedback.
---------------------------------------------------------------------------------------
Core
├☑ mne 1.7.0 (latest release)
├☑ numpy 1.26.4 (MKL 2023.1-Product with 4 threads)
├☑ scipy 1.13.0
└☑ matplotlib 3.8.4 (backend=QtAgg)
----------------------------------------------------------------------------------------

To let you know, I have tried open a new script and code like below.
This works properly.

import mne
easycap_montage = mne.channels.make_standard_montage("easycap-M1")
print(easycap_montage)
easycap_montage.plot();  # 2D

And this is the new sys_info of script.
--------------------------------------------------------------------------------------------------------------
Core
├☑ mne 1.7.0 (latest release)
├☑ numpy 1.26.4 (MKL 2023.1-Product with 4 threads)
├☑ scipy 1.13.0
└☑ matplotlib 3.8.4 (backend=module://matplotlib_inline.backend_inline)
-------------------------------------------------------------------------------------------------------------

P.S. According to the difference of matplotlib backend, I add %matplolib inline and run the first code again. The matplotlib backend is same as the new script, but still output the figure without head outline.