mne-python
mne-python copied to clipboard
RFC: better API for plot_topomap bands parameter?
plot_psds_topomap
, plot_epochs_psd_topomap
, and epochs.plot_psd_topomap
have a bands
parameter that takes a list of tuples as input. The format is:
Length-2 tuples specify a single frequency and a subplot title (e.g.,
``(6.5, 'presentation rate')``); length-3 tuples specify lower and
upper band edges and a subplot title.
This seems inelegant: input is one or more strings, each associated with 1 or 2 numbers. It is begging to be a dict
. Proposed new API:
If a :class:`dict`, keys will be used as subplot titles and dict values should be
either single frequency values or length-two :class:`tuples<tuple>` indicating
lower and upper band edges.
We could easily, silently support 'lists' or np.array
s as the dict values too; and also treat length-1 dict values as equivalent to passing a single value:
if not hasattr(value, '__len__') or len(value) == 1:
# assume single freq value
elif len(value) == 2:
# lower/upper band edges
else:
raise ValueError()