def test_plot_topo_tfr(): """Test plotting of TFR """ # Make a fake dataset to plot n_freqs = 11 con = np.random.randn(n_chan, n_freqs, len(epochs.times)) freqs = np.arange(n_freqs) # Show topography of connectivity from seed plot_topo_tfr(epochs, con, freqs, layout)
# Use 'MEG 2343' as seed seed_ch = 'MEG 2343' picks_ch_names = [raw.ch_names[i] for i in picks] # Create seed-target indices for connectivity computation seed = picks_ch_names.index(seed_ch) targets = np.arange(len(picks)) indices = seed_target_indices(seed, targets) # Define wavelet frequencies and number of cycles cwt_frequencies = np.arange(7, 30, 2) cwt_n_cycles = cwt_frequencies / 7. # Run the connectivity analysis using 2 parallel jobs sfreq = raw.info['sfreq'] # the sampling frequency con, freqs, times, _, _ = spectral_connectivity(epochs, indices=indices, method='wpli2_debiased', mode='cwt_morlet', sfreq=sfreq, cwt_frequencies=cwt_frequencies, cwt_n_cycles=cwt_n_cycles, n_jobs=2) # Mark the seed channel with a value of 1.0, so we can see it in the plot con[np.where(indices[1] == seed)] = 1.0 # Show topography of connectivity from seed import matplotlib.pyplot as plt title = 'WPLI2 - Visual - Seed %s' % seed_ch layout = mne.find_layout(epochs.info, 'meg') # use full layout plot_topo_tfr(epochs, con, freqs, layout=layout, title=title) plt.show()
# Create seed-target indices for connectivity computation seed = picks_ch_names.index(seed_ch) targets = np.arange(len(picks)) indices = seed_target_indices(seed, targets) # Define wavelet frequencies and number of cycles cwt_frequencies = np.arange(7, 30, 2) cwt_n_cycles = cwt_frequencies / 7. # Run the connectivity analysis using 2 parallel jobs sfreq = raw.info['sfreq'] # the sampling frequency con, freqs, times, _, _ = spectral_connectivity( epochs, indices=indices, method='wpli2_debiased', mode='cwt_morlet', sfreq=sfreq, cwt_frequencies=cwt_frequencies, cwt_n_cycles=cwt_n_cycles, n_jobs=2) # Mark the seed channel with a value of 1.0, so we can see it in the plot con[np.where(indices[1] == seed)] = 1.0 # Show topography of connectivity from seed import matplotlib.pyplot as plt layout = read_layout('Vectorview-all') title = 'WPLI2 - Visual - Seed %s' % seed_ch plot_topo_tfr(epochs, con, freqs, layout, title=title) plt.show()