question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: TFR.plot misc issues

See original GitHub issue

I am experiencing several issues with the .plot method of TFR objects. I suspect that there are several things off, but for now I found this obvious bug:

These are valid inputs for the title parameter:

https://github.com/mne-tools/mne-python/blob/638847ea5539be32919b6ac4dd85ef8c4c3b79aa/mne/time_frequency/tfr.py#L1136-L1139

Yet in the code, we have this logic:

https://github.com/mne-tools/mne-python/blob/638847ea5539be32919b6ac4dd85ef8c4c3b79aa/mne/time_frequency/tfr.py#L1269-L1278

Hence, when I pass title='auto', my figure will have the title auto

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
eortcommented, Mar 16, 2021

oh boy, this is really quite a challenge to unpack 😃

a couple of design question:

The auto value for title, number of picks, and combine are co-dependent

title='auto' is supposed to concatenate channels names for up to 6 picks. This would only make sense when there are multiple picks and those picks are combined into a single figure (with the combine keyword). Otherwise, I don’t see why I would want to have all picks in the title of a figure that only shows one pick. In case multiple picks are combined, I am not sure whether listing the channels is the best representation. At least in viz/utils.py it seems to be to produce a title like RMS/AVG of X electrodes instead of just a list of channel names. Perhaps a combination of the two would be better? (e.g. AVG of Ch1, Ch2, ..., for fewer than 6 picks).

In any case, what mne promises auto will do, is only reasonable for a specific combination of parameters. What would be the best approach to deal with that? Explain it in the doc? Raising exceptions? Silently adjusting the output whenever it does not make sense (i.e. multiple picks, uncombined)?

return separate figures or subplots?

Right now, the function promises to return multiple figures (even though it actually only returns a single figure). Is the idea to have a separate figure for each pick, or would it make sense to collect the tr plots in subplots of a figure and return that one? Or allow for both? If it should be possible to return multiple figures, they probably should be returned as a list of figures.

Tomorrow during the sprint, I’ll try to move further into this rabbit hole. Happy to chat then!

1reaction
bloylcommented, Jul 16, 2020

yes that function is unusable for anything other than plotting a single TFR. If you look at the code the return is inside the loop so it shouldn’t be surprising that it doesn’t work with multiple channels. https://github.com/mne-tools/mne-python/blob/056c273f1bb96bb3229e60874122f830f946746c/mne/time_frequency/tfr.py#L1280-L1284

For what its worth it is relatively easy to write your own wrapper that will do what you need it to. I use something (https://gist.github.com/bloyl/a08a64899f2feffda5271890a5c6a677) based off the plotting in https://mne.tools/stable/auto_examples/time_frequency/plot_time_frequency_erds.html#sphx-glr-auto-examples-time-frequency-plot-time-frequency-erds-py to plot multi channel tfrs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plotting of mne.combine_evoked output based on ...
Here above I have the TFR output from 1 grad and 20 grad, which looks too similar to me. The two tfr_contrast objects...
Read more >
What's new — MNE 1.2.2 documentation
PSD plots will now show non-data channels (e.g., misc ) if those channels are explicitly passed to picks , by Daniel McCloy. Fix...
Read more >
Effect Displays for Linear, Generalized Linear, and Other Models
allEffects identifies all of the high-order terms in a model and returns a list of "eff" or "effpoly" objects (i.e., an object of...
Read more >
ATOMS : Time Frequency Toolbox details - Scilab
This Toolbox was ported from http://tftb.nongnu.org It contains many algorithms implementing various kinds of time-frequency analysis with a special ...
Read more >
iFly GPS™ Release Notes
Fixed bug with clearing altitudes for a flight plan with procedures but only a single altitude for the whole plan. Fixed issue with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found