User Tools

Site Tools


analysis:nsb2015:week6

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
Previous revision
analysis:nsb2015:week6 [2015/07/19 21:19]
mvdm
analysis:nsb2015:week6 [2018/07/07 10:19] (current)
Line 182: Line 182:
   * Whatever the coefficients returned, there is not a single peak as we would expect from the pure input signal: in fact there are two peaks.   * Whatever the coefficients returned, there is not a single peak as we would expect from the pure input signal: in fact there are two peaks.
  
-To understand this, recall ​from last week that the largest frequency that can be detected in a signal sampled at ''​Fs''​ is ''​Fs/​2'',​ the //Nyquist frequency//​. Thus, we would expect the frequency axis from ''​fft()''​ to go from 0 to ''​Fs/​2''​ at most. In addition, it turns out the Fourier transform is defined for //real// as well as for //complex// signals, and it returns spectra for both these components. Since we are only interested in real signals, we get a symmetric spectrum back (note that if we did not use ''​abs()''​ on the output of ''​fft()''​ we would get some imaginary components as well).+To understand this, recall that the largest frequency that can be detected in a signal sampled at ''​Fs''​ is ''​Fs/​2'',​ the //Nyquist frequency//​. Thus, we would expect the frequency axis from ''​fft()''​ to go from 0 to ''​Fs/​2''​ at most. In addition, it turns out the Fourier transform is defined for //real// as well as for //complex// signals, and it returns spectra for both these components. Since we are only interested in real signals, we get a symmetric spectrum back (note that if we did not use ''​abs()''​ on the output of ''​fft()''​ we would get some imaginary components as well).
  
 To construct a frequency axis that takes both these ideas into account, we can do: To construct a frequency axis that takes both these ideas into account, we can do:
Line 404: Line 404:
 ==== Pitfalls for real-world signals ==== ==== Pitfalls for real-world signals ====
  
-We are almost ready to apply these methods to some real data. However, we first need to be aware of an issue that often comes up with real data. ''​fft()''​ and tools that rely on it, such as the spectral estimators in the previous section, assume that the data is sampled at evenly spaced intervals. ​We know from the previous module that this is only approximately true for Neuralynx data: chunks of 512 samples are sampled at a regular interval (''​Fs = 2000''​) but the interval between chunks is slightly larger than within, such that the overall Fs is slightly smaller than 2000. Because this difference is tiny, it will not affect our spectral estimate much. However if the difference becomes large our spectrum will be wrong. For instance:+We are almost ready to apply these methods to some real data. However, we first need to be aware of an issue that often comes up with real data. ''​fft()''​ and tools that rely on it, such as the spectral estimators in the previous section, assume that the data is sampled at evenly spaced intervals. ​However, ​this is only approximately true for Neuralynx data: chunks of 512 samples are sampled at a regular interval (''​Fs = 2000''​) but the interval between chunks is slightly larger than within, such that the overall Fs is slightly smaller than 2000. Because this difference is tiny, it will not affect our spectral estimate much. However if the difference becomes large our spectrum will be wrong. For instance:
  
 <code matlab> <code matlab>
Line 459: Line 459:
 ==== Application to real data ==== ==== Application to real data ====
  
-Let's begin by loading a ventral striatal LFP signal, remembering to use our improved ''​LoadCSCi()''​ function which should be placed in your path if it isn't already (if you don't have this, ''​LoadCSC()''​ will also work):+Let's begin by loading a ventral striatal LFP signal:
  
 <code matlab> <code matlab>
Line 485: Line 485:
 </​code>​ </​code>​
  
-Looks good -- note the scale! Recall that the odd structure of the diffs is because of Neuralynx'​s 512-sample-per-block format. So, technically we don't have uniformly spaced samples, but it's close enough that we don't have to bother with interpolating.+The slightly ​odd structure of the diffs is because of Neuralynx'​s 512-sample-per-block format. So, technically we don't have uniformly spaced samples, but it's close enough that we don't have to bother with interpolating.
  
 Let's decimate to speed up subsequent processing: Let's decimate to speed up subsequent processing:
analysis/nsb2015/week6.1437355179.txt.gz ยท Last modified: 2018/07/07 10:19 (external edit)