@@ -2189,6 +2189,7 @@ def _plot_mpl_stc(
21892189 time_viewer = False ,
21902190 colorbar = True ,
21912191 transparent = True ,
2192+ block = False ,
21922193):
21932194 """Plot source estimate using mpl."""
21942195 import matplotlib .pyplot as plt
@@ -2328,7 +2329,7 @@ def _plot_mpl_stc(
23282329 cax .tick_params (labelsize = 16 )
23292330 cb .ax .set_facecolor ("0.5" )
23302331 cax .set (xlim = (scale_pts [0 ], scale_pts [2 ]))
2331- plt_show (True )
2332+ plt_show (True , block = block )
23322333 return fig
23332334
23342335
@@ -2437,6 +2438,7 @@ def plot_source_estimates(
24372438 view_layout = "vertical" ,
24382439 add_data_kwargs = None ,
24392440 brain_kwargs = None ,
2441+ block = False ,
24402442 verbose = None ,
24412443):
24422444 """Plot SourceEstimate.
@@ -2538,6 +2540,7 @@ def plot_source_estimates(
25382540 %(view_layout)s
25392541 %(add_data_kwargs)s
25402542 %(brain_kwargs)s
2543+ %(block)s
25412544 %(verbose)s
25422545
25432546 Returns
@@ -2557,12 +2560,14 @@ def plot_source_estimates(
25572560 - https://openwetware.org/wiki/Beauchamp:FreeSurfer
25582561 """ # noqa: E501
25592562 from ..source_estimate import _BaseSourceEstimate , _check_stc_src
2563+ from .backends ._utils import _qt_block
25602564 from .backends .renderer import _get_3d_backend , use_3d_backend
25612565
25622566 _check_stc_src (stc , src )
25632567 _validate_type (stc , _BaseSourceEstimate , "stc" , "source estimate" )
25642568 subjects_dir = get_subjects_dir (subjects_dir = subjects_dir , raise_error = True )
25652569 subject = _check_subject (stc .subject , subject )
2570+ _validate_type (block , bool , "block" )
25662571 _check_option ("backend" , backend , ["auto" , "matplotlib" , "pyvistaqt" , "notebook" ])
25672572 plot_mpl = backend == "matplotlib"
25682573 if not plot_mpl :
@@ -2593,10 +2598,10 @@ def plot_source_estimates(
25932598 transparent = transparent ,
25942599 )
25952600 if plot_mpl :
2596- return _plot_mpl_stc (stc , spacing = spacing , ** kwargs )
2601+ return _plot_mpl_stc (stc , spacing = spacing , block = block , ** kwargs )
25972602 else :
25982603 with use_3d_backend (backend ):
2599- return _plot_stc (
2604+ brain = _plot_stc (
26002605 stc ,
26012606 overlay_alpha = alpha ,
26022607 brain_alpha = alpha ,
@@ -2614,6 +2619,9 @@ def plot_source_estimates(
26142619 title = title ,
26152620 ** kwargs ,
26162621 )
2622+ if block and brain ._renderer ._kind == "qt" :
2623+ _qt_block (brain .plotter .app_window )
2624+ return brain
26172625
26182626
26192627def _plot_stc (
0 commit comments