Module Expr Str Import alias Import alias identifier Import alias identifier ImportFrom alias Import alias identifier Import alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias Print NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd NameLoad Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMod NameLoad Num Assign NameStore Call AttributeLoad Call AttributeLoad Call AttributeLoad NameLoad attr Num Num attr attr Num keyword Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Num NameLoad keyword Str keyword Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Str Assign NameStore Dict Str Str Num Num Assign TupleStore NameStore NameStore TupleLoad Num Num Assign NameStore NameLoad Assign NameStore Call NameLoad keyword Num Assign NameStore BinOpAdd NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword NameLoad keyword NameLoad Assign NameStore BinOpAdd NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Delete NameDel Assign NameStore TupleLoad Str Str Assign NameStore Num Assign NameStore BinOpDiv Num BinOpPow NameLoad Num Assign NameStore Str Assign NameStore Call NameLoad keyword Str keyword ListLoad Num Num Num Assign NameStore TupleLoad Num Num Assign NameStore TupleLoad Str Str Assign NameStore TupleLoad Str Str Assign NameStore Call NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr ListComp SubscriptLoad SubscriptLoad NameLoad Index CompareEq SubscriptLoad NameLoad ExtSlice Slice Index Num NameLoad Slice NameLoad comprehension NameStore ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assert CompareEq Call NameLoad NameLoad BinOpMult Num NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad keyword NameLoad keyword Num keyword NameLoad Assign NameStore ListComp Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr comprehension NameStore NameLoad Delete NameDel NameDel Expr Call AttributeLoad NameLoad attr Call NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad For NameStore NameLoad body Assign NameStore Call NameLoad AttributeLoad SubscriptLoad NameLoad Index Num attr NameLoad NameLoad keyword Num keyword Num keyword Num Assign TupleStore NameStore NameStore GeneratorExp Call NameLoad NameLoad NameLoad NameLoad Str keyword NameLoad comprehension NameStore NameLoad Assign NameStore BinOpSub NameLoad NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index Num attr SubscriptLoad NameLoad Index Str Expr Call AttributeLoad SubscriptLoad NameLoad Index Num attr NameLoad Delete NameDel NameDel NameDel NameDel NameDel NameDel NameDel Delete NameDel NameDel Assign TupleStore NameStore TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Num Num keyword TupleLoad Num Num FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad keyword ListLoad Str Assign NameStore Call NameLoad BinOpAdd NameLoad Str Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad Str Return NameLoad decorator_list For TupleStore NameStore TupleStore NameStore NameStore Call NameLoad Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index Num For TupleStore NameStore NameStore NameStore NameStore NameStore Call NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Slice Num SubscriptLoad NameLoad Index NameLoad ListLoad Str Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword Str keyword NameLoad Expr Call AttributeLoad NameLoad attr Num Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Delete NameDel Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad BinOpMult NameLoad Num Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num Expr Call AttributeLoad NameLoad attr BinOpMult AttributeLoad NameLoad attr Num NameLoad keyword Call AttributeLoad Str attr NameLoad NameLoad keyword NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num Expr Call AttributeLoad NameLoad attr BinOpMult AttributeLoad NameLoad attr Num BinOpSub NameLoad NameLoad BinOpAdd NameLoad NameLoad keyword Num keyword NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr BinOpMult NameLoad Num Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr BinOpMult NameLoad Num BinOpMult NameLoad Num Expr Call AttributeLoad NameLoad attr Num Num Expr Call AttributeLoad NameLoad attr keyword Str keyword Num Expr Call AttributeLoad NameLoad attr keyword Num keyword Num keyword Num keyword Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr
N/A N/A 
===================================================
Demonstrate impact of whitening on source estimates
===================================================

This example demonstrates the relationship between the noise covariance
estimate and the MNE / dSPM source amplitudes. It computes source estimates for
the SPM faces data and compares proper regularization with insufficient
regularization based on the methods described in [1]_. The example demonstrates
that improper regularization can lead to overestimation of source amplitudes.
This example makes use of the previous, non-optimized code path that was used
before implementing the suggestions presented in [1]_. Please do not copy the
patterns presented here for your own analysis, this is example is purely
illustrative.

.. note:: This example does quite a bit of processing, so even on a
          fast machine it can take a couple of minutes to complete.

References
----------
.. [1] Engemann D. and Gramfort A. (2015) Automated model selection in
       covariance estimation and spatial whitening of MEG and EEG signals,
       vol. 108, 328-342, NeuroImage.
 N/A os N/A os.path op N/A numpy np scipy.misc imread N/A matplotlib.pyplot plt N/A mne mne io mne.datasets spm_face mne.minimum_norm apply_inverse make_inverse_operator mne.cov compute_covariance N/A __doc__ N/A data_path N/A N/A spm_face data_path N/A subjects_dir N/A data_path /subjects N/A raw_fname N/A data_path /MEG/spm/SPM_CTF_MEG_example_faces%d_3D.ds N/A raw N/A N/A io read_raw_ctf N/A raw_fname 1 N/A raw N/A N/A N/A N/A N/A N/A raw crop 0 150.0 load_data resample 60 npad auto N/A picks N/A N/A mne pick_types N/A raw info meg True exclude bads N/A N/A N/A raw filter 1 None method iir n_jobs 1 N/A events N/A N/A mne find_events raw stim_channel UPPT001 N/A event_ids N/A faces scrambled 1 2 N/A N/A tmin tmax N/A -0.2 0.5 N/A baseline None N/A reject N/A dict mag 3e-12 N/A trans N/A data_path /MEG/spm/SPM_CTF_MEG_example_faces1_3D_raw-trans.fif N/A src N/A N/A mne setup_source_space spm fname None spacing oct6 subjects_dir subjects_dir add_dist False N/A bem N/A data_path /subjects/spm/bem/spm-5120-5120-5120-bem-sol.fif N/A forward N/A N/A mne make_forward_solution N/A raw info trans src bem N/A forward N/A N/A mne convert_forward_solution forward surf_ori True N/A src N/A conditions N/A faces scrambled N/A snr 3.0 N/A lambda2 N/A 1.0 N/A snr 2 N/A method dSPM N/A clim N/A dict kind value lims N/A 0 2.5 5 N/A samples_epochs N/A 5 15 N/A method N/A empirical shrunk N/A colors N/A steelblue red N/A evokeds N/A list N/A stcs N/A list N/A methods_ordered N/A list N/A n_train samples_epochs N/A N/A events_ N/A N/A np concatenate N/A N/A N/A events N/A N/A N/A events N/A N/A N/A 2 id_ N/A n_train N/A id_ N/A N/A event_ids N/A k N/A k conditions N/A epochs_train N/A N/A mne Epochs raw events_ event_ids tmin tmax picks picks baseline baseline preload True reject reject N/A N/A N/A epochs_train equalize_event_counts event_ids copy False N/A N/A N/A len epochs_train N/A 2 n_train N/A noise_covs N/A compute_covariance epochs_train method method tmin None tmax 0 return_estimators True N/A evokeds N/A N/A N/A N/A epochs_train N/A k average N/A k conditions N/A epochs_train events_ N/A N/A N/A stcs append N/A list N/A N/A N/A methods_ordered append N/A list N/A cov noise_covs N/A N/A inverse_operator N/A make_inverse_operator N/A N/A evokeds N/A 0 info forward cov loose 0.2 depth 0.8 rank 274 N/A N/A stc_a stc_b N/A N/A apply_inverse e inverse_operator lambda2 dSPM pick_ori None N/A e evokeds N/A stc N/A stc_a stc_b N/A N/A N/A N/A methods_ordered N/A -1 append N/A cov N/A method N/A N/A N/A N/A stcs N/A -1 append stc N/A inverse_operator evokeds cov noise_covs stc stc_a stc_b N/A raw forward N/A N/A fig N/A axes1 axes2 N/A N/A plt subplots 2 3 figsize N/A 9.5 6 brain_to_mpl N/A N/A brain N/A N/A N/A convert image to be usable with matplotlib N/A tmp_path N/A N/A op abspath N/A N/A op join N/A op curdir my_tmp N/A N/A N/A brain save_imageset tmp_path views N/A ven N/A im N/A imread N/A tmp_path _ven.png N/A N/A N/A os remove N/A tmp_path _ven.png N/A im N/A N/A N/A ni N/A n_train axes N/A enumerate N/A zip samples_epochs N/A axes1 axes2 N/A N/A ax_dynamics N/A axes N/A 1 N/A N/A stc ax method kind color N/A zip N/A stcs N/A ni N/A axes N/A 2 N/A methods_ordered N/A ni N/A best worst colors N/A N/A brain N/A N/A stc plot subjects_dir subjects_dir hemi both clim clim N/A N/A N/A brain set_time 175 N/A im N/A brain_to_mpl brain N/A N/A N/A brain close N/A brain N/A N/A N/A ax axis off N/A N/A N/A N/A N/A ax get_xaxis set_visible False N/A N/A N/A N/A N/A ax get_yaxis set_visible False N/A N/A N/A ax imshow im N/A N/A N/A ax set_title N/A N/A {0} ({1} epochs) format kind N/A n_train 2 N/A stc_mean N/A N/A N/A stc data mean 0 N/A N/A N/A ax_dynamics plot N/A N/A stc times 1000.0 stc_mean label N/A N/A {0} ({1}) format method kind color color N/A stc_var N/A N/A N/A stc data std 0 N/A N/A N/A ax_dynamics fill_between N/A N/A stc times 1000.0 N/A stc_mean stc_var N/A stc_mean stc_var alpha 0.2 color color N/A N/A N/A ax_dynamics set_title N/A N/A {0} epochs format N/A n_train 2 N/A N/A N/A ax_dynamics set_xlabel Time (ms) N/A N/A N/A ax_dynamics set_ylabel Source Activation (dSPM) N/A N/A N/A ax_dynamics set_xlim N/A tmin 1000.0 N/A tmax 1000.0 N/A N/A N/A ax_dynamics set_ylim -3 3 N/A N/A N/A ax_dynamics legend loc upper left fontsize 10 N/A N/A N/A fig subplots_adjust hspace 0.4 left 0.03 right 0.98 wspace 0.07 N/A N/A N/A N/A fig canvas draw N/A N/A N/A fig show