module 'numpy' has no attribute 'bool'. when trying to use mne.viz.plot_alignment

I followed the adult MRI template however, i get this error when i try to visualize the source space

  • MNE version: 1.0.3
  • operating system: Windows 11

The code snippet


fs_dir = fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)

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ā€)

montage = mne.channels.make_standard_montage(ā€˜standard_1020ā€™)
infoTopo = mne.create_info(ch_names=chNames[:24], sfreq = sfreq_eeg,ch_types=ā€œeegā€).set_montage(montage, match_case=False)

raw = mne.io.RawArray(soiFltrd[i_f][:24], infoTopo)
raw.set_eeg_reference(projection=True)
mne.viz.plot_alignment(raw.info,src=src, eeg=[ā€œoriginalā€, ā€œprojectedā€],trans=trans,show_axes=True,mri_fiducials=True,dig=ā€œfiducialsā€,)


The error message comes when it gets to mne.viz.plot_alignment and the error is

module ā€˜numpyā€™ has no attribute ā€˜boolā€™.
np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
NumPy 1.20.0 Release Notes ā€” NumPy v2.0.dev0 Manual

Please any help will be appreciated.

Thanks

The simple fix is to update MNE-Python; version 1.0.3 is almost 2 years old by now. I checked and we no longer have any cases of np.bool in there.

If you canā€™t update MNE (e.g. working with a frozen environment / trying to reproduce something) then try downgrading to an older numpy (version 1.22.x is probably contemporary with MNE 1.0.3, and probably wonā€™t raise an error yet).

okay, thanks for the answer. I will try either and get back with the result.

Hi Dan, downgrading the numpy to the version you said worked so well. Thanks alot.
But I have another question.