Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Oct 24, 2024
1 parent d3673ba commit 5eee83f
Show file tree
Hide file tree
Showing 20 changed files with 464 additions and 478 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6610dc21
22c260d1
2 changes: 1 addition & 1 deletion exercises/ex2_erpComponents.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ <h1>Signal processing and analysis of human brain potentials (EEG) [Exercise 5]<
<p>The purpose of this assignment is to develop your ability to read and critically evaluate a journal article that uses ERP techniques to answer a research question. Specifically, you should be able to identify the research question and important elements of the research design, and explain how the ERP data help to answer this question. Don’t get bogged down with other details in the paper. Instead, use the assignment questions to guide your reading. Type your answers in the text field below each question. USE YOUR OWN WORDS to answer the questions.</p>
<section id="assignment" class="level2">
<h2 class="anchored" data-anchor-id="assignment">Assignment</h2>
<p>Read through the questions on this assignment, and then read the following article: Tanaka, J. W., &amp; Curran, T. (2001). A neural basis for expert object recognition. Psychol Sci, 12(1), 43–47. Find the paper here: https://doi.org/10.1111/1467-9280.00308 (maybe behind paywall) or here: http://psych.colorado.edu/~tcurran/Tanaka_Curran_2001.pdf</p>
<p>Read through the questions on this assignment, and then read the following article: Tanaka, J. W., &amp; Curran, T. (2001). A neural basis for expert object recognition. Psychol Sci, 12(1), 43–47. Find the paper <a href="https://doi.org/10.1111/1467-9280.00308">here</a> (maybe behind paywall) or <a href="https://pcl.sitehost.iu.edu/rgoldsto/perlearn/tanakacurran.pdf">here</a></p>
<ol type="1">
<li><p>In your own words, what was the research question?</p></li>
<li><p>Using an if/then statement, what was the hypothesis? The “if” part should relate to the theory, and the “then” part should relate to the expected ERP results.</p></li>
Expand Down
61 changes: 38 additions & 23 deletions exercises/ex3_filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ <h2 id="toc-title">On this page</h2>

<ul>
<li><a href="#simulate-a-simple-eeg-signal" id="toc-simulate-a-simple-eeg-signal" class="nav-link active" data-scroll-target="#simulate-a-simple-eeg-signal">Simulate a simple EEG signal</a></li>
<li><a href="#task" id="toc-task" class="nav-link" data-scroll-target="#task">Task</a></li>
<li><a href="#transform-to-fourier-space" id="toc-transform-to-fourier-space" class="nav-link" data-scroll-target="#transform-to-fourier-space">Transform to fourier space</a></li>
<li><a href="#a-simple-filter" id="toc-a-simple-filter" class="nav-link" data-scroll-target="#a-simple-filter">A simple filter</a></li>
<li><a href="#highpass-instead-of-lowpass" id="toc-highpass-instead-of-lowpass" class="nav-link" data-scroll-target="#highpass-instead-of-lowpass">Highpass instead of lowpass</a></li>
Expand Down Expand Up @@ -316,35 +315,23 @@ <h2 class="anchored" data-anchor-id="simulate-a-simple-eeg-signal">Simulate a si
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>x <span class="op">=</span> cos(<span class="dv">2</span><span class="op">*</span>pi<span class="op">*</span><span class="fl">0.5</span><span class="op">*</span>t) <span class="op">+</span> <span class="fl">0.2</span><span class="op">*</span>sin(<span class="dv">2</span><span class="op">*</span>pi<span class="op">*</span><span class="fl">2.5</span><span class="op">*</span>t<span class="op">+</span><span class="fl">0.1</span>) <span class="op">+</span> <span class="op">\</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> <span class="fl">0.2</span><span class="op">*</span>sin(<span class="dv">2</span><span class="op">*</span>pi<span class="op">*</span><span class="fl">15.3</span><span class="op">*</span>t) <span class="op">+</span> <span class="fl">0.1</span><span class="op">*</span>sin(<span class="dv">2</span><span class="op">*</span>pi<span class="op">*</span><span class="fl">16.7</span><span class="op">*</span>t <span class="op">+</span> <span class="fl">0.1</span>) <span class="op">+</span> <span class="op">\</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> <span class="fl">0.1</span><span class="op">*</span>sin(<span class="dv">2</span><span class="op">*</span>pi<span class="op">*</span><span class="fl">23.45</span><span class="op">*</span>t<span class="op">+</span><span class="fl">.8</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section>
<section id="task" class="level2">
<h2 class="anchored" data-anchor-id="task">Task</h2>
<p>Plot the signal against time.</p>
<p><strong>Task:</strong> Plot the signal against time.</p>
</section>
<section id="transform-to-fourier-space" class="level2">
<h2 class="anchored" data-anchor-id="transform-to-fourier-space">Transform to fourier space</h2>
<p>Next run the FFT algorithm. :::: callout-tip ## Task</p>
<p>plot the magnitude response (<span class="math inline">\(log10(abs(fft(x))))\)</span>). ::::</p>
</section>
<section id="a-simple-filter" class="level2">
<h2 class="anchored" data-anchor-id="a-simple-filter">A simple filter</h2>
<p>A very simple frequency filter is to set the unwanted amplitude of the fourier components to something close to zero. We have to be a tad careful not to remove the phase information though.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Your tasks are therefore
Task
</div>
</div>
<div class="callout-body-container callout-body">
<ul>
<li>split the complex fourier result into <em>angle</em> and <em>magnitude</em></li>
<li>set the respective magnitudes to zero (we start with a lowpass filter: <code>magnitude[30:370] = 0</code>)</li>
<li>combine angle and magnitude back to a complex fourier coefficient (<span class="math inline">\(m*e^{1j*ang}\)</span>)</li>
<li>apply the inverse FFT</li>
<li>plot the signal with what you started out</li>
<li>run the fourier analysis via <code>fft</code>.</li>
<li>plot the full log10-magnitude</li>
</ul>
</div>
</div>
Expand All @@ -358,7 +345,30 @@ <h2 class="anchored" data-anchor-id="a-simple-filter">A simple filter</h2>
</div>
</div>
<div class="callout-body-container callout-body">
<p>If you plot e.g.&nbsp;the magnitude you will notice it is mirrorsymmetric around the middle! This is because FFT is actually defined for complex signals. Because we only have real signals, practically half of the FFT is redundant. But this also means, all of our manual-filters need to take the mirror-symmetry into account.</p>
<p>If you plot e.g.&nbsp;the magnitude you will notice it is mirrorsymmetric around the middle! This is because FFT is actually defined for complex signals. Because we only have real signals, practically half of the FFT is redundant. But this also means, all of our manual-filters in the next steps need to take the mirror-symmetry into account. For this reason, typically a <code>rfft</code> function exists, returning only the real part.</p>
</div>
</div>
</section>
<section id="a-simple-filter" class="level2">
<h2 class="anchored" data-anchor-id="a-simple-filter">A simple filter</h2>
<p>A very simple frequency filter is to set the unwanted amplitude of the fourier components to something close to zero. We have to be a tad careful not to remove the phase information though.</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Your tasks are therefore
</div>
</div>
<div class="callout-body-container callout-body">
<ul>
<li>split the complex fourier result into <em>angle</em> and <em>magnitude</em></li>
<li>set the respective magnitudes to zero (we start with a lowpass filter: <code>magnitude[30:370] = 0</code>)</li>
<li>combine angle and magnitude back to a complex fourier coefficient (<span class="math inline">\(m*e^{1j*ang}\)</span>)</li>
<li>apply the inverse FFT</li>
<li>plot the signal with what you started out</li>
</ul>
</div>
</div>
</section>
Expand All @@ -380,6 +390,8 @@ <h2 class="anchored" data-anchor-id="highpass-instead-of-lowpass">Highpass inste
</section>
<section id="what-happens-to-the-frequency-and-time-response-if-we-add-artefacts" class="level2">
<h2 class="anchored" data-anchor-id="what-happens-to-the-frequency-and-time-response-if-we-add-artefacts">What happens to the frequency and time response if we add “artefacts”?</h2>
<p>Let’s see how the FFT reacts to steps and spikes. A step-function could look like this:</p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Dirac_distribution_CDF.svg/325px-Dirac_distribution_CDF.svg.png" class="img-fluid"></p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
Expand All @@ -390,13 +402,13 @@ <h2 class="anchored" data-anchor-id="what-happens-to-the-frequency-and-time-resp
</div>
</div>
<div class="callout-body-container callout-body">
<p>Add a DC-offset (a step-function) starting from <code>x[200:]</code> and investigate the fourier space. Filter it again (low or high pass) and transfer it back to the time domain and investigate the signal around the spike.</p>
<p>Add a DC-offset (a step-function) starting from <code>x[200:]</code> and investigate the fourier space. Filter it again (low or high pass) and transfer it back to the time domain and investigate the signal around the step.</p>
</div>
</div>
</section>
<section id="impulse-response-function" class="level2">
<h2 class="anchored" data-anchor-id="impulse-response-function">Impulse Response Function</h2>
<p>To get a bit deeper understanding of what is going on, have a look at the fourier transform of a new impulse signal (e.g.&nbsp;<code>1:400 =&gt; 0</code>. and <code>200 =&gt; 1</code>.).</p>
<p>To get a bit deeper understanding of what is going on, have a look at the fourier transform of a impulse signal (e.g.&nbsp;<code>1:400 =&gt; 0</code>. and <code>200 =&gt; 1</code>.).</p>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
Expand All @@ -407,8 +419,10 @@ <h2 class="anchored" data-anchor-id="impulse-response-function">Impulse Response
</div>
</div>
<div class="callout-body-container callout-body">
<p>What do you observe?</p>
<p>Why would we see ringing if we put most of the coefficients to 0?</p>
<ul>
<li>What do you observe?</li>
<li>Why did we see ringing in the previous filtered step-function, if when filtering we put coefficients to 0 - after all, we are not adding something?</li>
</ul>
</div>
</div>
</section>
Expand Down Expand Up @@ -441,7 +455,7 @@ <h2 class="anchored" data-anchor-id="filtering-eeg-data">Filtering EEG data</h2>
</div>
<div class="callout-body-container callout-body">
<ul>
<li>Choose the channel “Pz”, plot the channel (previous HW it was “Cz”)</li>
<li>Choose the channel “Pz”, plot the channel</li>
<li>Plot the fourier space using <code>raw.plot_psd()</code></li>
</ul>
</div>
Expand Down Expand Up @@ -473,6 +487,7 @@ <h2 class="anchored" data-anchor-id="filtering-eeg-data">Filtering EEG data</h2>
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>Bonus: comparing over-filtered ERPs</strong></p>
<p>If you want, you can compare the ERP with and without filtering. You can also use “invalid” filter settings - HP up to 2-5Hz, lowpass until 10-20Hz. I say invalid here, because usually with such ranges, you would filter out results that you are actually interested in.</p>
<p><strong>Bonus: Electrical Artefacts</strong></p>
<p>Instead of notch filtering 50/60Hz artefacts, one can also try to regress it out in smarter ways. A good tool for this is <em>Zap_Line</em> with a python implementation here: https://github.com/nbara/python-meegkit/. There are also several robust detrending methods, which could potentially replace highpass filters in the future. But more work needs to be invested to see how results compare. These methods are not (yet) common.</p>
Expand Down
Loading

0 comments on commit 5eee83f

Please sign in to comment.