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 : source reconstruction on EEG using fsaverage brain #6146

Merged
merged 30 commits into from
Apr 23, 2019

Conversation

agramfort
Copy link
Member

@agramfort agramfort commented Apr 13, 2019

this PR aims to cover a long standing issue with MNE which is to do EEG source reconstruction using a template brain here fsaverage.

Limitation of the current PR:

  • very coarse narrative doc
  • has no cross-links with other tutorials
  • only tests with one montage file 'standard_1005'
  • data contains induced power so current evoked pipeline is not appropriate.
  • needs mne.datasets.fetch_fsaverage_3layer_bem or so

@drammock any thoughts on how to integrate this in the new in the making documentation?

@massich this is a good test for the new digitization refactoring

@agramfort
Copy link
Member Author

agramfort commented Apr 15, 2019 via email

@agramfort
Copy link
Member Author

agramfort commented Apr 15, 2019 via email

@mmagnuski
Copy link
Member

Circle errors on the example:

Traceback (most recent call last):
  File "/home/circleci/.local/lib/python3.7/site-packages/sphinx_gallery/gen_rst.py", line 398, in _memory_usage
    multiprocess=True)
  File "/home/circleci/.local/lib/python3.7/site-packages/memory_profiler.py", line 336, in memory_usage
    returned = f(*args, **kw)
  File "/home/circleci/.local/lib/python3.7/site-packages/sphinx_gallery/gen_rst.py", line 389, in __call__
    exec(self.code, self.globals)
  File "/home/circleci/project/tutorials/plot_eeg_no_mri.py", line 58, in <module>
    subjects_dir=subjects_dir, trans=trans_fname)
  File "</home/circleci/project/mne/externals/decorator.py:decorator-gen-117>", line 2, in plot_alignment
  File "/home/circleci/project/mne/utils/_logging.py", line 89, in wrapper
    return function(*args, **kwargs)
  File "/home/circleci/project/mne/viz/_3d.py", line 815, in plot_alignment
    % (subject, '\n'.join(try_fnames)))
OSError: No head surface found for subject fsaverage after trying:
/home/circleci/mne_data/MNE-sample-data/subjects/fsaverage/bem/outer_skin.surf
/home/circleci/mne_data/MNE-sample-data/subjects/fsaverage/bem/flash/outer_skin.surf
/home/circleci/mne_data/MNE-sample-data/subjects/fsaverage/bem/fsaverage-head.fif

@mmagnuski
Copy link
Member

@agramfort Sure, I can try, but I had a lot of problems before trying to push to other people's PRs. If you also have a tutorial on that, that would be helpful. :)

@mmagnuski
Copy link
Member

Regarding the error: is it possible that mne's fsaverage ships without head surface? I remember I had to construct it when using fsaverage for source localization.

@agramfort
Copy link
Member Author

agramfort commented Apr 15, 2019 via email

@larsoner
Copy link
Member

If you upload the surfaces I can update the dataset. Or if it's as simple as mne watershed_bem I'll run it locally and update.

@agramfort
Copy link
Member Author

agramfort commented Apr 15, 2019 via email

@larsoner
Copy link
Member

We already have fsaverage-inner_skull-bem.fif in mne/data/ but no 3-layer, and I don't think we should add it there because it bloats the repo. We could add a mne.datasets.fetch_fsaverage_3layer_bem or something. We can converge at the sprint

@agramfort
Copy link
Member Author

agramfort commented Apr 15, 2019 via email

@massich
Copy link
Contributor

massich commented Apr 15, 2019

This tuto does something similar to what we have in #5836 but with fsavarege rather than sample. I can take over and the missing files so that this PR renders in circle.

@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #6146 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #6146      +/-   ##
==========================================
+ Coverage   87.21%   87.21%   +<.01%     
==========================================
  Files         412      412              
  Lines       73985    73985              
  Branches    12270    12270              
==========================================
+ Hits        64523    64525       +2     
+ Misses       6592     6588       -4     
- Partials     2870     2872       +2

@massich
Copy link
Contributor

massich commented Apr 15, 2019

@massich
Copy link
Contributor

massich commented Apr 15, 2019

The current solution requires to download 1.8Gb we could either allow for:

  1. Partial download of the sample
  2. split sample and fsaverage and,
    2a) ship them separately
    2b) ship them twice

@drammock
Copy link
Member

@agramfort for now, putting it in the root of tutorials (as you've done) is fine. This PR will almost surely get merged before the big tutorials overhaul, and I'll rebase against it and move this new tutorial as necessary at that time.

# check all montages
#

fix_units = {'EGI_256':'cm', 'GSN-HydroCel-128':'cm', 'GSN-HydroCel-129':'cm',
Copy link
Member

Choose a reason for hiding this comment

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

EGI_256 is not in cm, take a look at this comment: the distance for each channel from the center is exactly 1. for EGI_256.

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed your comment. The way you figured out the distance is smarter than the way I did it.

The code was pulled from an early stage of #5836 and yes EGI_256 it's broken. Now that we are at it, when load EGI_256 with eeg=['original', 'projected'] you can see that the original do have a 'brainish' shape but the projected does not.

Either way, we decided with @agramfort to add the example ploting all helmets i a different PR. (I'll ping you there)

@larsoner
Copy link
Member

I'm okay with the sensitivity map, we should just link at the end to a standard MNE tutorial or something then

@larsoner larsoner self-assigned this Apr 19, 2019
@agramfort
Copy link
Member Author

agramfort commented Apr 19, 2019 via email

@massich
Copy link
Contributor

massich commented Apr 19, 2019

does it mean that we make #6167 green (or cherry pick 32efc81) and call it a day? Or are we missing something else?

@massich
Copy link
Contributor

massich commented Apr 19, 2019

does it mean that we make #6167 green (or cherry pick 32efc81) and call it a day? Or are we missing something else?

I'm referring to the example itself.

@agramfort
Copy link
Member Author

agramfort commented Apr 19, 2019 via email

@larsoner
Copy link
Member

Feel free to push to my branch the commit to go back to eegbci

return subjects_dir


def set_montage_coreg_path(subjects_dir=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

I would make this private

Copy link
Member Author

@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.

@massich I am lost reviewing this PR. I see unrelated things and I still see the use of set_montage_coreg_path

mne/bem.py Outdated
if incomplete == 'raise':
raise RuntimeError(msg)
else:
warn(msg)
Copy link
Member Author

Choose a reason for hiding this comment

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

why is this here???

Copy link
Member

Choose a reason for hiding this comment

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

got here likely by accident in 8d1023e

fnames = glob.glob(op.join(tempdir, '*proj.fif'))
assert len(fnames) == 1
fnames = glob.glob(op.join(tempdir, '*-eve.fif'))
assert len(fnames) == 1
Copy link
Member Author

Choose a reason for hiding this comment

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

how did this happen in this PR?

@@ -37,9 +37,6 @@ def run():
action="store_true")
parser.add_option("-p", "--preflood", dest="preflood",
help="Change the preflood height", default=None)
parser.add_option("--copy", dest="copy",
help="Use copies instead of symlinks for surfaces",
action="store_true")
Copy link
Contributor

Choose a reason for hiding this comment

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

@larsoner all this bem related things that were added to the PR. Were they needed?? I mean, they are unrelated to the PR. But maybe you wanted them.

Copy link
Member

Choose a reason for hiding this comment

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

They were needed when I created the 3-layer BEM for fsaverage, so yes please keep

"""Test mne flash_bem."""
check_usage(mne_flash_bem, force_help=True)
# Using the sample dataset
subjects_dir = op.join(sample.data_path(download=False), 'subjects')
# Copy necessary files to tempdir
tempdir = str(tmpdir)
tempdir = _TempDir()
Copy link
Member

Choose a reason for hiding this comment

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

We want almost everything from this commit. Feel free to push a new PR but we shouldn't lose them

Copy link
Contributor

Choose a reason for hiding this comment

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

no prob. I'll get it back and just ping you to make sure I did not forget anything important.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I made a PR #6192 feel free to push in it.

@jona-sassenhagen
Copy link
Contributor

Didn't see this ... very cool MNE is making an effort to support the "lazy and stupid" crowd finally!!!

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

I reviewed only the Tutorial at @massich's request; there are lots of small improvements that are possible, but nothing that is unclear enough to be a blocker.

# The files live in:
subject = 'fsaverage'
trans = op.join(fs_dir, 'bem', 'fsaverage-trans.fif')
src = op.join(fs_dir, 'bem', 'fsaverage-5-src.fif')
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be 'fsaverage-ico-5-src.fif?

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

@massich
Copy link
Contributor

massich commented Apr 23, 2019

the failing error is unrelated. Merging

@massich massich merged commit 639b738 into mne-tools:master Apr 23, 2019
jeythekey pushed a commit to jeythekey/mne-python that referenced this pull request Apr 27, 2019
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.

7 participants