<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import mne <EOL> from mne . datasets import sample <EOL> from mne . minimum_norm import ( apply_inverse , apply_inverse_epochs , <EOL> read_inverse_operator ) <EOL> from mne . connectivity import seed_target_indices , spectral_connectivity <EOL> print ( __doc__ ) <EOL> data_path = sample . data_path ( ) <EOL> subjects_dir = data_path + '<STR_LIT>' <EOL> fname_inv = data_path + '<STR_LIT>' <EOL> fname_raw = data_path + '<STR_LIT>' <EOL> fname_event = data_path + '<STR_LIT>' <EOL> label_name_lh = '<STR_LIT>' <EOL> fname_label_lh = data_path + '<STR_LIT>' % label_name_lh <EOL> event_id , tmin , tmax = <NUM_LIT:1> , - <NUM_LIT> , <NUM_LIT:0.5> <EOL> method = "<STR_LIT>" <EOL> inverse_operator = read_inverse_operator ( fname_inv ) <EOL> label_lh = mne . read_label ( fname_label_lh ) <EOL> raw = mne . io . read_raw_fif ( fname_raw ) <EOL> events = mne . read_events ( fname_event ) <EOL> raw . info [ '<STR_LIT>' ] += [ '<STR_LIT>' ] <EOL> picks = mne . pick_types ( raw . info , meg = True , eeg = False , stim = False , eog = True , <EOL> exclude = '<STR_LIT>' ) <EOL> epochs = mne . Epochs ( raw , events , event_id , tmin , tmax , picks = picks , <EOL> baseline = ( None , <NUM_LIT:0> ) , reject = dict ( mag = <NUM_LIT> , grad = <NUM_LIT> , <EOL> eog = <NUM_LIT> ) ) <EOL> snr = <NUM_LIT> <EOL> lambda2 = <NUM_LIT:1.0> / snr ** <NUM_LIT:2> <EOL> evoked = epochs . average ( ) <EOL> stc = apply_inverse ( evoked , inverse_operator , lambda2 , method , <EOL> pick_ori = "<STR_LIT>" ) <EOL> stc_label = stc . in_label ( label_lh ) <EOL> src_pow = np . sum ( stc_label . data ** <NUM_LIT:2> , axis = <NUM_LIT:1> ) <EOL> seed_vertno = stc_label . vertices [ <NUM_LIT:0> ] [ np . argmax ( src_pow ) ] <EOL> seed_idx = np . searchsorted ( stc . vertices [ <NUM_LIT:0> ] , seed_vertno ) <EOL> n_sources = stc . data . shape [ <NUM_LIT:0> ] <EOL> indices = seed_target_indices ( [ seed_idx ] , np . arange ( n_sources ) ) <EOL> snr = <NUM_LIT:1.0> <EOL> lambda2 = <NUM_LIT:1.0> / snr ** <NUM_LIT:2> <EOL> stcs = apply_inverse_epochs ( epochs , inverse_operator , lambda2 , method , <EOL> pick_ori = "<STR_LIT>" , return_generator = True ) <EOL> fmin = ( <NUM_LIT> , <NUM_LIT> ) <EOL> fmax = ( <NUM_LIT> , <NUM_LIT> ) <EOL> sfreq = raw . info [ '<STR_LIT>' ] <EOL> coh , freqs , times , n_epochs , n_tapers = spectral_connectivity ( <EOL> stcs , method = '<STR_LIT>' , mode = '<STR_LIT>' , indices = indices , <EOL> sfreq = sfreq , fmin = fmin , fmax = fmax , faverage = True , n_jobs = <NUM_LIT:1> ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( freqs [ <NUM_LIT:0> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( freqs [ <NUM_LIT:1> ] ) <EOL> tmin = np . mean ( freqs [ <NUM_LIT:0> ] ) <EOL> tstep = np . mean ( freqs [ <NUM_LIT:1> ] ) - tmin <EOL> coh_stc = mne . SourceEstimate ( coh , vertices = stc . vertices , tmin = <NUM_LIT> * tmin , <EOL> tstep = <NUM_LIT> * tstep , subject = '<STR_LIT>' ) <EOL> brain = coh_stc . plot ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> time_label = '<STR_LIT>' , <EOL> subjects_dir = subjects_dir , <EOL> clim = dict ( kind = '<STR_LIT:value>' , lims = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) ) <EOL> brain . show_view ( '<STR_LIT>' ) </s>
