Repository navigation
Description
There was a discussion in #6288 about refactoring plot_epochs_image. Here is the proposed new API (copied with clarifications from #6288):
+--------------------+----------+-------------+----------------------------+
| picks | group_by | combine | result |
+====================+==========+=============+============================+
| | | callable | |
| | +-------------+ |
| | | 'mean' | |
| | +-------------+ |
| | None | 'median' | 1 fig per ch_type |
| | +-------------+ |
| | | 'std' | |
| | +-------------+ |
| None, | | 'gfp', None | |
| ch_type, +----------+-------------+----------------------------+
| list of ch_types | | callable | 1 fig per dict key |
| | +-------------+ |
| | | 'mean' | (dict values index into |
| | +-------------+ orig. sensor indices, not |
| | dict | 'median' | whatever `picks` yields) |
| | +-------------+ |
| | | 'std' | (if one dict value selects |
| | +-------------+ multiple sensor types: |
| | | 'gfp', None | raise ValueError) |
+--------------------+----------+-------------+----------------------------+
| | | callable | |
| | +-------------+ |
| | | 'mean' | 1 fig |
| | +-------------+ |
| | None | 'median' | (stop allowing to combine |
| | +-------------+ across sensor types: |
| | | 'std' | Warning -> ValueError) |
| | +-------------+ |
| | | 'gfp' | |
| int, | +-------------+----------------------------+
| list of int, | | None | 1 fig per pick |
| ch_name, +----------+-------------+----------------------------+
| list of ch_names | | callable | 1 fig per dict key |
| | +-------------+ |
| | | 'mean' | (dict values index into |
| | +-------------+ orig. sensor indices, not |
| | dict | 'median' | whatever `picks` yields) |
| | +-------------+ |
| | | 'std' | (if one dict value selects |
| | +-------------+ multiple sensor types: |
| | | 'gfp', None | raise ValueError) |
+--------------------+----------+-------------+----------------------------+
I think this table summarizes what the behavior should be. It's different from
current behavior only in two cases:
-
when picks is a (list of) channel types, and
group_byandcombineare
bothNone. Currently in that case you get 5 arbitrary channels; as
proposed in table that returns 1 fig per ch_type (GFP). -
when picks is a (list of) ints or ch_names,
group_byisNone, and
combineis notNone, do not combine across sensor types anymore (current
behavior is to emit aRuntimeWarning; change toValueError). This is to
be consistent with the other case (whenpicks=specific_indices_or_names
andgroup_by=dict(...)selects heterogeneous sensor types, which already
throwsValueError).
Given that spec, I think some changes that make sense are:
-
we don't need to accept
group_by='type'anymore because it never gives a
different result fromgroup_by=None -
Three related changes:
- Don't allow non-None for
picksifgroup_byis a dict. Just infer
picksfrom the dict values. - when
group_bydict values are integers, treat them as indexing into
the full list of ch_names (necessary given previous point). - allow
group_bydict values to be channel names, not just integers
(optional, but would be nice)
- Don't allow non-None for
-
whenever
group_byisNone, construct a dict anyway depending on values of
picksandcombine. That should simplify the code path, because we'd
always be plotting from a dict (one figure per dict key).
Activity
agramfort commentedon May 19, 2019
jona-sassenhagen commentedon May 28, 2019
For what other functions should this also apply? Probably
evoked.plot_image, and perhapsplot_compare_evokeds.