Skip to content

Is there any pattern behind when times are in ms or in s? #3164

Closed

Description

@jona-sassenhagen

Try this:

import matplotlib.pyplot as plt

import mne
from mne.datasets import sample

# Load and preprocess data
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
raw = mne.io.read_raw_fif(raw_fname, preload=True).pick_types(
    meg='grad', stim=True, eeg=False).filter(1, None, method='iir')

# Set up events
events = mne.find_events(raw)
event_id = {'Aud/L': 1, 'Aud/R': 2}
tmin, tmax = -.1, .5

# regular epoching
picks = mne.pick_types(raw.info, meg=True)
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, reject=None,
                    baseline=None, preload=True, verbose=False)

epochs["Aud"].average().plot_joint(times=[.1, .15], ts_args={'xlim':(-.1, .4)});

Or rather, DON'T do this, because the last step sometimes just results in a very silly plot, but sometimes (particularly when using %matplotlib inline) takes a very long time to run because it is trying to plot something very weird.

Instead, you must plot as:

epochs["Aud"].average().plot_joint(times=[.1, .15], ts_args={'xlim':(-100, 400)});

This is arguably very counterintuitive.

Is there any chance we can get this sorted out at all, or are we locked into this heterogeneity by legacy?

Activity

  1. jona-sassenhagen commented on Apr 23, 2016

    @jona-sassenhagen
    ContributorAuthor

    To clarify, this is not about plot_joint, which simply passes parameters to evoked.plot and evoked.plot_topomap.

  2. larsoner commented on Apr 24, 2016

    @larsoner
    Member

    I think in all newer code we try to use s and m but in some older legacy places we have ms and/or mm. IMO it would be worth going through a deprecation cycle with time_units='ms' -> 's', it's what we're doing with fit_sphere_to_headshape here.

  3. agramfort commented on Apr 24, 2016

    @agramfort
    SponsorMember
  4. jona-sassenhagen commented on Apr 24, 2016

    @jona-sassenhagen
    ContributorAuthor

    well I think we can live with : 'xlim':(-100, 400)
    it does not say time and the data is plotted in x axis in milliseconds
    that's why

    Definitely not least-surprise though you have to admit.

    IMO it would be worth going through a deprecation cycle with time_units='ms' -> 's'

    Yes! I can go through the code and see how big of a deal it would be.

  5. agramfort commented on Apr 24, 2016

    @agramfort
    SponsorMember
  6. jona-sassenhagen commented on May 11, 2016

    @jona-sassenhagen
    ContributorAuthor

    I just had my browser crash on me because I set xlim in seconds. (In the Notebook, it creates a massive PNG in that case.)

    I will at least try to think of avoiding this situation, e.g. by fixing plot_joint for situations where times is not in xlim or xlim is very short.

  7. larsoner commented on May 11, 2016

    @larsoner
    Member

    Closing as "won't fix" until we convince @agramfort it's worthwhile :)

    But yes if you can think of a good way to warn people at least that would help.

  8. larsoner commented on Apr 2, 2018

    @larsoner
    Member

    This continues to come up from time to time. And from working on #5079 it looks like the only plots that use [ms] are evoked.plot. This is inconsistent even with things that produce evoked.plot-like sensor trace plots. :(

    @agramfort any change of heart about adding time_unit to evoked.plot and evoked.plot_joint? I think it would be a couple dozen lines of code to do it.

    I'd actually be in favor of a deprecation cycle to get to 's'. It would be painful but then everything would be unified.

  9. larsoner commented on Apr 2, 2018

    @larsoner
    Member

    And by "working on XXX" I meant "working on #5079" ... that's what I get for drafting a reply before actually making the PR :)

  10. agramfort commented on Apr 2, 2018

    @agramfort
    SponsorMember
  11. larsoner commented on Apr 2, 2018

    @larsoner
    Member

    Yes, we are 98% there, just evoked.plot to conquer IIRC

  12. added this to the 0.16 milestone on Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions