|
24 | 24 | from ..utils.check import (_check_fname, _check_option, _import_h5io_funcs,
|
25 | 25 | _is_numeric, check_fname)
|
26 | 26 | from ..utils.misc import _pl
|
| 27 | +from ..utils.spectrum import _split_psd_kwargs |
27 | 28 | from ..viz.topo import _plot_timeseries, _plot_timeseries_unified, _plot_topo
|
28 | 29 | from ..viz.topomap import (_make_head_outlines, _prepare_topomap_plot,
|
29 | 30 | plot_psds_topomap)
|
@@ -92,29 +93,8 @@ def plot_psd(self, fmin=0, fmax=np.inf, tmin=None, tmax=None, picks=None,
|
92 | 93 | -----
|
93 | 94 | %(notes_plot_psd_meth)s
|
94 | 95 | """
|
95 |
| - from ..io import BaseRaw |
96 |
| - |
97 |
| - # triage reject_by_annotation |
98 |
| - rba = dict() |
99 |
| - if isinstance(self, BaseRaw): |
100 |
| - rba = dict(reject_by_annotation=reject_by_annotation) |
101 |
| - |
102 |
| - spectrum = self.compute_psd( |
103 |
| - method=method, fmin=fmin, fmax=fmax, tmin=tmin, tmax=tmax, |
104 |
| - picks=picks, proj=proj, n_jobs=n_jobs, verbose=verbose, **rba, |
105 |
| - **method_kw) |
106 |
| - |
107 |
| - # translate kwargs |
108 |
| - amplitude = 'auto' if estimate == 'auto' else (estimate == 'amplitude') |
109 |
| - ci = 'sd' if area_mode == 'std' else area_mode |
110 |
| - # ↓ here picks="all" because we've already restricted the `info` to |
111 |
| - # ↓ have only `picks` channels |
112 |
| - fig = spectrum.plot( |
113 |
| - picks='all', average=average, dB=dB, amplitude=amplitude, |
114 |
| - xscale=xscale, ci=ci, ci_alpha=area_alpha, color=color, |
115 |
| - alpha=line_alpha, spatial_colors=spatial_colors, sphere=sphere, |
116 |
| - exclude=exclude, axes=ax, show=show) |
117 |
| - return fig |
| 96 | + init_kw, plot_kw = _split_psd_kwargs(plot_fun=Spectrum.plot) |
| 97 | + return self.compute_psd(**init_kw).plot(**plot_kw) |
118 | 98 |
|
119 | 99 | @legacy(alt='.compute_psd().plot_topo()')
|
120 | 100 | @verbose
|
@@ -148,13 +128,8 @@ def plot_psd_topo(self, tmin=None, tmax=None, fmin=0, fmax=100, proj=False,
|
148 | 128 | fig : instance of matplotlib.figure.Figure
|
149 | 129 | Figure distributing one image per channel across sensor topography.
|
150 | 130 | """
|
151 |
| - spectrum = self.compute_psd( |
152 |
| - method=method, fmin=fmin, fmax=fmax, tmin=tmin, tmax=tmax, |
153 |
| - proj=proj, n_jobs=n_jobs, verbose=verbose, **method_kw) |
154 |
| - |
155 |
| - return spectrum.plot_topo( |
156 |
| - dB=dB, layout=layout, color=color, fig_facecolor=fig_facecolor, |
157 |
| - axis_facecolor=axis_facecolor, axes=axes, block=block, show=show) |
| 131 | + init_kw, plot_kw = _split_psd_kwargs(plot_fun=Spectrum.plot_topo) |
| 132 | + return self.compute_psd(**init_kw).plot_topo(**plot_kw) |
158 | 133 |
|
159 | 134 | @legacy(alt='.compute_psd().plot_topomap()')
|
160 | 135 | @verbose
|
@@ -212,19 +187,8 @@ def plot_psd_topomap(self, bands=None, tmin=None, tmax=None, ch_type=None,
|
212 | 187 | fig : instance of Figure
|
213 | 188 | Figure showing one scalp topography per frequency band.
|
214 | 189 | """
|
215 |
| - spectrum = self.compute_psd( |
216 |
| - method=method, tmin=tmin, tmax=tmax, proj=proj, |
217 |
| - n_jobs=n_jobs, verbose=verbose, **method_kw) |
218 |
| - |
219 |
| - fig = spectrum.plot_topomap( |
220 |
| - bands=bands, ch_type=ch_type, normalize=normalize, agg_fun=agg_fun, |
221 |
| - dB=dB, sensors=sensors, show_names=show_names, mask=mask, |
222 |
| - mask_params=mask_params, contours=contours, outlines=outlines, |
223 |
| - sphere=sphere, image_interp=image_interp, extrapolate=extrapolate, |
224 |
| - border=border, res=res, size=size, cmap=cmap, vlim=vlim, |
225 |
| - cnorm=cnorm, colorbar=colorbar, cbar_fmt=cbar_fmt, units=units, |
226 |
| - axes=axes, show=show) |
227 |
| - return fig |
| 190 | + init_kw, plot_kw = _split_psd_kwargs(plot_fun=Spectrum.plot_topomap) |
| 191 | + return self.compute_psd(**init_kw).plot_topomap(**plot_kw) |
228 | 192 |
|
229 | 193 | def _set_legacy_nfft_default(self, tmin, tmax, method, method_kw):
|
230 | 194 | """Update method_kw with legacy n_fft default for plot_psd[_topo]().
|
@@ -912,9 +876,8 @@ class Spectrum(BaseSpectrum):
|
912 | 876 | .. footbibliography::
|
913 | 877 | """
|
914 | 878 |
|
915 |
| - def __init__(self, inst, method, fmin, fmax, tmin, tmax, picks, |
916 |
| - proj, reject_by_annotation, *, n_jobs, verbose=None, |
917 |
| - **method_kw): |
| 879 | + def __init__(self, inst, method, fmin, fmax, tmin, tmax, picks, proj, |
| 880 | + reject_by_annotation, *, n_jobs, verbose=None, **method_kw): |
918 | 881 | from ..io import BaseRaw
|
919 | 882 |
|
920 | 883 | # triage reading from file
|
|
0 commit comments