Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: Add "highlight" parameter to Evoked.plot() to conveniently highlight time periods #10614

Merged
merged 4 commits into from
May 8, 2022

Conversation

hoechenberger
Copy link
Member

@hoechenberger hoechenberger commented May 8, 2022

Allows to conveniently produce figures like:

evoked

Becomes really powerful when combined with Evoked.plot_topomap()'s average parameter:

joint

MWE:

# %%
from pathlib import Path
import mne


sample_dir = Path(mne.datasets.sample.data_path())
sample_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis_raw.fif'

raw = mne.io.read_raw_fif(sample_fname)
raw.crop(tmax=60)

events = mne.find_events(raw, stim_channel='STI 014')
event_id = {'auditory/left': 1, 'auditory/right': 2, 'visual/left': 3,
            'visual/right': 4, 'face': 5, 'buttonpress': 32}

epochs = mne.Epochs(raw, events=events, event_id=event_id,
                    tmin=-0.2, tmax=0.5, baseline=(None, 0),
                    preload=True)

evoked = epochs.average()

evoked.plot(
    spatial_colors=True, picks='mag', gfp=True,
    highlight=[(0.05, 0.13), (0.23, 0.3)]
);
evoked.plot_joint(
    times=[0.09],
    topomap_args=dict(average=0.1),
    ts_args=dict(highlight=(0.04, 0.14)),
    picks='mag'
);

@hoechenberger hoechenberger marked this pull request as ready for review May 8, 2022 13:24
@hoechenberger hoechenberger changed the title Add "highlight" parameter to Evoked.plot() to highlight time periods MRG: Add "highlight" parameter to Evoked.plot() to highlight time periods May 8, 2022
mne/viz/evoked.py Outdated Show resolved Hide resolved
@hoechenberger hoechenberger requested a review from agramfort May 8, 2022 13:34
@hoechenberger hoechenberger changed the title MRG: Add "highlight" parameter to Evoked.plot() to highlight time periods MRG: Add "highlight" parameter to Evoked.plot() to conveniently highlight time periods May 8, 2022
@agramfort
Copy link
Member

any idea why it's not taking the full y range?

@hoechenberger
Copy link
Member Author

any idea why it's not taking the full y range?

Nope, it might be that we're doing some axis-range foo somewhere which I've overlooked. Any help on this would be appreciated! But I think even like it is now it's a step forward :)

@hoechenberger

This comment was marked as outdated.

@agramfort
Copy link
Member

agramfort commented May 8, 2022 via email

@hoechenberger
Copy link
Member Author

Amazing!!!!!

@hoechenberger
Copy link
Member Author

@agramfort Please merge if happy

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyone merge if happy.

thx @hoechenberger

@hoechenberger hoechenberger merged commit 9f83365 into mne-tools:main May 8, 2022
@hoechenberger hoechenberger deleted the evoked-highlight branch May 8, 2022 19:46
larsoner added a commit to larsoner/mne-python that referenced this pull request May 9, 2022
* upstream/main:
  MRG: Add "highlight" parameter to Evoked.plot() to conveniently highlight time periods (mne-tools#10614)
  MRG: Allow to pass array of "average" values to plot_evoked_topomap() (mne-tools#10610)
  fix: snirf length units (mne-tools#10613)
  minor, doc: fix subplot titles in tutorial (mne-tools#10607)
  Display averaged time period in Evoked topomap title (mne-tools#10606)
  MAINT: Fix for pydata-sphinx-theme [skip azp][skip actions][circle deploy] (mne-tools#10605)
  DOC: report.add_html in tutorial (mne-tools#10603)
  Broader support of the SNIRF file format and enable reading GowerLab data (mne-tools#10555)
  MRG: Recommend mamba instead of libmamba for installation (mne-tools#10597)
  Fix dev documentation warning [skip azp][skip actions] (mne-tools#10599)
  FIX cmap (mne-tools#10593)
  [ENH, MRG] Add interpolate bridged electrodes function (mne-tools#10587)
larsoner added a commit to HanBnrd/mne-python that referenced this pull request May 17, 2022
* upstream/main: (24 commits)
  Use less memory when loading EDF file (mne-tools#10638)
  BUG: fix ipython console accessibility after MNEQtBrowser in Spyder (mne-tools#10637)
  WIP: Fix mne.time_frequency.multitaper Nyquist adjustment slightly incorrect (mne-tools#10541)
  BUG: Fix bug with fNIRS reordering (mne-tools#10630)
  MNT: PyQt6 for pip pre 3.10 (mne-tools#10636)
  CI: Fix conda (mne-tools#10628)
  MRG: Update installer links to point to 1.0.3_0 (mne-tools#10622)
  [BUG, MRG] fix info write access (mne-tools#10626)
  [MRG] Fixed group_by titles in evoked_plot. (mne-tools#10618)
  [BUG, MRG] Replace image_interp with interpolation in topomap plot arguments (mne-tools#10617)
  MAINT: Fix timeout (mne-tools#10624)
  Simplify mne-tools#10619 (mne-tools#10620)
  Drop EEG rejection thresholds when replacing EEG with CSD channels (mne-tools#10619)
  Add get_montage support for fNIRS (mne-tools#10611)
  ENH: Improve make_head_surface options (mne-tools#10592)
  [ENH, MRG] Add citation for intracranial JOSS paper (mne-tools#10616)
  [ENH] Add sys info for mne-icalabel (mne-tools#10615)
  MRG: Add "highlight" parameter to Evoked.plot() to conveniently highlight time periods (mne-tools#10614)
  MRG: Allow to pass array of "average" values to plot_evoked_topomap() (mne-tools#10610)
  fix: snirf length units (mne-tools#10613)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants