Skip to content

question: puzzling results in epochs.plot_topo_image #6112

Closed

Description

@drammock

Setup:

import os
import mne
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, preload=True, verbose=False)
events = mne.find_events(raw, stim_channel='STI 014')
epochs = mne.Epochs(raw, events, preload=True)

I expected these two options to yield the same results, but they're very different:

# OPTION 1
epochs.copy().pick_types(meg=False, eeg=True).plot_topo_image()

Figure_1

# OPTION 2
eeg_layout = mne.channels.find_layout(raw.info, ch_type='eeg')                                                            
epochs.plot_topo_image(layout=eeg_layout)

Figure_2

Is the difference here intentional, or a bug?

Activity

  1. larsoner commented on Apr 2, 2019

    @larsoner
    Member

    Looks like a scaling / vmiv / vmax problem in the first example

  2. drammock commented on Apr 2, 2019

    @drammock
    MemberAuthor

    So, not intentional I take it. I'll have a look.

  3. jona-sassenhagen commented on Apr 2, 2019

    @jona-sassenhagen
    Contributor

    For the purpose of DRY, this could default to #6078 ...

  4. drammock commented on Apr 2, 2019

    @drammock
    MemberAuthor

    @jona-sassenhagen it looks like _plot_masked_image (and its proposed public version) require/create an axes object each time called, whereas plot_topo_image_epochs does the _iter_topography thing to plot each little imagmap inside one big axes. So changing plot_topo_image_epochs to use _plot_masked_image behind the scenes might take some heavy lifting.

    (as an aside, I noticed that _plot_masked_image has a picks argument that appears to go unused?)

  5. jona-sassenhagen commented on Apr 2, 2019

    @jona-sassenhagen
    Contributor

    Hm? iter_topography creates one axis per sensor, right?

    for ax, ch_idx in my_topo_plot:

    So this would essentially be about changing the show_func mostly, right?
    Not saying it is trivial.

    Either way, the same applies to #4746, which I will do during the sprint.

  6. drammock commented on Apr 2, 2019

    @drammock
    MemberAuthor

    ah, you're right @jona-sassenhagen. I thought it was passing unified=True by default, but that must have been something else I was looking at yesterday.

  7. drammock commented on Apr 2, 2019

    @drammock
    MemberAuthor

    @larsoner I'm convinced that in fact both of the plots above have messed up vmin/vmax. Compare the detail plots:

    epochs.plot_image(picks='EEG 060') 
    

    Figure_3

    versus clicking on that channel after

    epochs.copy().pick_types(meg=False, eeg=True).plot_topo_image()
    

    Figure_5

    versus clicking on that channel after

    epochs.plot_topo_image(layout=eeg_layout)
    

    Figure_4

    Still working out how to correct it.

  8. jona-sassenhagen commented on Apr 2, 2019

    @jona-sassenhagen
    Contributor

    I remember fixing a lot of code in epochs.plot_image to get the vlims right. Maybe check there.

    Or I could indeed try to hook this up to _plot_masked_image at the sprint, so it could simply share that vlim functionality.

  9. added a commit that references this issue on Apr 3, 2019
    70f8a27
  10. drammock commented on Apr 3, 2019

    @drammock
    MemberAuthor

    I'm gonna punt on this one until the sprint, I think. I put in a draft PR for what I think should be happening, but the resulting plots don't look right (too much of the signal lands near zero => images are mostly grey/white). I also considered an approach using np.quantile to set vmin/vmax at the (0.01, 0.99) quantiles to pull some color into the middle range... maybe worth exploring?

  11. mmagnuski commented on Apr 3, 2019

    @mmagnuski
    Member

    I've had this problem too some time ago, but now I rarely use plot_topo_image.

  12. jona-sassenhagen commented on Apr 23, 2019

    @jona-sassenhagen
    Contributor

    Mayyyyybe with #6186 in we can use _set_image_lims_and_scale for this.

  13. self-assigned this
    on Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions