Skip to content

Commit

Permalink
BUG: viz plot window's 'title' argument showed no effect. (#12828)
Browse files Browse the repository at this point in the history
Co-authored-by: shristi <[email protected]>
Co-authored-by: Eric Larson <[email protected]>
Co-authored-by: Daniel McCloy <[email protected]>
  • Loading branch information
4 people authored Jan 10, 2025
1 parent dedb392 commit 176f64f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/changes/devel/12828.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed behavior of :func:`mne.viz.plot_source_estimates` where the ``title`` was not displayed properly, by :newcontrib:`Shristi Baral`.
1 change: 1 addition & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
.. _Senwen Deng: https://snwn.de
.. _Seyed Yahya Shirazi: https://neuromechanist.github.io
.. _Sheraz Khan: https://github.com/SherazKhan
.. _Shristi Baral: https://github.com/shristibaral
.. _Silvia Cotroneo: https://github.com/sfc-neuro
.. _Simeon Wong: https://github.com/dtxe
.. _Simon Kern: https://skjerns.de
Expand Down
7 changes: 7 additions & 0 deletions mne/source_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ def plot(
transparent=True,
alpha=1.0,
time_viewer="auto",
*,
subjects_dir=None,
figure=None,
views="auto",
Expand Down Expand Up @@ -2256,6 +2257,7 @@ def plot(
vector_alpha=1.0,
scale_factor=None,
time_viewer="auto",
*,
subjects_dir=None,
figure=None,
views="lateral",
Expand All @@ -2267,6 +2269,7 @@ def plot(
foreground=None,
initial_time=None,
time_unit="s",
title=None,
show_traces="auto",
src=None,
volume_options=1.0,
Expand Down Expand Up @@ -2299,6 +2302,7 @@ def plot(
foreground=foreground,
initial_time=initial_time,
time_unit=time_unit,
title=title,
show_traces=show_traces,
src=src,
volume_options=volume_options,
Expand Down Expand Up @@ -2767,6 +2771,7 @@ def plot_3d(
vector_alpha=1.0,
scale_factor=None,
time_viewer="auto",
*,
subjects_dir=None,
figure=None,
views="axial",
Expand All @@ -2778,6 +2783,7 @@ def plot_3d(
foreground=None,
initial_time=None,
time_unit="s",
title=None,
show_traces="auto",
src=None,
volume_options=1.0,
Expand Down Expand Up @@ -2810,6 +2816,7 @@ def plot_3d(
foreground=foreground,
initial_time=initial_time,
time_unit=time_unit,
title=title,
show_traces=show_traces,
src=src,
volume_options=volume_options,
Expand Down
6 changes: 6 additions & 0 deletions mne/utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4656,6 +4656,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75):
The title of the generated figure. If ``None`` (default), no title is
displayed.
"""

docdict["title_stc"] = """
title : str | None
Title for the figure window. If ``None``, the subject name will be used.
"""

docdict["title_tfr_plot"] = """
title : str | 'auto' | None
Title for the plot. If ``"auto"``, will use the channel name (if ``combine`` is
Expand Down
16 changes: 13 additions & 3 deletions mne/viz/_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2354,6 +2354,7 @@ def plot_source_estimates(
transparent=True,
alpha=1.0,
time_viewer="auto",
*,
subjects_dir=None,
figure=None,
views="auto",
Expand Down Expand Up @@ -2463,8 +2464,7 @@ def plot_source_estimates(
Defaults to 'oct6'.
.. versionadded:: 0.15.0
title : str | None
Title for the figure. If None, the subject name will be used.
%(title_stc)s
.. versionadded:: 0.17.0
%(show_traces)s
Expand Down Expand Up @@ -2543,6 +2543,7 @@ def plot_source_estimates(
view_layout=view_layout,
add_data_kwargs=add_data_kwargs,
brain_kwargs=brain_kwargs,
title=title,
**kwargs,
)

Expand Down Expand Up @@ -2578,6 +2579,7 @@ def _plot_stc(
view_layout,
add_data_kwargs,
brain_kwargs,
title,
):
from ..source_estimate import _BaseVolSourceEstimate
from .backends.renderer import _get_3d_backend, get_brain_class
Expand Down Expand Up @@ -2620,7 +2622,9 @@ def _plot_stc(
if overlay_alpha == 0:
smoothing_steps = 1 # Disable smoothing to save time.

title = subject if len(hemis) > 1 else f"{subject} - {hemis[0]}"
sub_info = subject if len(hemis) > 1 else f"{subject} - {hemis[0]}"
title = title if title is not None else sub_info

kwargs = {
"subject": subject,
"hemi": hemi,
Expand Down Expand Up @@ -3251,6 +3255,7 @@ def plot_vector_source_estimates(
vector_alpha=1.0,
scale_factor=None,
time_viewer="auto",
*,
subjects_dir=None,
figure=None,
views="lateral",
Expand All @@ -3262,6 +3267,7 @@ def plot_vector_source_estimates(
foreground=None,
initial_time=None,
time_unit="s",
title=None,
show_traces="auto",
src=None,
volume_options=1.0,
Expand Down Expand Up @@ -3339,6 +3345,9 @@ def plot_vector_source_estimates(
time_unit : 's' | 'ms'
Whether time is represented in seconds ("s", default) or
milliseconds ("ms").
%(title_stc)s
.. versionadded:: 1.9
%(show_traces)s
%(src_volume_options)s
%(view_layout)s
Expand Down Expand Up @@ -3385,6 +3394,7 @@ def plot_vector_source_estimates(
cortex=cortex,
foreground=foreground,
size=size,
title=title,
scale_factor=scale_factor,
show_traces=show_traces,
src=src,
Expand Down

0 comments on commit 176f64f

Please sign in to comment.