Kubke Lab:Research/ABR/Notebook/2013/10/29

From OpenWetWare

< Kubke Lab:Research | ABR | Notebook | 2013 | 10(Difference between revisions)
Jump to: navigation, search
(Autocreate 2013/10/29 Entry for Kubke_Lab:Research/ABR/Notebook)
Current revision (21:33, 28 October 2013) (view source)
(Feedback from Andy)
 
(6 intermediate revisions not shown.)
Line 6: Line 6:
| colspan="2"|
| colspan="2"|
<!-- ##### DO NOT edit above this line unless you know what you are doing. ##### -->
<!-- ##### DO NOT edit above this line unless you know what you are doing. ##### -->
 +
 +
__TOC__
 +
=General Entries=
=General Entries=
-
* Insert content here...
+
* Played around with filter() and butter() in library.signal [[User:M Fabiana Kubke|MF Kubke]] 20:11, 28 October 2013 (EDT)
 +
 
 +
== Feedback from Andy ==
 +
 
 +
* Filter: Higher order is sharper cutoff. A sharp butterworth would be a 5th or 6th order. I wouldn't use any higher.
 +
 
 +
* Try an fft to see where the low pass cutoff should be. If the filter order is too high you get ringing. [ see http://t.co/QfrGaDjvj2 ]
 +
 
 +
* entered wrong sampling rate - sampling rate is actually 50 kHz - need to recalculate the filters based on that. They are off by a factor of 10, so what says lowpassed at 100 is actually at 1k.
 +
 
=Personal Entries=
=Personal Entries=
==Fabiana==
==Fabiana==
-
*Enter content here
+
* File 2013-10-29-MFK.Rmd
 +
 
 +
<!-- saved from url=(0014)about:internet -->
 +
<html>
 +
 
 +
<body>
 +
<h1>Trying to apply a low pass filter to ABR data </h1>
 +
 
 +
<p>Using package signal</p>
 +
 
 +
<pre><code class="r">install.packages(&quot;signal&quot;)
 +
</code></pre>
 +
 
 +
<pre><code>## Error: trying to use CRAN without setting a mirror
 +
</code></pre>
 +
 
 +
<pre><code class="r">library(signal)
 +
</code></pre>
 +
 
 +
<pre><code>## Warning: package &#39;signal&#39; was built under R version 3.0.2
 +
</code></pre>
 +
 
 +
<pre><code>## Loading required package: MASS
 +
##
 +
## Attaching package: &#39;signal&#39;
 +
##
 +
## The following object is masked from &#39;package:stats&#39;:
 +
##
 +
##    filter, poly
 +
</code></pre>
 +
 
 +
<p>Read test file</p>
 +
 
 +
<pre><code class="r">dir()
 +
</code></pre>
 +
 
 +
<pre><code>##  [1] &quot;2013-10-27-MFK.Rmd&quot;  &quot;2013-10-27.html&quot;    &quot;2013-10-27.R&quot;     
 +
##  [4] &quot;2013-10-27.txt&quot;      &quot;2013-10-28-MFK.html&quot; &quot;2013-10-28-MFK.md&quot; 
 +
##  [7] &quot;2013-10-28-MFK.Rmd&quot;  &quot;2013-10-29-MFK.Rmd&quot;  &quot;Copy189L0A.ABR&quot;   
 +
## [10] &quot;Copy224l0a.txt&quot;      &quot;Copy233L0B.ABR.log&quot;  &quot;Copy233L0B.ABR.txt&quot;
 +
## [13] &quot;figure&quot;              &quot;knitr-testr.html&quot;    &quot;knitr-testr.md&quot;   
 +
## [16] &quot;knitr-testr.Rmd&quot;    &quot;kntR2.html&quot;          &quot;kntR2.md&quot;         
 +
## [19] &quot;kntR2.Rmd&quot;          &quot;my first knitr.html&quot; &quot;my first knitr.md&quot; 
 +
## [22] &quot;my first knitr.Rmd&quot;  &quot;mydata_new&quot;          &quot;mydata_new.txt&quot;   
 +
## [25] &quot;readrawabr.R&quot;        &quot;Sandbox1.R&quot;          &quot;Sandbox1.txt&quot;     
 +
## [28] &quot;signal.pdf&quot;          &quot;texput.log&quot;
 +
</code></pre>
 +
 
 +
<pre><code class="r">mydata &lt;- read.table(&quot;Copy233L0B.ABR.txt&quot;, header = T)
 +
head(mydata)  #passed test
 +
</code></pre>
 +
 
 +
<pre><code>##  msec left right spont  bin
 +
## 1 0.00 1000  1000  1000 1000
 +
## 2 0.02 1000  1000  1000 1000
 +
## 3 0.04 1000  1000  1000 1000
 +
## 4 0.06 1000  1000  1000 1000
 +
## 5 0.08 1000  1000  1000 1000
 +
## 6 0.10 1000  1000  1000 1000
 +
</code></pre>
 +
 
 +
<pre><code class="r">write.table(mydata, &quot;mydata_new.txt&quot;)
 +
mydata_new &lt;- read.table(&quot;mydata_new&quot;, header = T)
 +
head(mydata_new)  #passed test
 +
</code></pre>
 +
 
 +
<pre><code>##  msec left right spont  bin
 +
## 1 0.00 1000  1000  1000 1000
 +
## 2 0.02 1000  1000  1000 1000
 +
## 3 0.04 1000  1000  1000 1000
 +
## 4 0.06 1000  1000  1000 1000
 +
## 5 0.08 1000  1000  1000 1000
 +
## 6 0.10 1000  1000  1000 1000
 +
</code></pre>
 +
 
 +
<pre><code class="r">mydata_new$bincomp[1:1000] &lt;- (mydata_new$bin[1:1000] - (mydata_new$left[1:1000] +
 +
    mydata_new$right[1:1000]))
 +
head(mydata_new)
 +
</code></pre>
 +
 
 +
<pre><code>##  msec left right spont  bin bincomp
 +
## 1 0.00 1000  1000  1000 1000  -1000
 +
## 2 0.02 1000  1000  1000 1000  -1000
 +
## 3 0.04 1000  1000  1000 1000  -1000
 +
## 4 0.06 1000  1000  1000 1000  -1000
 +
## 5 0.08 1000  1000  1000 1000  -1000
 +
## 6 0.10 1000  1000  1000 1000  -1000
 +
</code></pre>
 +
 
 +
<pre><code class="r">write.table(mydata_new, &quot;mydata_new.txt&quot;)  #passed test
 +
head(mydata_new)
 +
</code></pre>
 +
 
 +
<pre><code>##  msec left right spont  bin bincomp
 +
## 1 0.00 1000  1000  1000 1000  -1000
 +
## 2 0.02 1000  1000  1000 1000  -1000
 +
## 3 0.04 1000  1000  1000 1000  -1000
 +
## 4 0.06 1000  1000  1000 1000  -1000
 +
## 5 0.08 1000  1000  1000 1000  -1000
 +
## 6 0.10 1000  1000  1000 1000  -1000
 +
</code></pre>
 +
 
 +
<p>Test plotting for comparison </p>
 +
 
 +
<pre><code class="r">
 +
plot(mydata_new[c(1, 2)], type = &quot;l&quot;, main = &quot;original left&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AA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prw0ISHJjw04aEJD014aMJDEx6a8NCEhyY8NOGhCQ9NeGjCQxMemvDQhIcmPDThoQkPTXhowkMTHprw0ISHJjw04aEJD014aMJDEx6a8NCEhyY8NOGhCQ9NeGjCQxMemvDQhIcmPDThoQkPTXhowkMTHprw0NLhw6tjQwtfS8nw4evr/tDC15Lw0ISH5jYemnv10ISH5qoemjt30ISHJjw0t/HQ3KuHJjw0V/XQCuzchRC9Lwyx39vd3bxXb7UkPLSbt/FWSzfv1VstCQ9NeGjCQ0vfq48etQtfcxn26i8ObY+WYVUfG0L4mnMbD014aHngN0cRvuZKwlvNlYO/cJ2UHD/n+Cnb+KQZO/6z4wsPHV946PjCQ8cXHjq+8NDxM8JbSwkPTXhowkMTHprw0ISHJjw04aEJDy0b/M+XfKSPX3AGYZxH6fHLzOA97pnhc8EX/ySMsoOHcRalYIZxBkWGf/05tfytwBe+U5WFn41frG7hy25KCj/ih3FNXO42dAtfdvx74MuN/xm7O/hxHiWHLg2/+KbADIS/OHTD8OeXvxV4V/U/h38G/o7j+JKjF55H2fHHN848cRxvjSU8NOGhCQ9NeGjCQxMemvDQhIcmPDThoQkPTXhowkMTHprw0ISHJjw04aEJD014aMJDI8OHv3exLt5h/Pny5HLdEhr+zT6933D60r08Gn5YiK9+6jrh33/Gt6IE4bvv6x2mywd+7wnvNh7XelXvXr31nvDQhIcmPDThoQkPTXhowkMTHprw0ISHJjw04aEJD014aMJDEx6a8ND+BWstsIe7RyYHAAAAAElFTkSuQmCC" alt="plot of chunk unnamed-chunk-3"/> </p>
 +
 
 +
<p>Now - try to apply a low pass filterusing butter() to determine the properties of the filter. </p>
 +
 
 +
<pre><code class="r">bf &lt;- butter(3, 0.1)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
 
 +
par(mfrow = c(1, 2))
 +
plot(mydata_new[c(1, 2)], type = &quot;l&quot;, main = &quot;original left&quot;)
 +
plot(test1, main = &quot;butter(3, 0.1)&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data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eqGoe1h/JQEjxJd4X0rE70plW3xK/LH5++KXqrrH9WdGfMkxq2iPX35HsPy7V+8UH34V6jYaa+JLC5WKLyn1oPh6eUF5tDAmfu1XtkCZ+Gzea8UviM/FpEqVRWkRG4gouBc5jfjBh/pQ3qgGqYFD89OKL76Oz5cpKllQ6vdbJA9dx5+an/U6Ht4K4p2CeKcg3imIdwrinYJ4pyDeKYh3CuKdgninIN4piHcK4p2CeKcg3imIdwrinYJ4pyDeKYh/jN9fF+/8mVABxD/JM87/eFb855fFYh8JtvvV5C35fRg+sh5687D473AvvwQQHt0bhrGKv6yH7jy9xx+MX57NzrbHV/7+TD1mxC/rL6AE3+KLfqlcjx3xy3nHd4Cwx4/AjHjf5/jF/aHe66z+sh56w3W8UxDvFMQ7BfFOQbxTEO8UxDsF8U5BvFMQ7xTEOwXxTkG8UxDvFMQ7BfFOQbxTEO+U/wARN6UtcVGr5QAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-4"/> </p>
 +
 
 +
<p>Test type = &ldquo;low&rdquo; vs type = &ldquo;high&rdquo;</p>
 +
 
 +
<pre><code class="r">bf &lt;- butter(3, 0.1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
 
 +
par(mfrow = c(1, 2))
 +
plot(test1, main = &quot;butter type low&quot;)
 +
 
 +
bf &lt;- butter(3, 0.1, type = &quot;high&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter type high&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AAAPdElEQVR4nO2di5KjOBAEV/r/j94Ij3lazavVUEKZFzfjNVBQShs0Xo/3X4Yu+ff0AcAzIL5TEN8piO8UxHcK4jsF8Z2C+E5BfKcgvlMQ3ymI7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4RnxssmrxjPjYZNXimWt8bLJq8cysPjZZtXhGfGyyavHMqT42WbV4Dpnc/fzWOOIFYVYfmaxaPCM+Nlm1eOYaH5usWjwzq49NVi2eER+brFo8Iz42WbV4RnxssmrxXGNWv/dZb4iXpMKsfncB4gWpcKq3IhD/cvG70YgXBPGRyarFcy3xxRTEI/748dwK4k0Q70pWLZ65xscmqxbPiI9NVi2eER+brFo8Iz42WbV4RnxssmrxjPjYZNXi+SbxjpBQEG+CeFeybHPExybLNr9HvCzh4oVBfGPJtUB8Y8m1QHxjybVAfGPJtUB8Y8m1QHxjybVAfGPJtUB8Y8m1QHxjybVAfGPJtUB8Y8m1QHxjybWIFK+Po93Lu3vE/43AQ0t9G9eh5e6Id9Byd8Q7aLk74h203B3xDlrujngHLXdHvIOWu7vFQ5sgvlMQ3ymI7xTEdwriOwXxnYL4TkF8pyC+U5zijTd6fO9efjsXeWXb5N75Gdru7hOfcvGV4e/dy2/nIq9s+23r2PkZGu8eIj4f338xMl/aNmUF8dmx+zu7C4pPwwbXBq5p8fd1jxJ/vUByPmOeF99Edz3x+b7yLhrvHiS+cBjnIhsW30b3GPFpvlS3vIvGu4f8HD/8Iof6z7I+2u7OK3edgvhOQXynIL5TEN8piO8UxHcK4jsF8Z2C+E5BfKcgvlMQ3ymI7xTEdwriOwXxnYL4TkF8pyC+Ux4WP3zCdtQbIpV5tvvzz/genQ882F1E/Odd4J/fIAp+T7QWD3YXEj/8H/lbEGI82F1IfL7h11/EeLC7pvj9f1LlHTzYXVP8s0d0Hw92lxXfhXxO9cvyHc7qb+/+vHh4BMR3CuI7BfGdgvhOQXynIL5TEN8piO8UxHcK4jsF8Z2C+E5BfKcgvlMQ3ymI7xTEd8p/IxKkSZAuuVgAAAAASUVORK5CYII=" alt="plot of chunk unnamed-chunk-5"/> </p>
 +
 
 +
<p>(guess default is low then)</p>
 +
 
 +
<p>Try changing filter properties - change filter order (first argument in function)</p>
 +
 
 +
<pre><code class="r">par(mfrow = c(2, 2))
 +
plot(mydata_new[c(1, 2)], type = &quot;l&quot;, main = &quot;original left&quot;)
 +
 
 +
bf &lt;- butter(1, 0.1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(1, 0.1)&quot;)
 +
 
 +
bf &lt;- butter(3, 0.1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(3, 0.1)&quot;)
 +
 
 +
bf &lt;- butter(15, 0.1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(30, 0.1)&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AAAUzklEQVR4nO2di7qrKAyFD77/Q8/s1ipqAiFyC1nrm9mnVQgsfrl4aftvg1zq3+gKQGME8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E4F8E41BnwIz1eXDdHm8P/reyJLujkM+/+PjTfPlxZq4H+6Hn8H//G9DnjSzmfDnXX4vW7TAB3Bh93DXw/+mon/O/d/0x4pv+pXzdo67R5mDne/vxvRycP+MpBjxGv1A3/CPqFf/tnO/VFrLdDjA2Hn1hp/aGnwUZKqGgl+uzRJNBgsBp6y8wDPTm/rg49G/e0Y5NcFfx7mzsHH+88X64I/dvoDT85+Cw714eo3NdQf7i9NYRv8Fq3aL939MvpdrF/SW9VzlLu72x5j2/0Ex/Sq/ibrPGsqage6RRo01LgLOLbPzusqPF4w++tpuit3UB8BvFMBvFMBvFMBvFMBvFMBvFMBvFMBvFMBPCfjD/7kBPCMQvR3RaXBL37Up+Qa/OrmU1rdO8BzWny0A3inwhzPaXHvWNUzWn20K+/xwZxUDUOC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Fzq2h3ucDP7hCHTXU+3Tgqz4GP7eGeh8NHhokgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHcqgHeq/wAaap8Xtgz3twAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-6"/> </p>
 +
 
 +
<p>Not really sure what the order is doing - ????</p>
 +
 
 +
<p>Stick with filter order == 3, change crirical frequency W. W-&gt; [0-1] where 1 is the Nyquist frequency (&frac12; of the sampling rate )</p>
 +
 
 +
<pre><code class="r">head(mydata_new)
 +
</code></pre>
 +
 
 +
<pre><code>##  msec left right spont  bin bincomp
 +
## 1 0.00 1000  1000  1000 1000  -1000
 +
## 2 0.02 1000  1000  1000 1000  -1000
 +
## 3 0.04 1000  1000  1000 1000  -1000
 +
## 4 0.06 1000  1000  1000 1000  -1000
 +
## 5 0.08 1000  1000  1000 1000  -1000
 +
## 6 0.10 1000  1000  1000 1000  -1000
 +
</code></pre>
 +
 
 +
<p>sampling rate =&gt; every 0.2 msec ()</p>
 +
 
 +
<p>Looks like sampling rate at 5 kHz =&gt; Nyquist = 2.5 KHz</p>
 +
 
 +
<pre><code class="r">par(mfrow = c(2, 2))
 +
plot(mydata_new[c(1, 2)], type = &quot;l&quot;, main = &quot;original left&quot;)
 +
 
 +
bf &lt;- butter(3, 0.01, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(3, 0.01 (25 Hz)&quot;)
 +
 
 +
bf &lt;- butter(3, 0.1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(3, 0.1 (250 Hz))&quot;)
 +
 
 +
bf &lt;- butter(3, 1, type = &quot;low&quot;)
 +
test1 &lt;- filter(bf, mydata_new$left)
 +
plot(test1, main = &quot;butter(30, 1 (2.5KHz))&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAA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VwDsVwDsVwDsVwDsVwDsVwDvV/wA2P54SyLt2qgAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-8"/> </p>
 +
 
 +
<p>Try the first derivative on the 250 LP</p>
 +
 
 +
<pre><code class="r">
 +
bf &lt;- butter(3, 0.1, type = &quot;low&quot;)
 +
mydata_new$leftlow &lt;- filter(bf, mydata_new$left)
 +
 
 +
par(mfrow = c(1, 3))
 +
plot(mydata_new$msec, mydata_new$left, type = &quot;l&quot;, main = &quot;original left&quot;)
 +
plot(mydata_new$msec, mydata_new$leftlow, type = &quot;l&quot;, main = &quot;lowpassed left&quot;)
 +
mydata_new$diffleft2[2:1000] &lt;- diff(mydata_new$leftlow)/diff(mydata_new$msec)
 +
plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = &quot;l&quot;,
 +
    main = &quot;first diff on lowpassed left&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AAAVHElEQVR4nO2di5qsJhCEA+//0PnOjhfABpqmVJCqk2xmlKZKfkGd3T35z1NL6r+3A1DviOAXFcEvKoJfVAS/qAh+URH8oiL4RUXwi4rgFxXBLyqCX1QEv6gIflER/KIi+EWFBO8uL8K3516XNrhVFi8XFeICpz254JX77Zac7jiEJ2Z8Ct52JH3uhpobAqfduPhVzuiOQwCAd879vrjfm+3kdefXI8nfTvfb+pR239+LLeKRLQ4abLkj8Dk2W4qt223Q4i1nkFsOoR/8L8wW6XizR9z3Xfc+pTPM/o+YLT2SWwI7n45N5OtqSYCHcDP4fQE4370Kfv9zZjunSBDvHDVw4ABuuhZqwaMO4V7w59f4qN4BfwmZTJZw0O8J7KLOYkcVeNwhwK7xu19wfl1mfHAH0G+rjrdHjEPtYXIXy1sCn3B3q9/mc9A2n2hMb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PbizUjG4tabpsz2FXPycW5REfyiIvhFRfCLiuAXFcEvKoJfVAS/qAh+URH8oiL4RUXwi4rgFxUQvAu+Xnf2fjMLJ+b8p07wf/7On98BDL4P6Pz23WD3++Ggbcf+MyGPDjBzpuoFv//Z3fd4vyRbviPq0RLwEyzM2ZUTCn7PdAbd//X7Pn++flLMmQoJfgsbnaFbKufjP4AfXWLOrpwQ8NtZ57YT8jxDj4Vov3j9DuTY9ZiYMxXmrl7hOcS9MnMeugf8QA9FkZjzED/AWVQEv6gIflER/KIi+EVF8IuK4BcVwS8qgl9UBL+o/gearpFo5iVa7AAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-9"/> </p>
 +
 
 +
<p>First deriv stil looks noisy - try different filters </p>
 +
 
 +
<pre><code class="r">
 +
bf &lt;- butter(3, 0.04, type = &quot;low&quot;)
 +
mydata_new$leftlow &lt;- filter(bf, mydata_new$left)
 +
 
 +
par(mfrow = c(1, 3))
 +
plot(mydata_new$msec, mydata_new$left, type = &quot;l&quot;, main = &quot;original left&quot;)
 +
plot(mydata_new$msec, mydata_new$leftlow, type = &quot;l&quot;, main = &quot;lowpassed  100 left&quot;)
 +
mydata_new$diffleft2[2:1000] &lt;- diff(mydata_new$leftlow)/diff(mydata_new$msec)
 +
plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = &quot;l&quot;,
 +
    main = &quot;first diff on lowpassed left&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AAAUnklEQVR4nO2diZbrqA5FG/7/o3vdim0mgYUkbDDn9Ht1E0CD2UaeUqn/PLSl/ns7AegdAfymAvhNBfCbCuA3FcBvKoDfVAC/qQB+UwH8pgL4TQXwmwrgNxXAbyqA31QAv6kswbviRfw29Lp8gLkk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MHoCXdSyfJ8DLOpbPE+BlHcvnCfCyjuXz7AEPfUgAv6kAflMB/KYC+E0F8JuKD75+b7rW4Wo2rmajvQV++qj20O075tkBvnZNWNt+l3+YPO2ohKiG4Qp5JiFqYSzAV/fcmo1r2AycUOQZyQC8r++61URrNlUTvpAnx8So1HcnWt+CoSUUeV6yObmrtDdPRiohhp40Vdp3zBOXc5sK4DcVwG8qgN9UAL+pAH5TAfymAvhNBfCbCuA3FcBvKoDfVAC/qQzBu+hn2al9mGUn5PlPSvB/8Z0PTwCj54DOH0+D3e/DQUfH+ZmQRycYeebSgj//O6Of6f0yOfK7Ur1GGnyCBXmq8jQFf+YUEj3/788+H14/KeSZyxL8kWyyhx5ZOZ/+Z/DRJeSpytME/LHXuWOHDHvoVYjOg9dvQ66ux4Q8c9mc1TNiTnGujDwvjQE/0UVRIuR5CTdwNhXAbyqA31QAv6kAflMB/KYC+E0F8JsK4DcVwG+q/wFPCpP6IUNsvAAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-10"/> </p>
 +
 
 +
<pre><code class="r">
 +
par(mfrow = c(1, 1))
 +
 
 +
plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = &quot;l&quot;,
 +
    main = &quot;first diff on lowpassed left&quot;)
 +
</code></pre>
 +
 
 +
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAH4CAMAAACR9g9NAAAACVBMVEX9/v0AAAD9/v3/vTJ9AAAAA3RSTlP//wDXyg1BAAAACXBIWXMAAAsSAAALEgHS3X78AAANq0lEQVR4nO2di3ajuhIFj/z/H33vJOEh0BMJqeVdNStjB0QLU9BqcIz/+4Ak/81eAZgD4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhREC/KcuKdc///uU/22/z+/DT+/S8Rr9NqhcL99t+lg96sJj7i6bq9T48Zs2+KL+l/FouJd2474veH7X+3Nznmbx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W/uy7whFnWaTER1P9MftzEu/u4i8NF+brxV8y9TFYB4742xJX8Yzxxrkq/OyfKtzln8/U/ETuLXUNRlW/DC1yFhab4+vFp9wVfTPfl/L14iEM4kVBvCiIFwXxoiBeFMSLgnhREC8K4kVBvCiIFwXxoiBeFMSLgnhR/gf4paxFfu8CSQAAAABJRU5ErkJggg==" alt="plot of chunk unnamed-chunk-10"/> </p>
 +
 
 +
<p>Mmmmmmm&hellip;.</p>
 +
 
 +
</body>
 +
 
 +
</html>
 +
 
==Andy==
==Andy==
*Enter content here
*Enter content here

Current revision

Hearing development in barn owls Main project page
Previous entry      Next entry

Contents


General Entries

  • Played around with filter() and butter() in library.signal MF Kubke 20:11, 28 October 2013 (EDT)

Feedback from Andy

  • Filter: Higher order is sharper cutoff. A sharp butterworth would be a 5th or 6th order. I wouldn't use any higher.
  • Try an fft to see where the low pass cutoff should be. If the filter order is too high you get ringing. [ see http://t.co/QfrGaDjvj2 ]
  • entered wrong sampling rate - sampling rate is actually 50 kHz - need to recalculate the filters based on that. They are off by a factor of 10, so what says lowpassed at 100 is actually at 1k.

Personal Entries

Fabiana

  • File 2013-10-29-MFK.Rmd

Trying to apply a low pass filter to ABR data

Using package signal

install.packages("signal")
## Error: trying to use CRAN without setting a mirror
library(signal)
## Warning: package 'signal' was built under R version 3.0.2
## Loading required package: MASS
## 
## Attaching package: 'signal'
## 
## The following object is masked from 'package:stats':
## 
##     filter, poly

Read test file

dir()
##  [1] "2013-10-27-MFK.Rmd"  "2013-10-27.html"     "2013-10-27.R"       
##  [4] "2013-10-27.txt"      "2013-10-28-MFK.html" "2013-10-28-MFK.md"  
##  [7] "2013-10-28-MFK.Rmd"  "2013-10-29-MFK.Rmd"  "Copy189L0A.ABR"     
## [10] "Copy224l0a.txt"      "Copy233L0B.ABR.log"  "Copy233L0B.ABR.txt" 
## [13] "figure"              "knitr-testr.html"    "knitr-testr.md"     
## [16] "knitr-testr.Rmd"     "kntR2.html"          "kntR2.md"           
## [19] "kntR2.Rmd"           "my first knitr.html" "my first knitr.md"  
## [22] "my first knitr.Rmd"  "mydata_new"          "mydata_new.txt"     
## [25] "readrawabr.R"        "Sandbox1.R"          "Sandbox1.txt"       
## [28] "signal.pdf"          "texput.log"
mydata <- read.table("Copy233L0B.ABR.txt", header = T)
head(mydata)  #passed test
##   msec left right spont  bin
## 1 0.00 1000  1000  1000 1000
## 2 0.02 1000  1000  1000 1000
## 3 0.04 1000  1000  1000 1000
## 4 0.06 1000  1000  1000 1000
## 5 0.08 1000  1000  1000 1000
## 6 0.10 1000  1000  1000 1000
write.table(mydata, "mydata_new.txt")
mydata_new <- read.table("mydata_new", header = T)
head(mydata_new)  #passed test
##   msec left right spont  bin
## 1 0.00 1000  1000  1000 1000
## 2 0.02 1000  1000  1000 1000
## 3 0.04 1000  1000  1000 1000
## 4 0.06 1000  1000  1000 1000
## 5 0.08 1000  1000  1000 1000
## 6 0.10 1000  1000  1000 1000
mydata_new$bincomp[1:1000] <- (mydata_new$bin[1:1000] - (mydata_new$left[1:1000] + 
    mydata_new$right[1:1000]))
head(mydata_new)
##   msec left right spont  bin bincomp
## 1 0.00 1000  1000  1000 1000   -1000
## 2 0.02 1000  1000  1000 1000   -1000
## 3 0.04 1000  1000  1000 1000   -1000
## 4 0.06 1000  1000  1000 1000   -1000
## 5 0.08 1000  1000  1000 1000   -1000
## 6 0.10 1000  1000  1000 1000   -1000
write.table(mydata_new, "mydata_new.txt")  #passed test
head(mydata_new)
##   msec left right spont  bin bincomp
## 1 0.00 1000  1000  1000 1000   -1000
## 2 0.02 1000  1000  1000 1000   -1000
## 3 0.04 1000  1000  1000 1000   -1000
## 4 0.06 1000  1000  1000 1000   -1000
## 5 0.08 1000  1000  1000 1000   -1000
## 6 0.10 1000  1000  1000 1000   -1000

Test plotting for comparison


plot(mydata_new[c(1, 2)], type = "l", main = "original left")

plot of chunk unnamed-chunk-3

Now - try to apply a low pass filterusing butter() to determine the properties of the filter.

bf <- butter(3, 0.1)
test1 <- filter(bf, mydata_new$left)

par(mfrow = c(1, 2))
plot(mydata_new[c(1, 2)], type = "l", main = "original left")
plot(test1, main = "butter(3, 0.1)")

plot of chunk unnamed-chunk-4

Test type = “low” vs type = “high”

bf <- butter(3, 0.1, type = "low")
test1 <- filter(bf, mydata_new$left)

par(mfrow = c(1, 2))
plot(test1, main = "butter type low")

bf <- butter(3, 0.1, type = "high")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter type high")

plot of chunk unnamed-chunk-5

(guess default is low then)

Try changing filter properties - change filter order (first argument in function)

par(mfrow = c(2, 2))
plot(mydata_new[c(1, 2)], type = "l", main = "original left")

bf <- butter(1, 0.1, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(1, 0.1)")

bf <- butter(3, 0.1, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(3, 0.1)")

bf <- butter(15, 0.1, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(30, 0.1)")

plot of chunk unnamed-chunk-6

Not really sure what the order is doing - ????

Stick with filter order == 3, change crirical frequency W. W-> [0-1] where 1 is the Nyquist frequency (½ of the sampling rate )

head(mydata_new)
##   msec left right spont  bin bincomp
## 1 0.00 1000  1000  1000 1000   -1000
## 2 0.02 1000  1000  1000 1000   -1000
## 3 0.04 1000  1000  1000 1000   -1000
## 4 0.06 1000  1000  1000 1000   -1000
## 5 0.08 1000  1000  1000 1000   -1000
## 6 0.10 1000  1000  1000 1000   -1000

sampling rate => every 0.2 msec ()

Looks like sampling rate at 5 kHz => Nyquist = 2.5 KHz

par(mfrow = c(2, 2))
plot(mydata_new[c(1, 2)], type = "l", main = "original left")

bf <- butter(3, 0.01, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(3, 0.01 (25 Hz)")

bf <- butter(3, 0.1, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(3, 0.1 (250 Hz))")

bf <- butter(3, 1, type = "low")
test1 <- filter(bf, mydata_new$left)
plot(test1, main = "butter(30, 1 (2.5KHz))")

plot of chunk unnamed-chunk-8

Try the first derivative on the 250 LP


bf <- butter(3, 0.1, type = "low")
mydata_new$leftlow <- filter(bf, mydata_new$left)

par(mfrow = c(1, 3))
plot(mydata_new$msec, mydata_new$left, type = "l", main = "original left")
plot(mydata_new$msec, mydata_new$leftlow, type = "l", main = "lowpassed left")
mydata_new$diffleft2[2:1000] <- diff(mydata_new$leftlow)/diff(mydata_new$msec)
plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = "l", 
    main = "first diff on lowpassed left")

plot of chunk unnamed-chunk-9

First deriv stil looks noisy - try different filters


bf <- butter(3, 0.04, type = "low")
mydata_new$leftlow <- filter(bf, mydata_new$left)

par(mfrow = c(1, 3))
plot(mydata_new$msec, mydata_new$left, type = "l", main = "original left")
plot(mydata_new$msec, mydata_new$leftlow, type = "l", main = "lowpassed  100 left")
mydata_new$diffleft2[2:1000] <- diff(mydata_new$leftlow)/diff(mydata_new$msec)
plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = "l", 
    main = "first diff on lowpassed left")

plot of chunk unnamed-chunk-10


par(mfrow = c(1, 1))

plot(mydata_new$msec, mydata_new$diffleft2, ylim = c(-3000, 3000), type = "l", 
    main = "first diff on lowpassed left")

plot of chunk unnamed-chunk-10

Mmmmmmm….

Andy

  • Enter content here

Oris

  • Enter content here


Personal tools