Repository navigation
MRG: Unify compute_source_psd, compute_source_psd_epochs - #5514
Conversation
|
This looks more reasonable to me then what I was getting using compute_source_psd but it still doesn't seem to match what I see in brainstorm using a similar although not identical pipeline. Below you'll find attached screen shots showing sensor PSD, topo and localized relative power, for 2 frequencies 8 and 35 Hz for both a brainstorm pipeline and this pipeline. It seems like the sensor data is in agreement, but the source estimates look very different. In my opinion brainstorm more closely matches the topos at those frequencies. @dengemann do you have access to brainstorm? 8 HZ35 Hz |
|
Does anyone have an example neuromag resting dataset? perhaps this is a CTF specific issue? |
|
did you clean the data the same way? did you mark bad segments?
at least the sensor PSDs should be the same.
|
|
Hi Denis! Sorry, I'm quite busy till mid Oct, I'll carefully review it by then if it's not very late for you. |
|
@agramfort in this particular example neither pipelines marks bad segments. Differences between pipelines. The preprocessing pipelines in issue #5510 are more similar. That being said I think the sensor PSDs do look very similar. The visual difference in the topos is mostly color map and edge interpolation I think. The big difference to my eye is how different the source analysis looks give the similarities in the sensor profiles. Look at the 8 Hz peak. Both topos (MNE and brainstorm) show 2 hot spots on the right hemisphere. Brainstorm puts the activity in roughly the right spot, middle of the right hemisphere, where as MNE has bilateral occipital activation. |
|
ok I see. Yes https://user-images.githubusercontent.com/5585821/45498042-3c7a2900-b747-11e8-9bd1-c9ac2a388ae9.png is weird. did you check with plot_alignment? can we mess up the compensation info? |
|
@bloyl do you want to suggest edits here that approximate the pipelines as much as possible? I think this is what we have to do. |
@guiomar Hi Guiomar, sure, no problem! Showing a cross-toolbox replication of analyses is still a good thing mid October. It is only important that we make progress before the next Biomag. Otherwise we cannot do our next panel session :) |
|
@guiomar @agramfort @larsoner @SherazKhan I am just wondering if any licensing issue speaks against shipping one or two OMEGA datasets via MNE (making it download if user clicks to agree to license). This would probably be the best. |
|
plot_alignment looks fine. Regarding gradient compensations. It is worth noting that the resting (comp=3) and empty room(comp=0) have difference gradient compensations on. That being said If i set grad_comp to either 3 or 0 ( |
We need to systematically debug this. In principle we should be able to do logically exactly the same. |
|
@dengemann : I don't know about licensing on the omega datasets. Do you know if this code/approach works with HCP resting data? |
|
That is interesting what you say. Perhaps something about our CTF handling
is off. HCP works well. You have a lot occipital and motor alpha/beta there
and clear high SNR power spectra. Just we have to do a bit of work to make
an example here in MNE. Doing such an example on the mne-hcp website would
be easier / faster.
…On Fri 14 Sep 2018 at 00:41, Luke Bloy ***@***.***> wrote:
@dengemann <https://github.com/dengemann> : I don't know about licensing
on the omega datasets.
I do know that this issue exists there as well as that is the data I
looked at initially.
Do you know if this code/approach works with HCP resting data?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5514 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB0fipV99zvZMCtjM2PXuLzLJZe-vCkNks5uat8xgaJpZM4WmNtW>
.
|
|
Anyways: we should not abandon this issue. The fact that we have
difficulties seeing similar results is telling us that there is something
to learn. Worst case: write out numbers and compare Brainstom-MNE step by
step.
On Fri 14 Sep 2018 at 00:44, Denis-Alexander Engemann <
[email protected]> wrote:
… That is interesting what you say. Perhaps something about our CTF handling
is off. HCP works well. You have a lot occipital and motor alpha/beta there
and clear high SNR power spectra. Just we have to do a bit of work to make
an example here in MNE. Doing such an example on the mne-hcp website would
be easier / faster.
On Fri 14 Sep 2018 at 00:41, Luke Bloy ***@***.***> wrote:
> @dengemann <https://github.com/dengemann> : I don't know about licensing
> on the omega datasets.
> I do know that this issue exists there as well as that is the data I
> looked at initially.
>
> Do you know if this code/approach works with HCP resting data?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#5514 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AB0fipV99zvZMCtjM2PXuLzLJZe-vCkNks5uat8xgaJpZM4WmNtW>
> .
>
|
|
OK I think I have sorted the issue. The problem is that both the new example and mne-python/mne/minimum_norm/time_frequency.py Line 514 in b6b0afe I get much more biological looking maps that match much better with brainstrom figures of relative power. While it doesn't make perfect sense. IE logs shouldn't change ordering, I think the combination of values much less than 1 and some scaling (maybe?) in the display code causes the behavior we are seeing. Does this make sense to others? |
|
Can you push a commit to how branch so we can see the effect? Yes the log will have a compressive effect so it will make differences less drastic |
|
I don't think i have push access to @dengemann 's branch. Even if i did i don't know how to push to it. Can i just push to the checked-out out PR? |
|
Who asks shall be given Luke! I'm on it.
…On Tue, Sep 18, 2018 at 9:05 PM Luke Bloy ***@***.***> wrote:
I don't think i have push access to @dengemann
<https://github.com/dengemann> 's branch. Even if i did i don't know how
to push to it. Can i just push to the checked-out out PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5514 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB0fimr_DzDT8Oa_IG40W92YvvjRaxxdks5ucUPdgaJpZM4WmNtW>
.
|
|
@dengemann thx. I'll try to figure out how to push right to the PR. @larsoner in the mean time here is a modified example the demonstrates the difference. I just commented out the output at 35hz is below. notice it better matches the epoch topos and the brainstorm responses from above. In thinking more about it the scaling issues (ie changing spatial peaks), might be our computing relative power in decibels? |
You should have push access now. Regarding the image you share what made me suspicious when I played with the data and scrolled through frequencies was that everything seemed to land in the visual cortex here regardless of the frequency band, with some small fluctuations. But generally speaking, the OMEGA/Brainstorm results should be our guide. |
|
Yes the "baseline correction" applied will matter Keep in mind you never actually push to a PR, this is loose terminology. You push commits to branches. Requests to merge commits from one branch to another form PRs. So basically you need to push commits to whatever branch is listed in this PR, namely dengemann:bstorm_rest |
Codecov Report
@@ Coverage Diff @@
## master #5514 +/- ##
=========================================
+ Coverage 88.49% 88.5% +0.01%
=========================================
Files 369 369
Lines 69074 69115 +41
Branches 11651 11654 +3
=========================================
+ Hits 61124 61172 +48
+ Misses 5090 5087 -3
+ Partials 2860 2856 -4 |
|
I have the impression it's the same pb you have when you do t-test in
source space. If var is super
small normalizing with std or baseline can blow up the values. And
typically you can these tiny
values in deep sources ...
|
|
I've simplified, optimized, and unified the two scripts to get the following output: @bloyl @dengemann if you can both take a quick look and let me know if it still makes sense to you then I think we can merge this for 0.17. |
|
... I noticed that there is something fishy where the result changes depending on whether you use But we should maybe fix that separately. |
|
Okay from talking to @dengemann we'll split this into two PRs:
@dengemann is going to try to follow the now-removed example with |
| - Fix :func:`mne.io.Raw.plot_proj_topomap` by `Joan Massich`_ | ||
| - Fix :func:`mne.io.Raw.plot_projs_topomap` by `Joan Massich`_ | ||
|
|
||
| - Fix bug in :func:`mne.minimum_norm.compute_source_psd` where the ``stc.times`` output was scaled by 1000, by `Eric Larson`_ |
| stc.data = source_data | ||
| out = stc | ||
| if return_sensor: | ||
| out = (out, evoked) |
There was a problem hiding this comment.
Fix: make compute_source_psd wrap to compute_source_psd_epochs. We get multitaper estimation for free, and simplify the codebase.
Enhancement: have return_sensor output so you get the Evoked and SourceEstimate.
| if dB is None: | ||
| dB = True | ||
| warn('dB=True by default in 0.17 but will change to False in 0.18, ' | ||
| 'set it explicitly to avoid this warning', DeprecationWarning) |
There was a problem hiding this comment.
Fix: Deprecate dB=True to unify with compute_source_psd_epochs (which does not even have a dB argument and outputs non-dB PSDs)
| logger.info('Using %d tapers with bandwidth %0.1fHz %s' | ||
| % (n_tapers, bandwidth, extra)) | ||
| if isinstance(bandwidth, string_types): | ||
| bandwidth = '%s windowing' % (bandwidth,) |
There was a problem hiding this comment.
Enhancement: allow MTM estimation to take a string, meaning "use standard estimation". The advantage of this is that in the long run it will greatly simplify our code paths, especially if we go to implement CUDA-based multitaper estimation.
| Returns | ||
| ------- | ||
| stc : SourceEstimate | VectorSourceEstimate | ||
| The modified stc. |
There was a problem hiding this comment.
Enh: Add missing SourceEstimate method
| (read_info(fname_kit_raw), 304, 'KIT'), | ||
| (read_info(fname_bti_raw), 304, 'Magnes'), | ||
| (read_info(fname_ctf_raw), 348, 'CTF'), | ||
| (read_info(fname_ctf_raw), 343, 'CTF'), |
There was a problem hiding this comment.
Enh: Improve CTF helmet position based on information from this thread. (And it looks more correct / no more head collisions in BST data, too.)
| title : str | None | ||
| Title for the figure. If None, the subject name will be used. | ||
|
|
||
| .. versionadded:: 0.17.0 |
There was a problem hiding this comment.
Enh: Allow plot_source_estimates to take a title kwarg as an alternative to auto-setting it
| for l in layout: | ||
| if not isinstance(l, Layout): | ||
| raise TypeError('All entries in layout list must be of type ' | ||
| 'Layout, got type %s' % (type(l),)) |
There was a problem hiding this comment.
Fix: Give more informative error
|
@dengemann is okay with the two-PR plan. So @agramfort if you're happy I think this should be good to merge. Once this is in, I'll open a second PR where @dengemann and @bloyl can report back on how the Brainstorm pipeline works on their data |
|
diff was a pain to read but LGTM. |
I tried to make your life a little bit easier with guiding review comments, but I'm not surprised it was still unpleasant. Thanks for looking Since @dengemann said he was okay with this refactoring, okay to merge this? |
|
ok then !
|






This is the script I worked on during our small Biomag2018 sprint @larsoner @agramfort.
The analysis implements conceptually on my understanding of what @guiomar presented ruing our open science panel.
The good news is that something physiologically looking comes out.
The bad news is that I have to write "funny" code to make this happen and the data is quite difficult to analyze:
As we know our default surface plotting is not prepared for heavy tailed data and moving distributions. So we have to crop stcs and compute local percentages, etc.
I had to compute Welch PSDs in source space in an unelegant way in order to get relative source power. For comparison, our inverse PSD function gave quite meaningless results
The data seems difficult. In many segments of the data the local PSD shows no pronounced alpha peak and the overall morphology of the PSD is driven by a few segments with clear oscillatory peaks in alpha and beta.
@bloyl have a look here and let me know what you think. We can work on this PR together in the next days and I can give you push access into my fork.
@guiomar I'd be curious if what I did here is about equivalent with your OMEGA analysis and if the results look plausible to you.
cc @dokato here you have finally the example + coreg info to do source localization of the Brainstorm resting state data.
Here are some plots from the script (and some interactively generated ones):