Skip to content

FIX plot_compared_evokeds grad ci estimation - #4736

Closed
ktavabi wants to merge 2 commits into
mne-tools:masterfrom
ktavabi:fix-compare-evokeds
Closed

ktavabi wants to merge 2 commits into
mne-tools:masterfrom
ktavabi:fix-compare-evokeds

Conversation

@ktavabi

@ktavabi ktavabi commented Nov 8, 2017

Copy link
Copy Markdown
Contributor

Attempt to fix #4730

Comment thread mne/viz/evoked.py
data = np.asarray([evoked_.data[picks, :].mean(0)
for evoked_ in evokeds[condition]])
if ch_type == 'grad':
data = [(_merge_grad_data(evoked_.data[picks, :])).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems you need to import _merge_grad_data :)

Also maybe you will have to include a check that the relevant channels are in the picks.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Thanks for tackling this!

@ktavabi

ktavabi commented Nov 9, 2017

Copy link
Copy Markdown
Contributor Author

Shouldn't there be an import error if _merge_grad_data is not available? In any case, I tried from ..channels.layout import _merge_grad_data at ln 1668 to no avail.

I also tried unpacking and running [(_merge_grad_data(evoked_.data[picks, :])).mean(0) for evoked_ in evokeds[condition]] line by line with same result.

Also maybe you will have to include a check that the relevant channels are in the picks.

I am also suspecting the pairing of grads is somehow getting botched between ci and averaging, but can't see how. Anyway TBC, late here.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Shouldn't there be an import error if _merge_grad_data is not available?

No, if you try to use something that's not defined, you get a NameError. ImportError is for stuff that you try to import, but the import fails.

@ktavabi

ktavabi commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

Sorry, that's what I meant. I think _merge_grad_data is already in the namespace.

@codecov

codecov Bot commented Nov 10, 2017

Copy link
Copy Markdown

Codecov Report

Merging #4736 into master will decrease coverage by 26.23%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master   #4736       +/-   ##
==========================================
- Coverage   87.84%   61.6%   -26.24%     
==========================================
  Files         349     349               
  Lines       65761   65764        +3     
  Branches    11311   11313        +2     
==========================================
- Hits        57767   40515    -17252     
- Misses       5124   22676    +17552     
+ Partials     2870    2573      -297

@ktavabi

ktavabi commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

So it looks like

  1. Taking RMS of grad pairs
  2. Computing ci and mean

is different from

  1. Taking RMS of grads
  2. computing ci
  3. averaging evokeds
  4. Taking RMS of grand mean

Does this make sense?

@agramfort

Copy link
Copy Markdown
Member

@ktavabi to compute CIs on combined grads you need first to combine grads
on each epoch, then compute CIs and show the average + CIs.

in other words you cannot compute CIs on each channel

clear?

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Import of merge_grads depends on if ch_type == 'grad' and len(picks) > 1:. So if you have only one pick, it's not being imported. However, if there is only one pick, you can't pair them anyways.

@ktavabi

ktavabi commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

Sorry, @agramfort I am not sure what you mean.

Where ch_type == 'grad' and len(picks) > 1

  1. data = np.asarray([(_merge_grad_data(evoked_.data[picks, :])).mean(0) for evoked_ in evokeds[condition]]) is the merged grad data array (cond x time) for each evoked ds?
  2. data.mean(0) and _ci_fun(data) are grad RMS mean and ci across evokeds?

I was assuming that is the scope of this PR i.e., we need mean + CIs of grad RMS (fig 2) across evokeds (fig 3) for gist in #4730 to work, no?

screen shot 2017-11-10 at 11 48 33 am

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Sorry, I can't be of much help here. I messed it up in the first place, grads just confuse me.

@ktavabi ktavabi closed this Nov 15, 2017
@ktavabi
ktavabi deleted the fix-compare-evokeds branch November 15, 2017 07:28
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.

Compare evokeds confidence intervals for grads

3 participants