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:combineplanar_pipelineorder [2018/10/21 15:20]
42.49.180.224 old revision restored (2017/08/17 11:21)
example:combineplanar_pipelineorder [2018/10/01 10:31] (current)
131.174.46.108
Line 1: Line 1:
-{{tag>example planar gradient combineplanar}}+{{tag>example planar gradient combineplanar}}
  
 ====== The correct pipeline order for combining planar MEG channels ====== ====== The correct pipeline order for combining planar MEG channels ======
Line 14: Line 14:
 The following code creates a single dipole that projects brain activity on posterior sensors. We simulate an alpha component (10Hz) whose power decreases after a hypothetical visual stimulus delivery. The signal itself is not very important (you can design your own). The following code creates a single dipole that projects brain activity on posterior sensors. We simulate an alpha component (10Hz) whose power decreases after a hypothetical visual stimulus delivery. The signal itself is not very important (you can design your own).
  
-&lt;code&gt;+<code>
 grad275 = ft_read_sens('​ctf275.mat'​);​ grad275 = ft_read_sens('​ctf275.mat'​);​
  
Line 44: Line 44:
 cfg.grad ​   = grad275; cfg.grad ​   = grad275;
 data_axial ​ = ft_dipolesimulation(cfg);​ data_axial ​ = ft_dipolesimulation(cfg);​
-&lt;/code&gt;+</code>
  
 ===== Time-Frequency analysis ===== ===== Time-Frequency analysis =====
Line 50: Line 50:
 But first, it's important to remind the logic behind the induced Time-Frequency Representation (TFR). What the induced TFR archives is the computation of the power estimates (non-linear transformation) for each single trial. As a consequence,​ the grand-mean (single-trials) of the induced TFR will add phase-locked PLUS non-phase-locked (time jittered) components. This is fundamentally different from the evoked TFR: first single-trials are averaged and then a TFR is computed. With the latter approach, non-phase-locked components wont be efficiently added because they'​ll average out. More info in [[http://​www.ncbi.nlm.nih.gov/​pubmed/​8753885| Tallon-Baudry et al 1996 J Neurosci]] But first, it's important to remind the logic behind the induced Time-Frequency Representation (TFR). What the induced TFR archives is the computation of the power estimates (non-linear transformation) for each single trial. As a consequence,​ the grand-mean (single-trials) of the induced TFR will add phase-locked PLUS non-phase-locked (time jittered) components. This is fundamentally different from the evoked TFR: first single-trials are averaged and then a TFR is computed. With the latter approach, non-phase-locked components wont be efficiently added because they'​ll average out. More info in [[http://​www.ncbi.nlm.nih.gov/​pubmed/​8753885| Tallon-Baudry et al 1996 J Neurosci]]
    
-&lt;code&gt;+<code>
 %% synthetic planar computation %% synthetic planar computation
 cfg              = []; cfg              = [];
Line 60: Line 60:
 cfg.neighbours ​  = ft_prepare_neighbours(cfg,​ data_axial);​ cfg.neighbours ​  = ft_prepare_neighbours(cfg,​ data_axial);​
 data_planar ​     = ft_megplanar(cfg,​data_axial);​ data_planar ​     = ft_megplanar(cfg,​data_axial);​
-&lt;/code&gt;+</code>
  
 With the ft_megplanar '​sincos'​ method, the vertical and horizontal components of each channel contain the negative and the positive parts of the signal. However, ft_combineplanar cfg.combinemethod = '​sum'​ for freq datatype, sums the power of the vertical and the horizontal components. With the ft_megplanar '​sincos'​ method, the vertical and horizontal components of each channel contain the negative and the positive parts of the signal. However, ft_combineplanar cfg.combinemethod = '​sum'​ for freq datatype, sums the power of the vertical and the horizontal components.
  
-&lt;code&gt;+<code>
 %% time-frequency analysis on axial and synthetic planar data %% time-frequency analysis on axial and synthetic planar data
 cfg            = []; cfg            = [];
Line 81: Line 81:
 %% average the axial representation to compare later %% average the axial representation to compare later
 freq_axial_avg = ft_freqdescriptives([],​freq_axial);​ freq_axial_avg = ft_freqdescriptives([],​freq_axial);​
-&lt;/code&gt;+</code>
  
 Now let's test the influence of pipeline order on the espected value Now let's test the influence of pipeline order on the espected value
Line 87: Line 87:
 A) Combine planar for each single trial and then average A) Combine planar for each single trial and then average
  
-&lt;code&gt;+<code>
 cfg               = []; cfg               = [];
 cfg.combinemethod = '​sum';​ cfg.combinemethod = '​sum';​
Line 93: Line 93:
  
 freq_combined_avg1 = ft_freqdescriptives([],​freq_combined);​ freq_combined_avg1 = ft_freqdescriptives([],​freq_combined);​
-&lt;/code&gt;+</code>
  
 The other way: The other way:
Line 99: Line 99:
 B) Average single trials planar data (vertical and horizontal components) and then combine planar B) Average single trials planar data (vertical and horizontal components) and then combine planar
  
-&lt;code&gt;+<code>
 freq_planar_avg = ft_freqdescriptives([],​freq_planar);​ freq_planar_avg = ft_freqdescriptives([],​freq_planar);​
  
Line 105: Line 105:
 cfg.combinemethod ​ = '​sum';​ cfg.combinemethod ​ = '​sum';​
 freq_combined_avg2 = ft_combineplanar(cfg,​freq_planar_avg);​ freq_combined_avg2 = ft_combineplanar(cfg,​freq_planar_avg);​
-&lt;/code&gt;+</code>
  
 Let's plot the results and see if there'​s a difference: Let's plot the results and see if there'​s a difference:
-&lt;code&gt;+<code>
 cfg         = []; cfg         = [];
 cfg.layout ​ = '​CTF275.lay';​ cfg.layout ​ = '​CTF275.lay';​
Line 127: Line 127:
 subplot(324);​ft_singleplotTFR(cfg,​ freq_combined_avg1);​title('​combined-then-average'​);​colorbar;​ subplot(324);​ft_singleplotTFR(cfg,​ freq_combined_avg1);​title('​combined-then-average'​);​colorbar;​
 subplot(326);​ft_singleplotTFR(cfg,​ freq_combined_avg2);​title('​average-then-combined'​);​colorbar;​ subplot(326);​ft_singleplotTFR(cfg,​ freq_combined_avg2);​title('​average-then-combined'​);​colorbar;​
-&lt;/code&gt;+</code>
  
 {{:​example:​example:​tfr.png?​700|}} {{:​example:​example:​tfr.png?​700|}}
  
-We can see that the second and the third row indicates that the other of the ft_combineplanar does not influence the power output (same topo and power scale). This is because with the induced TFR each single trial is squared (power estimate) and ft_combineplanar cfg.combinemethod='​sum'​ on freq datatype [[http://​mathworld.wolfram.com/​VectorAddition.html|sums]] the vertical and the horizontal components. As the single trial estimates are positive (power estimates), the order of the operation does not influence the output. You can now guess whether the same logic is going to hold for the Event-Related Fields.+We can see that the second and the third row indicates that the order of the ft_combineplanar does not influence the power output (same topo and power scale). This is because with the induced TFR each single trial is squared (power estimate) and ft_combineplanar cfg.combinemethod='​sum'​ on freq datatype [[http://​mathworld.wolfram.com/​VectorAddition.html|sums]] the vertical and the horizontal components. As the single trial estimates are positive (power estimates), the order of the operation does not influence the output. You can now guess whether the same logic is going to hold for the Event-Related Fields.
  
 ===== Event-Related Fields ===== ===== Event-Related Fields =====
Line 138: Line 138:
 A) Combine planar for each single trial and then average A) Combine planar for each single trial and then average
  
-&lt;code&gt;+<code>
 cfg               = []; cfg               = [];
 cfg.combinemethod = '​sum';​ cfg.combinemethod = '​sum';​
Line 144: Line 144:
  
 data_combined_avg1 = ft_timelockanalysis([],​data_combined);​ data_combined_avg1 = ft_timelockanalysis([],​data_combined);​
-&lt;/code&gt;+</code>
  
 B) Average axial single trials, compute the planar gradient (vertical and horizontal components) and then combine it: B) Average axial single trials, compute the planar gradient (vertical and horizontal components) and then combine it:
  
-&lt;code&gt;+<code>
 data_axial_avg = ft_timelockanalysis([],​data_axial);​ %% this is an Axial ERF data_axial_avg = ft_timelockanalysis([],​data_axial);​ %% this is an Axial ERF
  
Line 163: Line 163:
 cfg.combinemethod ​ = '​sum';​ cfg.combinemethod ​ = '​sum';​
 data_combined_avg2 = ft_combineplanar(cfg,​data_planar_avg);​ data_combined_avg2 = ft_combineplanar(cfg,​data_planar_avg);​
-&lt;/code&gt;+</code>
  
-But as with the '​sincos'​ planar method the vertical and horizontal components preserve the positive and negative parts of the signal (it's still not squared -&​gt; ​this is done in ft_combineplanar):​+But as with the '​sincos'​ planar method the vertical and horizontal components preserve the positive and negative parts of the signal (it's still not squared -this is done in ft_combineplanar):​
  
 C) Average planar (vertical and horizontal components) single trials and then combine C) Average planar (vertical and horizontal components) single trials and then combine
  
-&lt;code&gt;+<code>
 data_planar_avg = []; data_planar_avg = [];
 data_planar_avg = ft_timelockanalysis([],​data_planar);​ data_planar_avg = ft_timelockanalysis([],​data_planar);​
Line 176: Line 176:
 cfg.combinemethod ​ = '​sum';​ cfg.combinemethod ​ = '​sum';​
 data_combined_avg3 = ft_combineplanar(cfg,​data_planar_avg);​ data_combined_avg3 = ft_combineplanar(cfg,​data_planar_avg);​
-&lt;/code&gt;+</code>
  
 Let's visualize and compare the results: Let's visualize and compare the results:
  
-&lt;code&gt;+<code>
 cfg         = []; cfg         = [];
 cfg.layout ​ = '​CTF275.lay';​ cfg.layout ​ = '​CTF275.lay';​
Line 200: Line 200:
 subplot(426);​ft_singleplotER(cfg,​ data_combined_avg2);​title('​average axial then planar+combined'​);​ subplot(426);​ft_singleplotER(cfg,​ data_combined_avg2);​title('​average axial then planar+combined'​);​
 subplot(428);​ft_singleplotER(cfg,​ data_combined_avg3);​title('​average planar then combined'​);​ subplot(428);​ft_singleplotER(cfg,​ data_combined_avg3);​title('​average planar then combined'​);​
-&lt;/code&gt;+</code>
  
 {{:​example:​example:​erf.png?​700|}} {{:​example:​example:​erf.png?​700|}}
  
 We can see that the second row (ft_combineplanar single trials and then average single trials) it's very different (and way higher on amplitude) than the third and fourth rows. It's very difficult to appreciate the alpha desynchronization effect (compare it with the axial representation,​ first row). This is because the ft_combineplanar cfg.combinemethod='​sum'​ for raw and timelock data, squares the vertical and the horizontal planar components (non-linear transformation). Then, as ERF is a linear transformation (mean), the order of the non-linear transformation is going to influence the output. You can also see that if the average is computed on the axial and the planar level (both data representations preserve the positive and negatives parts of the signal), and then we combine the planar, the output is almost identical in time and space (topographies). We can see that the second row (ft_combineplanar single trials and then average single trials) it's very different (and way higher on amplitude) than the third and fourth rows. It's very difficult to appreciate the alpha desynchronization effect (compare it with the axial representation,​ first row). This is because the ft_combineplanar cfg.combinemethod='​sum'​ for raw and timelock data, squares the vertical and the horizontal planar components (non-linear transformation). Then, as ERF is a linear transformation (mean), the order of the non-linear transformation is going to influence the output. You can also see that if the average is computed on the axial and the planar level (both data representations preserve the positive and negatives parts of the signal), and then we combine the planar, the output is almost identical in time and space (topographies).