Skip to content

Commit 176f64f

Browse files
shristibaralshristibaral2larsonerdrammock
authored
BUG: viz plot window's 'title' argument showed no effect. (#12828)
Co-authored-by: shristi <shristi.baral@aalto.fi> Co-authored-by: Eric Larson <larson.eric.d@gmail.com> Co-authored-by: Daniel McCloy <dan@mccloy.info>
1 parent dedb392 commit 176f64f

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

doc/changes/devel/12828.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed behavior of :func:`mne.viz.plot_source_estimates` where the ``title`` was not displayed properly, by :newcontrib:`Shristi Baral`.

doc/changes/names.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
.. _Senwen Deng: https://snwn.de
274274
.. _Seyed Yahya Shirazi: https://neuromechanist.github.io
275275
.. _Sheraz Khan: https://github.com/SherazKhan
276+
.. _Shristi Baral: https://github.com/shristibaral
276277
.. _Silvia Cotroneo: https://github.com/sfc-neuro
277278
.. _Simeon Wong: https://github.com/dtxe
278279
.. _Simon Kern: https://skjerns.de

mne/source_estimate.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ def plot(
764764
transparent=True,
765765
alpha=1.0,
766766
time_viewer="auto",
767+
*,
767768
subjects_dir=None,
768769
figure=None,
769770
views="auto",
@@ -2256,6 +2257,7 @@ def plot(
22562257
vector_alpha=1.0,
22572258
scale_factor=None,
22582259
time_viewer="auto",
2260+
*,
22592261
subjects_dir=None,
22602262
figure=None,
22612263
views="lateral",
@@ -2267,6 +2269,7 @@ def plot(
22672269
foreground=None,
22682270
initial_time=None,
22692271
time_unit="s",
2272+
title=None,
22702273
show_traces="auto",
22712274
src=None,
22722275
volume_options=1.0,
@@ -2299,6 +2302,7 @@ def plot(
22992302
foreground=foreground,
23002303
initial_time=initial_time,
23012304
time_unit=time_unit,
2305+
title=title,
23022306
show_traces=show_traces,
23032307
src=src,
23042308
volume_options=volume_options,
@@ -2767,6 +2771,7 @@ def plot_3d(
27672771
vector_alpha=1.0,
27682772
scale_factor=None,
27692773
time_viewer="auto",
2774+
*,
27702775
subjects_dir=None,
27712776
figure=None,
27722777
views="axial",
@@ -2778,6 +2783,7 @@ def plot_3d(
27782783
foreground=None,
27792784
initial_time=None,
27802785
time_unit="s",
2786+
title=None,
27812787
show_traces="auto",
27822788
src=None,
27832789
volume_options=1.0,
@@ -2810,6 +2816,7 @@ def plot_3d(
28102816
foreground=foreground,
28112817
initial_time=initial_time,
28122818
time_unit=time_unit,
2819+
title=title,
28132820
show_traces=show_traces,
28142821
src=src,
28152822
volume_options=volume_options,

mne/utils/docs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4656,6 +4656,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75):
46564656
The title of the generated figure. If ``None`` (default), no title is
46574657
displayed.
46584658
"""
4659+
4660+
docdict["title_stc"] = """
4661+
title : str | None
4662+
Title for the figure window. If ``None``, the subject name will be used.
4663+
"""
4664+
46594665
docdict["title_tfr_plot"] = """
46604666
title : str | 'auto' | None
46614667
Title for the plot. If ``"auto"``, will use the channel name (if ``combine`` is

mne/viz/_3d.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,7 @@ def plot_source_estimates(
23542354
transparent=True,
23552355
alpha=1.0,
23562356
time_viewer="auto",
2357+
*,
23572358
subjects_dir=None,
23582359
figure=None,
23592360
views="auto",
@@ -2463,8 +2464,7 @@ def plot_source_estimates(
24632464
Defaults to 'oct6'.
24642465
24652466
.. versionadded:: 0.15.0
2466-
title : str | None
2467-
Title for the figure. If None, the subject name will be used.
2467+
%(title_stc)s
24682468
24692469
.. versionadded:: 0.17.0
24702470
%(show_traces)s
@@ -2543,6 +2543,7 @@ def plot_source_estimates(
25432543
view_layout=view_layout,
25442544
add_data_kwargs=add_data_kwargs,
25452545
brain_kwargs=brain_kwargs,
2546+
title=title,
25462547
**kwargs,
25472548
)
25482549

@@ -2578,6 +2579,7 @@ def _plot_stc(
25782579
view_layout,
25792580
add_data_kwargs,
25802581
brain_kwargs,
2582+
title,
25812583
):
25822584
from ..source_estimate import _BaseVolSourceEstimate
25832585
from .backends.renderer import _get_3d_backend, get_brain_class
@@ -2620,7 +2622,9 @@ def _plot_stc(
26202622
if overlay_alpha == 0:
26212623
smoothing_steps = 1 # Disable smoothing to save time.
26222624

2623-
title = subject if len(hemis) > 1 else f"{subject} - {hemis[0]}"
2625+
sub_info = subject if len(hemis) > 1 else f"{subject} - {hemis[0]}"
2626+
title = title if title is not None else sub_info
2627+
26242628
kwargs = {
26252629
"subject": subject,
26262630
"hemi": hemi,
@@ -3251,6 +3255,7 @@ def plot_vector_source_estimates(
32513255
vector_alpha=1.0,
32523256
scale_factor=None,
32533257
time_viewer="auto",
3258+
*,
32543259
subjects_dir=None,
32553260
figure=None,
32563261
views="lateral",
@@ -3262,6 +3267,7 @@ def plot_vector_source_estimates(
32623267
foreground=None,
32633268
initial_time=None,
32643269
time_unit="s",
3270+
title=None,
32653271
show_traces="auto",
32663272
src=None,
32673273
volume_options=1.0,
@@ -3339,6 +3345,9 @@ def plot_vector_source_estimates(
33393345
time_unit : 's' | 'ms'
33403346
Whether time is represented in seconds ("s", default) or
33413347
milliseconds ("ms").
3348+
%(title_stc)s
3349+
3350+
.. versionadded:: 1.9
33423351
%(show_traces)s
33433352
%(src_volume_options)s
33443353
%(view_layout)s
@@ -3385,6 +3394,7 @@ def plot_vector_source_estimates(
33853394
cortex=cortex,
33863395
foreground=foreground,
33873396
size=size,
3397+
title=title,
33883398
scale_factor=scale_factor,
33893399
show_traces=show_traces,
33903400
src=src,

0 commit comments

Comments
 (0)