Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
example:coherence_snr [2018/10/21 15:06]
42.49.180.224 [Effect of SNR on Coherence]
example:coherence_snr [2017/08/17 11:21] (current)
127.0.0.1 external edit
Line 5: Line 5:
 This example script uses simulated signals to demonstrate the effect of the signal to noise ratio (SNR) on the coherence estimate. Two datasets are simulated that have the same underlying signal, but that have different amounts of noise. ​ This example script uses simulated signals to demonstrate the effect of the signal to noise ratio (SNR) on the coherence estimate. Two datasets are simulated that have the same underlying signal, but that have different amounts of noise. ​
  
-&lt;note important&gt;+<note important>
 Note that in this example we are changing the noise. We could also have kept the noise constant and have varied the amplitude of the signal. The results of the simulated ​ would not be different. Note that in this example we are changing the noise. We could also have kept the noise constant and have varied the amplitude of the signal. The results of the simulated ​ would not be different.
-&lt;/note&gt;+</note>
  
 Specify the parameters of the two datasets. Specify the parameters of the two datasets.
  
-&lt;code&gt;+<code>
 fsample ​  = 1000; fsample ​  = 1000;
 fsignal ​  = 10; fsignal ​  = 10;
Line 33: Line 33:
 snr2 = 0.060; snr2 = 0.060;
  
-&lt;/code&gt;+</code>
  
 Compute two simulated datasets, each with the same channels. Compute two simulated datasets, each with the same channels.
  
-&lt;code&gt;+<code>
  
 data1 = []; data1 = [];
Line 65: Line 65:
 subplot(2,​2,​3);​ plot(data2.time{1},​ data2.trial{1}(1,:​));​ title(sprintf('​dataset 2, channel %s', data2.label{1}));​ subplot(2,​2,​3);​ plot(data2.time{1},​ data2.trial{1}(1,:​));​ title(sprintf('​dataset 2, channel %s', data2.label{1}));​
 subplot(2,​2,​4);​ plot(data2.time{1},​ data2.trial{1}(2,:​));​ title(sprintf('​dataset 2, channel %s', data2.label{2}));​ subplot(2,​2,​4);​ plot(data2.time{1},​ data2.trial{1}(2,:​));​ title(sprintf('​dataset 2, channel %s', data2.label{2}));​
-&lt;/code&gt;+</code>
  
 {{:​example:​example_coherence_snr_1.png?​500|}} {{:​example:​example_coherence_snr_1.png?​500|}}
Line 71: Line 71:
 Next we compute the spectral decomposition of the raw data and subsequently compute the coherence with **[[:​reference:​ft_connectivityanalysis]]**. Note that for coherence (or other measures of phase synchrony) we need to specify either '​powandcsd'​ or '​fourier'​ as cfg.output to **[[:​reference:​ft_freqanalysis]]**. Next we compute the spectral decomposition of the raw data and subsequently compute the coherence with **[[:​reference:​ft_connectivityanalysis]]**. Note that for coherence (or other measures of phase synchrony) we need to specify either '​powandcsd'​ or '​fourier'​ as cfg.output to **[[:​reference:​ft_freqanalysis]]**.
  
-&lt;code&gt;+<code>
 cfg = []; cfg = [];
 cfg.method = '​mtmfft';​ cfg.method = '​mtmfft';​
Line 90: Line 90:
 plot(conn2.freq,​ conn2.cohspctrm,​ '​r'​);​ plot(conn2.freq,​ conn2.cohspctrm,​ '​r'​);​
 legend({sprintf('​snr = %f', snr1), sprintf('​snr = %f', snr2)}); legend({sprintf('​snr = %f', snr1), sprintf('​snr = %f', snr2)});
-&lt;/code&gt;+</code>
  
 {{:​example:​example_coherence_snr_2.png?​500|}} {{:​example:​example_coherence_snr_2.png?​500|}}
  
 Plotting the coherence for the two datasets is easy, as there are only two channels and therefore one estimate of coherence (as function of frequency) per dataset. For more realistic numbers of channels you may want to look at **[[:​reference:​ft_connectivityplot]]** and **[[:​reference:​ ft_multiplotCC]]**. Plotting the coherence for the two datasets is easy, as there are only two channels and therefore one estimate of coherence (as function of frequency) per dataset. For more realistic numbers of channels you may want to look at **[[:​reference:​ft_connectivityplot]]** and **[[:​reference:​ ft_multiplotCC]]**.
 +
 ===== Exercise 1 ===== ===== Exercise 1 =====
  
Line 110: Line 111:
  
 You should change the code such that the noise amplitude is constant, but that the signal amplitude depends on the SNR ratio. You should change the code such that the noise amplitude is constant, but that the signal amplitude depends on the SNR ratio.
 + 
 +
 +
 +
 +