Repository: mne-tools/mne-python

Issue:
OverFlowError when calling : `SourceEstimate.plot(...)`
### Description of the problem

Hello,

I'm trying to use the SourceEstimation.plot to get the 3D brain graph with the red activated areas.

When calling SourceEstimation.plot, i'm facing an Python Exception: `OverflowError: cannot convert float infinity to integer``

I'm sure the problem is from the SourceEstimate.data. Beacause after adding 1e-14 to all elements of this array, the exception is lo longer here.

My SourceEstimate.data matrix is a float64, it does not contains any INF or NAN : 

```py
print("== After editing data")
print("Shape", data_recreate.shape)
print("Min, Max", np.min(data_recreate), np.max(data_recreate))
print("Contains NaN", np.isnan(data_recreate).any())
print("Contains inf", np.isinf(data_recreate).any())
print("All types", set(type(element) for row in data_recreate for element in row))

stc_recreate = mne.SourceEstimate(data=data_recreate, vertices=vertices_recreate, tmin=tmin_recreate, tstep=tstep_recreate, subject=subject_recreate)

initial_time = 0.1
brain = stc_recreate.plot(
    subjects_dir=subjects_dir,
    initial_time=initial_time,
    smoothing_steps=7,
    hemi='both',
```

Output :
```
== After editing data
Shape (7498, 305)
Min, Max 0.0 1.8034394545323202e-10
Contains NaN False
Contains inf False
All types {<class 'numpy.float64'>}
```

I then supposed that this error was caused by the presence of "0" in the data. 
So I tried with a matrix that contains multiple lines with 0, things goes well.

```py
data_recreate = stc_copy.data.copy()
data_recreate += 1e-14   #  Avoir OverflowException

data_recreate[:, 1:10] = 0
data_recreate[0:200:, :] = 0

```

So I suppose this as an issue. Let me know if I'm doing something wrong.

Best



```
File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\source_estimate.py:743, in _BaseSourceEstimate.plot(self, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
    [709](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:709) @copy_function_doc_to_method_doc(plot_source_estimates)
    [710](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:710) def plot(
    [711](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:711)     self,
   (...)
    [741](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:741)     verbose=None,
    [742](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:742) ):
--> [743](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:743)     brain = plot_source_estimates(
    [744](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:744)         self,
    [745](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:745)         subject,
    [746](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:746)         surface=surface,
    [747](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:747)         hemi=hemi,
    [748](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:748)         colormap=colormap,
    [749](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:749)         time_label=time_label,
    [750](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:750)         smoothing_steps=smoothing_steps,
    [751](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:751)         transparent=transparent,
    [752](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:752)         alpha=alpha,
    [753](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:753)         time_viewer=time_viewer,
    [754](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:754)         subjects_dir=subjects_dir,
    [755](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:755)         figure=figure,
    [756](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:756)         views=views,
    [757](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:757)         colorbar=colorbar,
    [758](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:758)         clim=clim,
    [759](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:759)         cortex=cortex,
    [760](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:760)         size=size,
    [761](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:761)         background=background,
    [762](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:762)         foreground=foreground,
    [763](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:763)         initial_time=initial_time,
    [764](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:764)         time_unit=time_unit,
    [765](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:765)         backend=backend,
    [766](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:766)         spacing=spacing,
    [767](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:767)         title=title,
    [768](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:768)         show_traces=show_traces,
...
-> [4189](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4189)     fscale_power = int(np.log10(fmax))
   [4190](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4190)     if fscale_power < 0:
   [4191](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4191)         fscale_power -= 1

OverflowError: cannot convert float infinity to integer

```

### Steps to reproduce

```Python
import numpy as np
from scipy import linalg

import mne
from mne.datasets import sample
from mne.viz import plot_sparse_source_estimates

data_path = sample.data_path()
meg_path = data_path / "MEG" / "sample"
fwd_fname = meg_path / "sample_audvis-meg-eeg-oct-6-fwd.fif"
ave_fname = meg_path / "sample_audvis-ave.fif"
cov_fname = meg_path / "sample_audvis-shrunk-cov.fif"
subjects_dir = data_path / "subjects"
condition = "Left Auditory"

# Read noise covariance matrix
noise_cov = mne.read_cov(cov_fname)
# Handling average file
evoked = mne.read_evokeds(ave_fname, condition=condition, baseline=(None, 0))
evoked.crop(tmin=0.04, tmax=0.18)

evoked = evoked.pick(picks="meg", exclude="bads")
# Handling forward solution
forward = mne.read_forward_solution(fwd_fname)


fname_stc = meg_path / "sample_audvis-meg"

stc_sample = mne.read_source_estimate(fname_stc, subject="sample")


data_recreate = np.load("Matrix_data_cause_stc_plot_error.mat.npy")

vertices_recreate = stc_sample.vertices
tmin_recreate = stc_sample.tmin
tstep_recreate = stc_sample.tstep
subject_recreate = stc_sample.subject

stc_recreate = mne.SourceEstimate(data=data_recreate, vertices=vertices_recreate, tmin=tmin_recreate, tstep=tstep_recreate, subject=subject_recreate)

initial_time = 0.1
brain = stc_recreate.plot(
    subjects_dir=subjects_dir,
    initial_time=initial_time,
    smoothing_steps=7,
    hemi='both',
)
```


### Link to data

[Matrix_data_cause_stc_plot_error.mat.zip](https://github.com/mne-tools/mne-python/files/15241469/Matrix_data_cause_stc_plot_error.mat.zip)


### Expected results

![image](https://github.com/mne-tools/mne-python/assets/35274812/e7ae8c44-a55e-404e-ab7a-4bea95a4ebd0)


### Actual results

---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[17], [line 37](vscode-notebook-cell:?execution_count=17&line=37)
     [34](vscode-notebook-cell:?execution_count=17&line=34) stc_recreate = mne.SourceEstimate(data=data_recreate, vertices=vertices_recreate, tmin=tmin_recreate, tstep=tstep_recreate, subject=subject_recreate)
     [36](vscode-notebook-cell:?execution_count=17&line=36) initial_time = 0.1
---> [37](vscode-notebook-cell:?execution_count=17&line=37) brain = stc_recreate.plot(
     [38](vscode-notebook-cell:?execution_count=17&line=38)     subjects_dir=subjects_dir,
     [39](vscode-notebook-cell:?execution_count=17&line=39)     initial_time=initial_time,
     [40](vscode-notebook-cell:?execution_count=17&line=40)     smoothing_steps=7,
     [41](vscode-notebook-cell:?execution_count=17&line=41)     hemi='both',
     [42](vscode-notebook-cell:?execution_count=17&line=42) )

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\source_estimate.py:793, in _BaseSourceEstimate.plot(self, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
    [759](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:759) @copy_function_doc_to_method_doc(plot_source_estimates)
    [760](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:760) def plot(
    [761](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:761)     self,
   (...)
    [791](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:791)     verbose=None,
    [792](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:792) ):
--> [793](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:793)     brain = plot_source_estimates(
    [794](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:794)         self,
    [795](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:795)         subject,
    [796](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:796)         surface=surface,
    [797](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:797)         hemi=hemi,
    [798](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:798)         colormap=colormap,
    [799](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:799)         time_label=time_label,
    [800](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:800)         smoothing_steps=smoothing_steps,
    [801](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:801)         transparent=transparent,
    [802](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:802)         alpha=alpha,
    [803](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:803)         time_viewer=time_viewer,
    [804](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:804)         subjects_dir=subjects_dir,
    [805](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:805)         figure=figure,
    [806](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:806)         views=views,
    [807](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:807)         colorbar=colorbar,
    [808](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:808)         clim=clim,
    [809](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:809)         cortex=cortex,
    [810](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:810)         size=size,
    [811](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:811)         background=background,
    [812](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:812)         foreground=foreground,
    [813](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:813)         initial_time=initial_time,
    [814](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:814)         time_unit=time_unit,
    [815](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:815)         backend=backend,
    [816](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:816)         spacing=spacing,
    [817](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:817)         title=title,
    [818](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:818)         show_traces=show_traces,
    [819](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:819)         src=src,
    [820](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:820)         volume_options=volume_options,
    [821](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:821)         view_layout=view_layout,
    [822](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:822)         add_data_kwargs=add_data_kwargs,
    [823](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:823)         brain_kwargs=brain_kwargs,
    [824](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:824)         verbose=verbose,
    [825](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:825)     )
    [826](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/source_estimate.py:826)     return brain

File <decorator-gen-187>:12, in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_3d.py:2427, in plot_source_estimates(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, transparent, alpha, time_viewer, subjects_dir, figure, views, colorbar, clim, cortex, size, background, foreground, initial_time, time_unit, backend, spacing, title, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs, verbose)
   [2425](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2425) else:
   [2426](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2426)     with use_3d_backend(backend):
-> [2427](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2427)         return _plot_stc(
   [2428](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2428)             stc,
   [2429](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2429)             overlay_alpha=alpha,
   [2430](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2430)             brain_alpha=alpha,
   [2431](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2431)             vector_alpha=alpha,
   [2432](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2432)             cortex=cortex,
   [2433](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2433)             foreground=foreground,
   [2434](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2434)             size=size,
   [2435](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2435)             scale_factor=None,
   [2436](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2436)             show_traces=show_traces,
   [2437](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2437)             src=src,
   [2438](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2438)             volume_options=volume_options,
   [2439](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2439)             view_layout=view_layout,
   [2440](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2440)             add_data_kwargs=add_data_kwargs,
   [2441](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2441)             brain_kwargs=brain_kwargs,
   [2442](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2442)             **kwargs,
   [2443](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2443)         )

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_3d.py:2597, in _plot_stc(stc, subject, surface, hemi, colormap, time_label, smoothing_steps, subjects_dir, views, clim, figure, initial_time, time_unit, background, time_viewer, colorbar, transparent, brain_alpha, overlay_alpha, vector_alpha, cortex, foreground, size, scale_factor, show_traces, src, volume_options, view_layout, add_data_kwargs, brain_kwargs)
   [2594](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2594) del kwargs
   [2596](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2596) if time_viewer:
-> [2597](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2597)     brain.setup_time_viewer(time_viewer=time_viewer, show_traces=show_traces)
   [2598](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2598) else:
   [2599](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_3d.py:2599)     brain.show()

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_brain\_brain.py:601, in Brain.setup_time_viewer(***failed resolving arguments***)
    [599](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:599) self._configure_shortcuts()
    [600](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:600) self._configure_picking()
--> [601](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:601) self._configure_dock()
    [602](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:602) self._configure_tool_bar()
    [603](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:603) self._configure_menu()

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_brain\_brain.py:1027, in Brain._configure_dock(self)
   [1025](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:1025) self._configure_dock_playback_widget(name="Playback")
   [1026](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:1026) self._configure_dock_orientation_widget(name="Orientation")
-> [1027](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:1027) self._configure_dock_colormap_widget(name="Color Limits")
   [1028](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:1028) self._configure_dock_trace_widget(name="Trace")
   [1030](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:1030) # Smoothing widget

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_brain\_brain.py:867, in Brain._configure_dock_colormap_widget(self, name)
    [866](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:866) def _configure_dock_colormap_widget(self, name):
--> [867](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:867)     fmin, fmax, fscale, fscale_power = _get_range(self)
    [868](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:868)     rng = [fmin * fscale, fmax * fscale]
    [869](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:869)     self._data["fscale"] = fscale

File c:\Users\Ilian\Documents\dev\best-python\.venv\lib\site-packages\mne\viz\_brain\_brain.py:4181, in _get_range(brain)
   [4179](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4179)     fscale_power = 0
   [4180](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4180) else:
-> [4181](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4181)     fscale_power = int(np.log10(fmax))
   [4182](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4182)     if fscale_power < 0:
   [4183](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/lib/site-packages/mne/viz/_brain/_brain.py:4183)         fscale_power -= 1

OverflowError: cannot convert float infinity to integer

### Additional information

Platform             Windows-10-10.0.22621-SP0
Python               3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Executable           [c:\Users\Ilian\Documents\dev\best-python\.venv\Scripts\python.exe](file:///C:/Users/Ilian/Documents/dev/best-python/.venv/Scripts/python.exe)
CPU                  Intel64 Family 6 Model 165 Stepping 2, GenuineIntel (8 cores)
Memory               31.8 GB

Core
├☑ mne               1.7.0 (latest release)
├☑ numpy             1.26.4 (OpenBLAS 0.3.23.dev with 8 threads)
├☑ scipy             1.13.0
└☑ matplotlib        3.8.4 (backend=module://matplotlib_inline.backend_inline)

Numerical (optional)
├☑ sklearn           1.4.2
├☑ nibabel           5.2.1
├☑ nilearn           0.10.4
├☑ pandas            2.2.2
└☐ unavailable       numba, dipy, openmeeg, cupy, h5io, h5py

Visualization (optional)
├☑ pyvista           0.43.5 (OpenGL 4.5.0 NVIDIA 552.12 via NVIDIA GeForce GTX 1650 Ti/PCIe/SSE2)
├☑ pyvistaqt         0.11.0
├☑ vtk               9.3.0
├☑ qtpy              2.4.1 (PyQt6=6.6.1)
└☐ unavailable       ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv


Discussion:
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

Thanks for the report. It appears it's happening because the maximum value of your data is zero (which may indicate a mistake somewhere in your script; is data with no positive values plausible for you?)

The error is happening here:

https://github.com/mne-tools/mne-python/blob/1c5b39ff1d99bbcb2fc0e0071a989b3f3845ff30/mne/viz/_brain/_brain.py#L4153-L4171

@wmvanvliet you wrote this code in your UI event system work (#11891), any chance you have time to take a look?
Ah, the np.log10() call needs protection to prevent no.log10(0) of course. My bad :) PR incoming 

Resolving patch:
diff --git a/mne/viz/_brain/_brain.py b/mne/viz/_brain/_brain.py
--- a/mne/viz/_brain/_brain.py
+++ b/mne/viz/_brain/_brain.py
@@ -869,8 +869,8 @@ def set_orientation(value, orientation_data=orientation_data):
         )
 
     def _configure_dock_colormap_widget(self, name):
-        fmin, fmax, fscale, fscale_power = _get_range(self)
-        rng = [fmin * fscale, fmax * fscale]
+        fmax, fscale, fscale_power = _get_range(self)
+        rng = [0, fmax * fscale]
         self._data["fscale"] = fscale
 
         layout = self._renderer._dock_add_group_box(name)
@@ -4157,16 +4157,15 @@ def _get_range(brain):
     multiplied by the scaling factor and when getting a value, this value
     should be divided by the scaling factor.
     """
-    val = np.abs(np.concatenate(list(brain._current_act_data.values())))
-    fmin, fmax = np.min(val), np.max(val)
+    fmax = brain._data["fmax"]
     if 1e-02 <= fmax <= 1e02:
         fscale_power = 0
     else:
-        fscale_power = int(np.log10(fmax))
+        fscale_power = int(np.log10(max(fmax, np.finfo("float32").min)))
         if fscale_power < 0:
             fscale_power -= 1
     fscale = 10**-fscale_power
-    return fmin, fmax, fscale, fscale_power
+    return fmax, fscale, fscale_power
 
 
 class _FakeIren:


Test patch: