diff --git a/doc/changes/devel/12828.bugfix.rst b/doc/changes/devel/12828.bugfix.rst new file mode 100644 index 00000000000..707385ac698 --- /dev/null +++ b/doc/changes/devel/12828.bugfix.rst @@ -0,0 +1 @@ +Fixed behavior of :func:`mne.viz.plot_source_estimates` where the ``title`` was not displayed properly, by :newcontrib:`Shristi Baral`. diff --git a/doc/changes/names.inc b/doc/changes/names.inc index 8dba79bcccf..cc56773d592 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -271,6 +271,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 diff --git a/mne/source_estimate.py b/mne/source_estimate.py index 64c2d588f57..2bf9cfe1214 100644 --- a/mne/source_estimate.py +++ b/mne/source_estimate.py @@ -764,6 +764,7 @@ def plot( transparent=True, alpha=1.0, time_viewer="auto", + *, subjects_dir=None, figure=None, views="auto", @@ -2256,6 +2257,7 @@ def plot( vector_alpha=1.0, scale_factor=None, time_viewer="auto", + *, subjects_dir=None, figure=None, views="lateral", @@ -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, @@ -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, @@ -2767,6 +2771,7 @@ def plot_3d( vector_alpha=1.0, scale_factor=None, time_viewer="auto", + *, subjects_dir=None, figure=None, views="axial", @@ -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, @@ -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, diff --git a/mne/utils/docs.py b/mne/utils/docs.py index 3e59d751d93..465321c2150 100644 --- a/mne/utils/docs.py +++ b/mne/utils/docs.py @@ -4631,6 +4631,13 @@ 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 and the subject name. If None, only 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 diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py index 7dbabfa1ef6..08baec20085 100644 --- a/mne/viz/_3d.py +++ b/mne/viz/_3d.py @@ -2321,6 +2321,7 @@ def plot_source_estimates( transparent=True, alpha=1.0, time_viewer="auto", + *, subjects_dir=None, figure=None, views="auto", @@ -2430,8 +2431,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 @@ -2510,6 +2510,7 @@ def plot_source_estimates( view_layout=view_layout, add_data_kwargs=add_data_kwargs, brain_kwargs=brain_kwargs, + title=title, **kwargs, ) @@ -2545,6 +2546,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 @@ -2587,7 +2589,12 @@ 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]}" + if not title: + title = sub_info + else: + title = f"{title}, {sub_info}" + kwargs = { "subject": subject, "hemi": hemi, @@ -3220,6 +3227,7 @@ def plot_vector_source_estimates( vector_alpha=1.0, scale_factor=None, time_viewer="auto", + *, subjects_dir=None, figure=None, views="lateral", @@ -3231,6 +3239,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, @@ -3308,6 +3317,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 @@ -3354,6 +3366,7 @@ def plot_vector_source_estimates( cortex=cortex, foreground=foreground, size=size, + title=title, scale_factor=scale_factor, show_traces=show_traces, src=src,