mne group analysis presentation @ biomag 2016 conf

Post on 23-Jan-2018

1.298 Views

Category:

Science

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

How to perform MEG group analysis with MNE

MNE software for processing MEG and EEG data, A. Gramfort, M. Luessi, E. Larson, D. Engemann, D. Strohmeier, C. Brodbeck, L. Parkkonen, M. Hämäläinen, Neuroimage, 2014MEG and EEG data analysis with MNE-Python, A. Gramfort, M. Luessi, E. Larson, D. Engemann, D. Strohmeier, C. Brodbeck, R. Goj, M. Jas, T. Brooks, L. Parkkonen, M. Hämäläinen, Frontiers in Neuroscience, 2013

Biomag 2016http://www.biomag2016.org/satellite_meetings2.php

http://martinos.org/mne

• MNE based on C code developed for ~15 years by MSH• MNE-Python started ~6 years ago at MGH, Boston

About the project

Source: https://www.ohloh.net/p/MNE

http://martinos.org/mne/

http://mne-tools.github.io/mne-biomag-group-demo/

People behind this work

@agramfort @dengemann

@jasmainak

http://martinos.org/mne/stable/whats_new.html@jaeilepp

@Eric89GXL

MNE People

https://github.com/mne-tools/mne-python/graphs/contributors

Alan Leggitt, Alexander Rudiuk, Alexandre Barachant, Alexandre Gramfort, Andrew Dykstra, Asish Panda, Basile Pinsard, Brad Buran, Camilo Lamus, Cathy Nangini, Chris Holdgraf, Christian Brodbeck, Christoph Dinh, Christopher J. Bailey, Christopher Mullins, Clemens Brunner, Clément Moutard, Dan G. Wakeman, Daniel McCloy, Daniel Strohmeier, Denis A. Engemann, Emanuele Olivetti, Emily Ruzich, Emily Stephen, Eric Larson, Fede Raimondo, Federico Raimondo, Félix Raimundo, Guillaume Dumas, Hafeza Anevar, Hari Bharadwaj, Ingoo Lee, Jaakko Leppakangas, Jair Montoya, Jean-Remi King, Johannes Niediek, Jona Sassenhagen, Jussi Nurminen, Kambiz Tavabi, Keith Doelling, Lorenzo De Santis, Louis Thibault, Luke Bloy, Mads Jensen, Mainak Jas, Manfred Kitzbichler, Manoj Kumar, Marian Dovgialo, Marijn van Vliet, Mark Wronkiewicz, Marmaduke Woodman, Martin Billinger, Martin Luessi, Matt Tucker, Matti Hamalainen, Michael Krause, Mikolaj Magnuski, Natalie Klein, Nick Foti, Nick Ward, Niklas Wilming, Olaf Hauk, Phillip Alday, Praveen Sripad, Richard Höchenberger, Roan LaPlante, Romain Trachel, Roman Goj, Ross Maddox, Sagun Pai, Saket Choudhary, Simon Kornblith, Simon-Shlomo Poil, Sourav Singh, Tal Linzen, Tanay, Teon Brooks, Tom Dupré la Tour, Yaroslav Halchenko, Yousra Bekhti, Ellen Lau, Mads Jensen !

https://github.com/mne-tools/mne-biomag-group-demo/

Get the code to replicate

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/index.html

Analysis Scripts

One script

.../mne-biomag-group-demo/tree/master/scripts/processing

Fetch data from OpenfMRI

Sensor space analysis

Source space analysis

Anatomical pipeline

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/index.html

Results at group level

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/index.html

Demos and results for each

subject

Installing MNE-Python

$ pip install --upgrade --user mne

Install Scientific Python environment, e.g., Anaconda at

http://martinos.org/mne/stable/install_mne_python.html

https://www.continuum.io/downloads

Install MNE-Python:

.../mne-biomag-group-demo/tree/master/scripts/processing

Fetch data from OpenfMRI

Sensor space analysis

Source space analysis

Anatomical pipeline

Built on top of FreeSurfer$ recon-all -s ${SUBJECT} -i xy000000.nii -all

http://surfer.nmr.mgh.harvard.edu/

Anatomy workflow

MRI data

MRI data reconstructedrecon-all (Freesurfer 5.1)

BEM meshmne watershed_bemor mne flash_bem

BEM model

MEG/EEG data

Forward solutionor gain matrix

not automatic

needs freesurfer

Coregistrationmne_analyze/mrilab/Python

BEM meshes

http://martinos.org/mne/stable/auto_tutorials/plot_forward.html

BEM meshes

>>> for subject_id in range(1, 20):>>> subject = "sub%03d" % subject_id>>> mne.bem.make_watershed_bem(subject, >>> subjects_dir=subjects_dir,>>> overwrite=True)

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/11-make_watershed.html

Preprocessing: From raw to ERP/ERFdrifts blinks

line noise

cardiac

10 seconds filtered data clean data using SSPs

Preprocessingto get cleanevoked data(ERF/ERP)

or ICA

Maxwell filtering

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_maxfilter.html

MNE implements maxfilter (TM)

Maxwell filtering

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_maxfilter.html

MNE implements maxfilter (TM)

Maxwell filtering

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_maxfilter.html

MNE implements maxfilter (TM)

.../mne-biomag-group-demo/tree/master/scripts/processing

Fetch data from OpenfMRI

Sensor space analysis

Source space analysis

Filtering

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_analysis_1.html

Filtering

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_analysis_1.html

Code for filtering

>>> for subject_id in range(1, 20):>>> subject = "sub%03d" % subject_id>>> for run in range(1, 7):>>> raw_in = ...>>> raw = mne.io.read_raw_fif(raw_in, preload=True, add_eeg_ref=False)>>> raw.filter(1, 40, l_trans_bandwidth=0.5, h_trans_bandwidth='auto',>>> filter_length='auto', phase='zero', fir_window='hann')

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/02-python_filtering.html

Filter design

http://martinos.org/mne/stable/auto_tutorials/plot_background_filtering.html

Filter design

High pass filtering removes slow drifts and can make baselining unnecessary… yet the story is not that simple

http://martinos.org/mne/stable/auto_tutorials/plot_background_filtering.html

Paradigm

Presentation Screen

Famous

Unfamiliar

Scrambled

Paradigm on trigger channel

>>> mask = 4096 + 256 # mask for excluding high order bits>>> events = mne.find_events(raw, stim_channel='STI101',>>> consecutive='increasing', mask=mask,>>> mask_type='not_and', min_duration=0.003)>>> fig = mne.viz.plot_events(events)

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/03-run_extract_events.html

Paradigm in code

>>> events_id = {>>> 'face/famous/first': 5,>>> 'face/famous/immediate': 6,>>> 'face/famous/long': 7,>>> 'face/unfamiliar/first': 13,>>> 'face/unfamiliar/immediate': 14,>>> 'face/unfamiliar/long': 15,>>> 'scrambled/first': 17,>>> 'scrambled/immediate': 18,>>> 'scrambled/long': 19,>>> }

Use “tags” to describe events

From Epochs to Evoked

>>> tmin, tmax = -0.2, 0.8>>> reject = dict(grad=4000e-13, mag=4e-12, eog=180e-6)>>> baseline = None>>>>>> epochs = mne.Epochs(raw, events, events_id, tmin, tmax,

proj=True, picks=picks, baseline=baseline, preload=True, decim=2, reject=reject, add_eeg_ref=False)

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/05-make_epochs.html

…reject the ones with blinks

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_analysis_1.html

why did we drop epochs?Example of “drop log” for subject 1:

Use ICA on Epochs to remove ECG>>> ica_name = op.join(meg_dir, subject, 'run_%02d-ica.fif' % run)>>> ica = read_ica(ica_name)>>> n_max_ecg = 3 # use max 3 components>>> ecg_epochs = create_ecg_epochs(raw, tmin=-.5, tmax=.5)>>> ecg_inds, scores_ecg = ica.find_bads_ecg(ecg_epochs, method='ctps',

threshold=0.8)>>> ica.exclude += ecg_inds[:n_max_ecg]>>> ica.apply(epochs)

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_ica.html

Use ICA on Epochs to remove ECG

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_ica.html

Fit and apply ICA on Epochs

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_ica.html

From Epochs to Evoked

>>> evoked_faces = epochs['face'].average()>>> evoked_famous = epochs['face/famous'].average()>>> evoked_scrambled = epochs['scrambled'].average()>>> evoked_unfamiliar = epochs[‘face/unfamiliar'].average()>>> contrast = mne.combine_evoked([evoked_famous, >>> evoked_unfamiliar,>>> evoked_scrambled], >>> weights=[0.5, 0.5, -1.])>>> mne.evoked.write_evokeds('%s-ave.fif' % subject, [evoked_famous, evoked_scrambled, evoked_unfamiliar, contrast,

faces])

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/06-make_evoked.html

Index Epochs with tags

EEG Evoked for 3 first subjects

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_compare.html

EEG Evoked topographies (6 subjects)

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_compare.html

MEG Evoked for 3 first subjects

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_compare.html

MEG Evoked for 3 first subjects

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_compare.html

Back to filtering…

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_fanning.html

>>> raw.filter(None, 40, fir_window='hann', phase='zero', h_trans_bandwidth=‘auto’, filter_length='auto')

Back to filtering…

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_fanning.html

>>> raw.filter(None, 40, fir_window='hann', phase='zero', h_trans_bandwidth=‘auto’, filter_length='auto')

Fanningproblem

Much lessfanning

Back to filtering…

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_fanning.html

>>> raw.filter(1, None, l_trans_bandwidth=0.5, fir_window='hann', phase='zero',

h_trans_bandwidth=‘auto’, filter_length='auto')

Covariance est. and whitening

Engemann, D.A., Gramfort, A., Automated model selection in covariance estimation and spatial whitening of MEG and EEG signals., Neuroimage 2015

>>> cov = mne.compute_covariance(epochs, tmax=0, method='shrunk')

Covariance est. and whitening

>>> cov = mne.compute_covariance(epochs, tmax=0, method='shrunk')

whitened Global Field Power

whitened ERF

whitened ERP

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_analysis_1.html

Grand averaging

>>> for idx, evokeds in enumerate(all_evokeds):>>> # Combine subjects:>>> grand_avg[idx] = mne.combine_evoked(evokeds, 'equal')

>>> mapping = {'Famous': evokeds[0], 'Scrambled': evokeds[1], 'Unfamiliar': evokeds[2]}>>> mne.viz.plot_compare_evokeds(mapping, [idx])

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_group.html

Grand averaging

>>> for idx, evokeds in enumerate(all_evokeds):>>> # Combine subjects:>>> grand_avg[idx] = mne.combine_evoked(evokeds, 'equal')

>>> mapping = {'Famous': evokeds[0], 'Scrambled': evokeds[1], 'Unfamiliar': evokeds[2]}>>> mne.viz.plot_compare_evokeds(mapping, [idx])

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_group.html

From baseline to baseline !

MNE vs. Wakeman et al.

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_group.html

MNE vs. Wakeman et al.

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_group.html

Real?

Sensors stats (cluster level)

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_sensor_cluster_stats_eeg_channel.html

Sensors stats (cluster level)

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_sensor_spatio_temporal_cluster_stats.html

p = 0.01 (corrected)

Decoding

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_time_decoding.html

>>> td = TimeDecoding(predict_mode='cross-validation', times=times, scorer='roc_auc')>>> td.fit(epochs, y)

http://mne-tools.github.io/mne-biomag-group-demo/auto_scripts/08-run_time_decoding.html

Source space analysis

• 3 Layers BEM forward modeling

• dSPM source localization on cortical surface

• loose orientation (0.2) & depth (0.8) & SNR = 3

• RMS across orientations

• morphing to fsaverage:subject fsaveragemorphing

… the MNE (default) way

Source space analysis

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_analysis_2.html

Subject 2Contrast

localization (faces vs.

scrambled

Source space group analysis

http://mne-tools.github.io/mne-biomag-group-demo/auto_examples/plot_group.html

16 subjectsaverage ofContrast (faces vs.

scrambled

MNE web report

http://perso.telecom-paristech.fr/~mjas/biomag_demo/report_sub002.html

MNE web report

http://perso.telecom-paristech.fr/~mjas/biomag_demo/report_sub002.html

Command line:$ mne report --path MEG/sub002 --info MEG/sub002/run_01_filt_sss-epo.fif --subject sub002 --subjects-dir subjects/ --verbose --jobs 6

Getting help http://martinos.org/mne/

http://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysisMailing list:

Getting inspired...http://martinos.org/mne/auto_examples/index.html

Sending feedbackhttps://github.com/mne-tools/mne-python

Some links• Documentation:

• http://martinos.org/mne/ (general doc)

• http://martinos.org/mne/stable/manual/index.html (manual)

• http://martinos.org/mne/stable/tutorials.html (tutorials with code)

• http://martinos.org/mne/auto_examples/index.html (python examples)

• Code:

• https://github.com/mne-tools/mne-python (mne-python code)

• https://github.com/mne-tools/mne-matlab (mne matlab toolbox)

• https://github.com/mne-tools/mne-scripts (mne shell scripts)

Access HCP-MEG data as MNE-Python data structures

https:/mne-tools.github.io/mne-hcp

Seamlessly plug HCP MEG data into the Python ecosystem

…/mne-hcp/auto_tutorials/index.html

Poster

[Mo-P008]

Engemann et al.

Alexandre Gramforthttp://alexandre.gramfort.netContact:

GitHub : @agramfort Twitter : @agramfort

If you want a sticker come to the

MNE poster !

OpenScience!

top related