This shows you the differences between two versions of the page.
|
tutorial:timefrequencyanalysis [2012/07/24 15:44] 192.87.10.82 [Morlet wavelets] bandwidth and duration |
tutorial:timefrequencyanalysis [2013/05/23 10:09] (current) 144.82.46.254 [Hanning taper, fixed window length] corrected typo |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| We will continue working on the [[tutorial:shared:dataset|dataset]] described in the preprocessing tutorials. Below we will repeat code to select the trials and preprocess the data as described in the first tutorials ([[tutorial:Preprocessing|trigger based trial selection]], [[tutorial:visual_artifact_rejection|visual artifact rejection]]). We assume that the reader already knows how to do the preprocessing in FieldTrip. | We will continue working on the [[tutorial:shared:dataset|dataset]] described in the preprocessing tutorials. Below we will repeat code to select the trials and preprocess the data as described in the first tutorials ([[tutorial:Preprocessing|trigger based trial selection]], [[tutorial:visual_artifact_rejection|visual artifact rejection]]). We assume that the reader already knows how to do the preprocessing in FieldTrip. | ||
| - | There is no information in this tutorial about how to compare conditions, how to grandaverage the results across subject or how to do statistical analysis on the time-frequency data. Some of these issues are covered in other tutorials (see Summary and suggested further reading). | + | There is no information in this tutorial about how to compare conditions, how to grandaverage the results across subject or how to do statistical analysis on the time-frequency data. Some of these issues are covered in other tutorials (see [[#Summary and suggested further reading]]). |
| ===== Background ===== | ===== Background ===== | ||
| Line 48: | Line 48: | ||
| We will here describe how to calculate time frequency representations using Hanning tapers. When choosing for a fixed window length procedure the frequency resolution is defined according to the length of the time window (delta T). The frequency resolution (delta f in figure 1) = 1/length of time window in sec (delta T in figure 1). Thus a 500 ms time window results in a 2 Hz frequency resolution (1/0.5 sec= 2 Hz) meaning that power can be calculated for 2 Hz, 4 Hz, 6 Hz etc. An integer number of cycles must fit in the time window. | We will here describe how to calculate time frequency representations using Hanning tapers. When choosing for a fixed window length procedure the frequency resolution is defined according to the length of the time window (delta T). The frequency resolution (delta f in figure 1) = 1/length of time window in sec (delta T in figure 1). Thus a 500 ms time window results in a 2 Hz frequency resolution (1/0.5 sec= 2 Hz) meaning that power can be calculated for 2 Hz, 4 Hz, 6 Hz etc. An integer number of cycles must fit in the time window. | ||
| - | **[[reference:ft_freqanalysis|ft_Freqanalysis]]** requires preprocessed data (see above), which is available from ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/timefrequencyanalysis/dataFIC.mat. | + | **[[reference:ft_freqanalysis|Ft_freqanalysis]]** requires preprocessed data (see above), which is available from ftp://ftp.fcdonders.nl/pub/fieldtrip/tutorial/timefrequencyanalysis/dataFIC.mat. |
| load dataFIC | load dataFIC | ||
| Line 109: | Line 109: | ||
| //Figure 3; Time-frequency representations calculated using **[[reference:ft_freqanalysis|ft_freqanalysis]]**. Plotting was done with **[[reference:ft_multiplotTFR|ft_multiplotTFR]]**// | //Figure 3; Time-frequency representations calculated using **[[reference:ft_freqanalysis|ft_freqanalysis]]**. Plotting was done with **[[reference:ft_multiplotTFR|ft_multiplotTFR]]**// | ||
| - | Note that by using the options cfg.baseline and cfg.baselinetype when calling plotting functions, baseline correction can be applied to the data. Baseline correction can also be applied directly by calling **[[reference:ft_freqbaseline|ft_freqbaseline]]**. | + | Note that by using the options cfg.baseline and cfg.baselinetype when calling plotting functions, baseline correction can be applied to the data. Baseline correction can also be applied directly by calling **[[reference:ft_freqbaseline|ft_freqbaseline]]**. You can combine the various visualisation options/functions interactively to explore your data. Currently, this is the default ploting behavior because the configuration option cfg.interactive='yes' is activated unless you explicitly select cfg.interactive='no' before calling **[[reference:ft_multiplotTFR|ft_multiplotTFR]]** to deactivate it. See also the [[tutorial:plotting|plotting tutorial]] for more details. |
| An interesting effect seems to be present in the TFR of sensor MRC15. To make a plot of a single channel use the function **[[reference:ft_singleplotTFR|ft_singleplotTFR]]**: | An interesting effect seems to be present in the TFR of sensor MRC15. To make a plot of a single channel use the function **[[reference:ft_singleplotTFR|ft_singleplotTFR]]**: | ||
| Line 115: | Line 115: | ||
| cfg = []; | cfg = []; | ||
| cfg.baseline = [-0.5 -0.1]; | cfg.baseline = [-0.5 -0.1]; | ||
| - | cfg.baselinetype = 'absolute'; | + | cfg.baselinetype = 'absolute'; |
| + | cfg.maskstyle = 'saturation'; | ||
| cfg.zlim = [-3e-27 3e-27]; | cfg.zlim = [-3e-27 3e-27]; | ||
| cfg.channel = 'MRC15'; | cfg.channel = 'MRC15'; | ||
| Line 140: | Line 141: | ||
| cfg.zlim = [-1.5e-27 1.5e-27]; | cfg.zlim = [-1.5e-27 1.5e-27]; | ||
| cfg.ylim = [15 20]; | cfg.ylim = [15 20]; | ||
| - | cfg.showlabels = 'markers'; | + | cfg.marker = 'on'; |
| figure | figure | ||
| ft_topoplotTFR(cfg, TFRhann); | ft_topoplotTFR(cfg, TFRhann); | ||
| Line 148: | Line 149: | ||
| //Figure 5; A topographic representation of the time-frequency representations (15 - 20 Hz, 0.9 - 1.3 s post stimulus) obtained using **[[reference:ft_topoplotTFR|ft_topoplotTFR]]**// | //Figure 5; A topographic representation of the time-frequency representations (15 - 20 Hz, 0.9 - 1.3 s post stimulus) obtained using **[[reference:ft_topoplotTFR|ft_topoplotTFR]]**// | ||
| - | |||
| - | |||
| - | You can combine the various visualisation options/functions to interactively explore the data. This is done by starting with **[[reference:ft_multiplotTFR|ft_multiplotTFR]]** and the option cfg.interactive='yes'. See also the [[tutorial:plotting|plotting tutorial]] for more details. | ||
| - | |||
| - | cfg = []; | ||
| - | cfg.baseline = [-0.5 -0.1]; | ||
| - | cfg.baselinetype = 'absolute'; | ||
| - | cfg.zlim = [-3e-27 3e-27]; | ||
| - | cfg.showlabels = 'yes'; | ||
| - | cfg.layout = 'CTF151.lay'; | ||
| - | cfg.interactive = 'yes'; % note this option | ||
| - | figure | ||
| - | ft_multiplotTFR(cfg, TFRhann); | ||
| - | |||
| - | (The figures resulting from the interactive plotting mode are not demonstrated in this tutorial.) | ||
| == Exercise 1 == | == Exercise 1 == | ||
| Line 203: | Line 189: | ||
| cfg = []; | cfg = []; | ||
| cfg.baseline = [-0.5 -0.1]; | cfg.baseline = [-0.5 -0.1]; | ||
| - | cfg.baselinetype = 'absolute'; | + | cfg.baselinetype = 'absolute'; |
| + | cfg.maskstyle = 'saturation'; | ||
| cfg.zlim = [-3e-27 3e-27]; | cfg.zlim = [-3e-27 3e-27]; | ||
| cfg.channel = 'MRC15'; | cfg.channel = 'MRC15'; | ||
| + | cfg.interactive = 'no'; | ||
| figure | figure | ||
| ft_singleplotTFR(cfg, TFRhann7); | ft_singleplotTFR(cfg, TFRhann7); | ||
| Line 215: | Line 203: | ||
| Note the boundary effects for lower frequencies (the white time frequency points in the plot). There is no power value calculated for these time frequency points. The power value is assigned to the middle time point in the time window. For example for 2 Hz the time window has a length of 3.5 sec (1/2 * 7 cycles = 3.5 sec), this does not fit in the 3 sec window that is preprocessed and therefore there is no data point here. For 5 Hz the window has a length of 1.4 sec (1/5 * 7 cycles = 1.4 sec). We preprocessed data between t = -1 sec and t = 2 sec so the first power value is assigned to t= -0.3 (since -1 + (0.5 * 1.4) = -0.3). Because of these boundary effects it is important to apply **[[reference:ft_freqanalysis |ft_freqanalysis ]]** to a larger time window to get all the time frequency points for your time window of interest. | Note the boundary effects for lower frequencies (the white time frequency points in the plot). There is no power value calculated for these time frequency points. The power value is assigned to the middle time point in the time window. For example for 2 Hz the time window has a length of 3.5 sec (1/2 * 7 cycles = 3.5 sec), this does not fit in the 3 sec window that is preprocessed and therefore there is no data point here. For 5 Hz the window has a length of 1.4 sec (1/5 * 7 cycles = 1.4 sec). We preprocessed data between t = -1 sec and t = 2 sec so the first power value is assigned to t= -0.3 (since -1 + (0.5 * 1.4) = -0.3). Because of these boundary effects it is important to apply **[[reference:ft_freqanalysis |ft_freqanalysis ]]** to a larger time window to get all the time frequency points for your time window of interest. | ||
| - | If you would like to learn more about plotting of time-frequency representations, read Visualization. | + | If you would like to learn more about plotting of time-frequency representations, please see the [[#Visualization]] section. |
| === Exercise 3 === | === Exercise 3 === | ||
| Line 253: | Line 241: | ||
| ==== Multitapers ===== | ==== Multitapers ===== | ||
| - | Multitapers are typically used in order to achieve better control over the frequency smoothing. More tapers for a given time window will result in greater smoothing. High frequency smoothing has been shown to be particularly advantageous when dealing with electrophysiological brain signals above 30 Hz. Oscillatory gamma activity (30-100 Hz) is quite broad band and thus analysis of such signals benefit from multitapering. For signals lower than 30 Hz it is recommend to use only a single taper, e.g. a Hanning taper as shown above (beware that in the example below multitapers are used to analyze low frequencies because there are no effects in the gamma band in this dataset). | + | Multitapers are typically used in order to achieve better control over the frequency smoothing. More tapers for a given time window will result in greater smoothing. High frequency smoothing has been shown to be particularly advantageous when dealing with electrophysiological brain signals above 30 Hz. Oscillatory gamma activity (30-100 Hz) is quite broad band and thus analysis of such signals benefit from multitapering. For signals lower than 30 Hz it is recommend to use only a single taper, e.g. a Hamming taper as shown above (beware that in the example below multitapers are used to analyze low frequencies because there are no effects in the gamma band in this dataset). |
| Time-frequency analysis based on multitapers can be performed by the function **[[reference:ft_freqanalysis|ft_freqanalysis]]**. The function uses a sliding time window for which the power is calculated for a given frequency. Prior to calculating the power by discrete Fourier transformations the data are ‘tapered’. Several orthogonal tapers might be used for each time window. The power is calculated for each tapered data segment and then combined. In the example below we apply a time window which gradually becomes shorter for higher frequencies (similar to wavelet techniques). The arguments for the chosen parameters are as follows | Time-frequency analysis based on multitapers can be performed by the function **[[reference:ft_freqanalysis|ft_freqanalysis]]**. The function uses a sliding time window for which the power is calculated for a given frequency. Prior to calculating the power by discrete Fourier transformations the data are ‘tapered’. Several orthogonal tapers might be used for each time window. The power is calculated for each tapered data segment and then combined. In the example below we apply a time window which gradually becomes shorter for higher frequencies (similar to wavelet techniques). The arguments for the chosen parameters are as follows | ||
| Line 302: | Line 290: | ||
| //Figure 8; Time-frequency representations of power calculated using multitapers.// | //Figure 8; Time-frequency representations of power calculated using multitapers.// | ||
| - | If you would like to learn more about plotting of time-frequency representations, read Visualization. | + | If you would like to learn more about plotting of time-frequency representations, please see the [[#Visualization]] section. |
| ===== Time-frequency analysis IV. ===== | ===== Time-frequency analysis IV. ===== | ||
| Line 337: | Line 325: | ||
| //Figure 9; Time-frequency representations of power calculated using Morlet wavelets.// | //Figure 9; Time-frequency representations of power calculated using Morlet wavelets.// | ||
| - | If you would like to learn more about plotting of time-frequency representations, read the Visualization part of this tutorial. | + | If you would like to learn more about plotting of time-frequency representations, please see [[#Visualization]]. |
| ===== Summary and suggested further reading ===== | ===== Summary and suggested further reading ===== | ||
| Line 346: | Line 334: | ||
| ----- | ----- | ||
| - | This tutorial was last tested with version 20120612 of FieldTrip by Jan-Mathijs, using Matlab 2011b on a 64-bit MacOS platform. | + | This tutorial was last tested by Robert with version 20130305 of FieldTrip using Matlab 2011b on a 64-bit OS X platform. |
Share this page: