Jekyll2023-09-20T03:46:12+00:00/feed.xmlOleg Parashchenko, fullstack developer in lead roles. ML, NLP, AWS, Terraform, TypeScript, Pythonadvocating my software, tools and thoughts; sharing insightsTerraform cheat sheet2019-10-06T14:36:10+00:002019-10-06T14:36:10+00:00/blog/2019/10/06/terraform-cheat-sheet<p>The course "<a href="https://www.udemy.com/course/learn-devops-infrastructure-automation-with-terraform/">Infrastructure Automation With Terraform</a>" provides the course files on github: "<a href="https://github.com/wardviaene/terraform-course">wardviaene/terraform-course</a>".</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comThe course "Infrastructure Automation With Terraform" provides the course files on github: "wardviaene/terraform-course".Print whole deep object in JS2019-10-06T14:31:03+00:002019-10-06T14:31:03+00:00/blog/2019/10/06/print-whole-deep-object-in-js<p>The functions `<code>console.log</code>` or `<code>JSON.stringify</code>` in JavaScript do not print deep nested structures. To workaround, use `<code>util.inspect</code>`:</p>
<pre><code>
const util = require('util')
console.log(util.inspect(object_to_dump, { depth: 100, compact: false }))
</code></pre>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comThe functions `console.log` or `JSON.stringify` in JavaScript do not print deep nested structures. To workaround, use `util.inspect`: const util = require('util') console.log(util.inspect(object_to_dump, { depth: 100, compact: false }))Minimal GF-RGL usage example2019-04-04T13:22:12+00:002019-04-04T13:22:12+00:00/blog/2019/04/04/minimal-gf-rgl-usage-example<p>I managed to run GF-RGL (see the <a href="http://uucode.com/blog/2019/03/29/running-gf-rgl/">previous post</a>) as a part of a third-party project gf-matrix. Then I modified gf-matrix grammar files to create a minimal working version. Here is the result:</p>
<p><!--more--></p>
<pre><code>
$ cat Wrapper.gf
abstract Wrapper = Lang
, Extend ** {
} ;
$ cat WrapperEng.gf
concrete WrapperEng of Wrapper =
GrammarEng
, LexiconEng
, ConstructionEng
, DocumentationEng --# notpresent
, MarkupEng - [stringMark]
, ExtendEng
</code></pre>
<p>Usage:</p>
<pre><code>
export GF_LIB_PATH=/home/my-user-name/opt/gf-rgl/opt
$ echo 'parse "it goes"' | gf Wrapper.gf WrapperEng.gf
...
Languages: WrapperEng
Wrapper> PredVPS (DetNP (DetQuant DefArt NumSg)) (MkVPS (TTAnt TPres
ASimul) PPos (UseV go_V))
PredVPS (UsePron it_Pron) (MkVPS (TTAnt TPres ASimul) PPos (UseV go_V))
UseCl (TTAnt TPres ASimul) PPos (ImpersCl (UseV go_V))
UseCl (TTAnt TPres ASimul) PPos (PredVP (DetNP (DetQuant DefArt NumSg))
(UseV go_V))
UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron it_Pron) (UseV go_V))
</code></pre>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comI managed to run GF-RGL (see the previous post) as a part of a third-party project gf-matrix. Then I modified gf-matrix grammar files to create a minimal working version. Here is the result: $ cat Wrapper.gf abstract Wrapper = Lang , Extend ** { } ; $ cat WrapperEng.gf concrete WrapperEng of Wrapper = GrammarEng , LexiconEng , ConstructionEng , DocumentationEng --# notpresent , MarkupEng - [stringMark] , ExtendEng Usage: export GF_LIB_PATH=/home/my-user-name/opt/gf-rgl/opt $ echo 'parse "it goes"' | gf Wrapper.gf WrapperEng.gf ... Languages: WrapperEng Wrapper> PredVPS (DetNP (DetQuant DefArt NumSg)) (MkVPS (TTAnt TPres ASimul) PPos (UseV go_V)) PredVPS (UsePron it_Pron) (MkVPS (TTAnt TPres ASimul) PPos (UseV go_V)) UseCl (TTAnt TPres ASimul) PPos (ImpersCl (UseV go_V)) UseCl (TTAnt TPres ASimul) PPos (PredVP (DetNP (DetQuant DefArt NumSg)) (UseV go_V)) UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron it_Pron) (UseV go_V))Running GF-RGL2019-03-29T22:47:13+00:002019-03-29T22:47:13+00:00/blog/2019/03/29/running-gf-rgl<p>The <a href="http://www.grammaticalframework.org/lib/doc/synopsis.html">GF Resource Grammar Library</a> is the standard library for <a href="http://www.grammaticalframework.org/">Grammatical Framework</a>. It covers the morphology and basic syntax of over 30 languages. The GF project is big, and it is hard for outsiders to start using GF-RGL. This post summarizes my first steps which can be repeated by others.</p>
<p><!--more--></p>
<p>First, GF self should be installed as described on its site. I used a deb-package, so that the executable is installed as `/usr/bin/gf`.</p>
<p>I cloned RGL from its git repository `<a href="https://github.com/GrammaticalFramework/gf-rgl">https://github.com/GrammaticalFramework/gf-rgl</a>`. My setup command was:</p>
<pre><code>
./Setup.sh --dest=~/opt/gf-rgl/opt --gf=/usr/bin/gf --verbose
</code></pre>
<p>Files were installed into the directory `~/opt/gf-rgl/opt`. To understand how to use them, I searched github for rgl projects and found <a href="https://github.com/odanoburu/gf-matrix">gf-matrix</a>. Again, cloned the repository and tried to make anything. The following commands worked:</p>
<pre><code>
export GF_LIB_PATH=/home/my-user-name/opt/gf-rgl/opt
make
</code></pre>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comThe GF Resource Grammar Library is the standard library for Grammatical Framework. It covers the morphology and basic syntax of over 30 languages. The GF project is big, and it is hard for outsiders to start using GF-RGL. This post summarizes my first steps which can be repeated by others. First, GF self should be installed as described on its site. I used a deb-package, so that the executable is installed as `/usr/bin/gf`. I cloned RGL from its git repository `https://github.com/GrammaticalFramework/gf-rgl`. My setup command was: ./Setup.sh --dest=~/opt/gf-rgl/opt --gf=/usr/bin/gf --verbose Files were installed into the directory `~/opt/gf-rgl/opt`. To understand how to use them, I searched github for rgl projects and found gf-matrix. Again, cloned the repository and tried to make anything. The following commands worked: export GF_LIB_PATH=/home/my-user-name/opt/gf-rgl/opt makeMulti-page table with inter-row page breaks2019-03-03T20:15:05+00:002019-03-03T20:15:05+00:00/blog/2019/03/03/multi-page-table-with-inter-row-page-breaks<p>Usually it is a bad idea to break table inside a row. But people do want it. <a href="https://groups.google.com/d/msg/comp.text.tex/gE80AAOQ83U/woX-CFfUQYEJ">Once</a> I sketched a quick dirty hack for latex <a href="https://ctan.org/pkg/cals">cals package</a> and since then I've got several support requests. It seems now I have to support the code.</p>
<p>The current version can be found as github gist: <a href="https://gist.github.com/olpa/2a7096b231d0dbe2b022122b1674b4ff">tblbrk.tex</a>.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comUsually it is a bad idea to break table inside a row. But people do want it. Once I sketched a quick dirty hack for latex cals package and since then I've got several support requests. It seems now I have to support the code. The current version can be found as github gist: tblbrk.tex.Cleaning the signal from EEG-SMT2017-09-30T16:07:41+00:002017-09-30T16:07:41+00:00/blog/2017/09/30/cleaning-the-signal-from-eeg-smt<p>An disappointment after getting EEG-SMT working: the resulting measurement is just a noice. It is a challenging task for a beginner to understand what is going wrong.</p>
<p><!--more--></p>
<p><img src="/assets/2017/09/signal-is-bad.png" alt="signal-is-bad" width="500" height="368" class="alignnone size-full wp-image-528" /></p>
<h2>Check software</h2>
<p>First I made sure that the signal isn't modified somehow on the way.</p>
<p>EEG-SMT uses the version P2 of the firmware for ModularEEG, which is available here: <a href="http://openeeg.sourceforge.net/doc/modeeg/firmware/modeeg-p2.c">modeeg-p2.c</a>. The code just dumps to outside what it has as signal inputs.</p>
<p>The plugin for OpenVIBE also forwards the data further from EEG-SMT to the main software.</p>
<h2>How to attach electrodes</h2>
<p>The device provides 2 channels and has 5 electrodes. It is confusing.</p>
<p>Now I know for sure for the passive electrode:</p>
<p>* it is plugged into "DRL" socket,<br />
* the sensor is attached somewhere on the body: one can hold it in a hand, or attach it to a leg, an ear or a cheek.</p>
<p>The letters "DRL" stay for <a href="https://en.wikipedia.org/wiki/Driven_right_leg_circuit">Driven right leg circuit</a>. The explanations in the wikipedia article are sufficient.</p>
<p>At the moment, I do use the right leg, because the hands hold other electrodes.</p>
<p>I still don't understand the need to have _two_ electrodes for one channel. Even after reading <a href="http://openeeg.sourceforge.net/doc/modeeg/modeeg_design.html">The ModularEEG Design</a> document, I can't get it.</p>
<p>What I'd expect is that there is one and only one electrode pro channel, and additionally there is a "base" electrode, to be used as a zero potential.</p>
<p>The clear thing is that when two electrodes are connected together, the signal should be zero. Surprisingly, it is not so in my case. Initially it is so, but with time the noice starts again. TODO: ask in the mailing list what happens.</p>
<p>For futher investigation:</p>
<p>Maybe a contact gel is useful.</p>
<p><a href="https://en.wikipedia.org/wiki/10%E2%80%9320_system_(EEG)">The 10–20 system</a> or International 10–20 system is an internationally recognized method to describe and apply the location of scalp electrodes in the context of an EEG test or experiment.</p>
<h2>OpenVIBE with noice filter</h2>
<p>The background knowledge suggested to play with FFT (<a href="https://en.wikipedia.org/wiki/Fast_Fourier_transform">fast fourier transform</a>). And anyway spectrum analysis is required later to see which waves sends the brain.</p>
<p>The task was easy in OpenVIBE. The result is that I have a very big peak around 50 Hz. This is the frequence of the electrical supply. So I need separate the frequences which I need and frequences which is noice.</p>
<p>The frequences above 60 Hz are filtered out by OpenEEG circuit self. And I need only brain waves frequences, which are up to ~30 Hz (<a href="https://en.wikipedia.org/wiki/Beta_wave">Beta wave</a>, with the references to other waves).</p>
<p>OpenVIBE provides an example "neurofeedback" with an advanced data flow. I've learned from this example how to apply a filter and implemented it in a simple script.</p>
<p><img src="/assets/2017/09/program-to-filter-signal.png" alt="program-to-filter-signal" width="559" height="328" class="alignnone size-full wp-image-533" /></p>
<h2>Getting help</h2>
<p>I suspect I'm not the first who has the noice problem.</p>
<p>The first try was to search in the <a href="https://sourceforge.net/p/openeeg/mailman/openeeg-list/">mailing list of OpenEEG</a> project. Unfortunately, sourceforge now is very out-of-date, it the searching is a bad experience, one can find anything useful only with luck.</p>
<p>The advices in the mailing list are centered about re-checking the circuit and using shilded wires. All that is already have done in SMT-EEG device.</p>
<p>A better help source is the forum <a href="https://www.olimex.com/forum/index.php?board=25.0">Biofeedback - EEG, ECG, EKG</a> on Olimex site. In particular, the following threads helped me to start doing something reasonable: <a href="https://www.olimex.com/forum/index.php?topic=5245.0">Persistent noise with EKG-EMG shield</a> and <a href="https://www.olimex.com/forum/index.php?topic=2350.0">EEG- SMT EEG Signal Acquisition</a>.</p>
<h2>Reproducing feedback</h2>
<p>After software filtering is setup, it is time to get some results. The bad new is that I don't know with which measurements to start and which result should I expect.</p>
<p>An already mentioned thread "EEG- SMT EEG Signal Acquisition" in Olimex forum suggests the following setup:</p>
<blockquote><p>Please place the electrodes of one channel a bit over both temples and then hold the DRL firmly in hand. Then after you start the monitoring roll your eyes right and left and check the readings.</p></blockquote>
<p>I tried, but was not very successful, maybe because I don't know where exact temlpes are. Instead, I found a position where I get stable reproducable reaction on strong blinking.</p>
<p>Unfortunately, while writing this post, I've lost the position. Also, I've got no noice on the channel 1. The channel 2 was doing nothing.</p>
<p><img src="/assets/2017/09/with-filtered-channel-1.png" alt="with-filtered-channel-1" width="497" height="1027" class="alignnone size-full wp-image-534" /></p>
<p>Now I think that peek in the signal is caused not by brain but by eye muscles, but anyway it is good to have anything stable.</p>
<p>The next tasks are:</p>
<p>* make an EEG cap to use 10-20 system,<br />
* find stable reproducable eeg signal patters for brain activity.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comAn disappointment after getting EEG-SMT working: the resulting measurement is just a noice. It is a challenging task for a beginner to understand what is going wrong. Check software First I made sure that the signal isn't modified somehow on the way. EEG-SMT uses the version P2 of the firmware for ModularEEG, which is available here: modeeg-p2.c. The code just dumps to outside what it has as signal inputs. The plugin for OpenVIBE also forwards the data further from EEG-SMT to the main software. How to attach electrodes The device provides 2 channels and has 5 electrodes. It is confusing. Now I know for sure for the passive electrode: * it is plugged into "DRL" socket, * the sensor is attached somewhere on the body: one can hold it in a hand, or attach it to a leg, an ear or a cheek. The letters "DRL" stay for Driven right leg circuit. The explanations in the wikipedia article are sufficient. At the moment, I do use the right leg, because the hands hold other electrodes. I still don't understand the need to have _two_ electrodes for one channel. Even after reading The ModularEEG Design document, I can't get it. What I'd expect is that there is one and only one electrode pro channel, and additionally there is a "base" electrode, to be used as a zero potential. The clear thing is that when two electrodes are connected together, the signal should be zero. Surprisingly, it is not so in my case. Initially it is so, but with time the noice starts again. TODO: ask in the mailing list what happens. For futher investigation: Maybe a contact gel is useful. The 10–20 system or International 10–20 system is an internationally recognized method to describe and apply the location of scalp electrodes in the context of an EEG test or experiment. OpenVIBE with noice filter The background knowledge suggested to play with FFT (fast fourier transform). And anyway spectrum analysis is required later to see which waves sends the brain. The task was easy in OpenVIBE. The result is that I have a very big peak around 50 Hz. This is the frequence of the electrical supply. So I need separate the frequences which I need and frequences which is noice. The frequences above 60 Hz are filtered out by OpenEEG circuit self. And I need only brain waves frequences, which are up to ~30 Hz (Beta wave, with the references to other waves). OpenVIBE provides an example "neurofeedback" with an advanced data flow. I've learned from this example how to apply a filter and implemented it in a simple script. Getting help I suspect I'm not the first who has the noice problem. The first try was to search in the mailing list of OpenEEG project. Unfortunately, sourceforge now is very out-of-date, it the searching is a bad experience, one can find anything useful only with luck. The advices in the mailing list are centered about re-checking the circuit and using shilded wires. All that is already have done in SMT-EEG device. A better help source is the forum Biofeedback - EEG, ECG, EKG on Olimex site. In particular, the following threads helped me to start doing something reasonable: Persistent noise with EKG-EMG shield and EEG- SMT EEG Signal Acquisition. Reproducing feedback After software filtering is setup, it is time to get some results. The bad new is that I don't know with which measurements to start and which result should I expect. An already mentioned thread "EEG- SMT EEG Signal Acquisition" in Olimex forum suggests the following setup: Please place the electrodes of one channel a bit over both temples and then hold the DRL firmly in hand. Then after you start the monitoring roll your eyes right and left and check the readings. I tried, but was not very successful, maybe because I don't know where exact temlpes are. Instead, I found a position where I get stable reproducable reaction on strong blinking. Unfortunately, while writing this post, I've lost the position. Also, I've got no noice on the channel 1. The channel 2 was doing nothing. Now I think that peek in the signal is caused not by brain but by eye muscles, but anyway it is good to have anything stable. The next tasks are: * make an EEG cap to use 10-20 system, * find stable reproducable eeg signal patters for brain activity.Display signal from OpenEEG EEG-SMT2017-09-10T13:56:20+00:002017-09-10T13:56:20+00:00/blog/2017/09/10/display-signal-from-openeeg-eeg-smt<p>There is a number of software intended for EEG works. The <a href="https://www.olimex.com/Products/EEG/OpenEEG/EEG-SMT/resources/EEG-SMT_QUICKSTART.pdf">EEG-SMT quick start guide</a> suggests <a href="http://realization.org/page/topics/electric_guru.htm">Electric Guru</a>, <a href="http://www.shifz.org/brainbay/">BrainBay</a> and <a href="http://openvibe.inria.fr/">OpenVibe</a>, but it implies the use of a legacy operating system instead of Linux.</p>
<p>This post extends the quick start to have Linux notes. The content:</p>
<p>* Install OpenVIBE<br />
* Connect STM-EEG to Linux<br />
* Configure OpenVIBE<br />
* Get the signal</p>
<p><!--more--></p>
<h2>OpenVIBE</h2>
<blockquote><p><a href="http://openvibe.inria.fr/">OpenVibe</a> is a software platform that enables to design, test and use Brain-Computer Interfaces (BCIs). OpenViBE can also be used as a generic realtime EEG acquisition, processing and visualization system.</p></blockquote>
<p>The version 2.0 BETA is released at the moment of writing, but I decided to avoid being a tester and downloaded the <a href="http://openvibe.inria.fr/pub/src/openvibe-1.3.0-src.tar.xz">stable version 1.3.0</a> as the source code package. Unpack it:</p>
<pre><code>tar xJvf openvibe-1.3.0-src.tar.xz</code></pre>
<p>Read the file <tt>INSTALL</tt> for instructions. The short story is:</p>
<pre><code>
$ cd scripts
$ ./linux-install_dependencies
$ ./linux-build
</code></pre>
<p>Under Ubuntu 16.04.03, these commands have successfully built OpenVIBE without any tuning. The result is in "dist/".</p>
<h2>Connect STM-EEG to Linux</h2>
<p>Connect the device. Linux detects it automatically as:</p>
<pre><code>
Bus 001 Device 009: ID 0403:6001 Future Technology Devices
International, Ltd FT232 USB-Serial (UART) IC
</code></pre>
<p>Modules are been automatically loaded: <tt>ftdi_sio</tt>, <tt>usbserial</tt>.</p>
<p>A new tty device automatically appears:</p>
<pre><code>
$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Sep 2 16:48 /dev/ttyUSB0
</code></pre>
<p>You are not allowed to access this file because you are not in the group "dialout". For the time being, I use a quick dirty solution, allowing access to everyone. I don't remember if write access is also required, but grant it too.</p>
<pre><code>
$ sudo chmod o+rw /dev/ttyUSB0
$ ls -l /dev/ttyUSB0
crw-rw-rw- 1 root dialout 188, 0 Sep 2 16:48 /dev/ttyUSB0
</code></pre>
<h2>Configure OpenVIBE acquisition server</h2>
<p>Now you can follow the quick start guide.</p>
<p>Start the aquisition server (<tt>$ ./openvibe-acquisition-server.sh</tt>) and configure as suggested:</p>
<blockquote><p>
19) Select "OpenEEG Modular EEG p2" from the drop-down menu and adjust it's properties. Especially change the COM port to the proper port the EEG-SMT got connected to (after the drivers were installed in point) and also remember to reduce the number of channels to 1 or 2!
</p></blockquote>
<p><img src="/assets/2017/09/openvibe-acq-server.png" alt="openvibe-acq-server" width="1166" height="446" class="alignnone size-full wp-image-526" /></p>
<p>In our case, the port is "<tt>/dev/ttyUSB0</tt>".</p>
<p>Click "Connect". A debug message appears in the console:</p>
<pre><code>
[ INF ] Connecting to device [OpenEEG Modular EEG P2]...
[ INF ] Connection succeeded !
</code></pre>
<p>Click "Run". Console:</p>
<pre><code>
[ INF ] Starting the acquisition...
[ INF ] Now acquiring...
</code></pre>
<p>The program complains often that "device drift is too high". I don't know if it is bad and hope it can be ignored.</p>
<h2>Get the signal</h2>
<p>The visualisation tool is OpenVIBE designer (<tt>./openvibe-designer.sh</tt>).</p>
<p>A minimal useful program consist of two blocks:</p>
<p>* get the signal, and<br />
* visualise the signal.</p>
<p><img src="/assets/2017/09/openvibe-show-signal-min.png" alt="openvibe-show-signal-min" width="617" height="333" class="alignnone size-full wp-image-527" /></p>
<p>Consult the quick start for detailed instructions.</p>
<p>Make sure that the acquisition server is running, now run the visualisation program and see the result:</p>
<p><img src="/assets/2017/09/signal-is-bad.png" alt="signal-is-bad" width="500" height="368" class="alignnone size-full wp-image-528" /></p>
<p>This is a disaster with a lot of noice. And a topic for the next post.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comThere is a number of software intended for EEG works. The EEG-SMT quick start guide suggests Electric Guru, BrainBay and OpenVibe, but it implies the use of a legacy operating system instead of Linux. This post extends the quick start to have Linux notes. The content: * Install OpenVIBE * Connect STM-EEG to Linux * Configure OpenVIBE * Get the signal OpenVIBE OpenVibe is a software platform that enables to design, test and use Brain-Computer Interfaces (BCIs). OpenViBE can also be used as a generic realtime EEG acquisition, processing and visualization system. The version 2.0 BETA is released at the moment of writing, but I decided to avoid being a tester and downloaded the stable version 1.3.0 as the source code package. Unpack it: tar xJvf openvibe-1.3.0-src.tar.xz Read the file INSTALL for instructions. The short story is: $ cd scripts $ ./linux-install_dependencies $ ./linux-build Under Ubuntu 16.04.03, these commands have successfully built OpenVIBE without any tuning. The result is in "dist/". Connect STM-EEG to Linux Connect the device. Linux detects it automatically as: Bus 001 Device 009: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC Modules are been automatically loaded: ftdi_sio, usbserial. A new tty device automatically appears: $ ls -l /dev/ttyUSB0 crw-rw---- 1 root dialout 188, 0 Sep 2 16:48 /dev/ttyUSB0 You are not allowed to access this file because you are not in the group "dialout". For the time being, I use a quick dirty solution, allowing access to everyone. I don't remember if write access is also required, but grant it too. $ sudo chmod o+rw /dev/ttyUSB0 $ ls -l /dev/ttyUSB0 crw-rw-rw- 1 root dialout 188, 0 Sep 2 16:48 /dev/ttyUSB0 Configure OpenVIBE acquisition server Now you can follow the quick start guide. Start the aquisition server ($ ./openvibe-acquisition-server.sh) and configure as suggested: 19) Select "OpenEEG Modular EEG p2" from the drop-down menu and adjust it's properties. Especially change the COM port to the proper port the EEG-SMT got connected to (after the drivers were installed in point) and also remember to reduce the number of channels to 1 or 2! In our case, the port is "/dev/ttyUSB0". Click "Connect". A debug message appears in the console: [ INF ] Connecting to device [OpenEEG Modular EEG P2]... [ INF ] Connection succeeded ! Click "Run". Console: [ INF ] Starting the acquisition... [ INF ] Now acquiring... The program complains often that "device drift is too high". I don't know if it is bad and hope it can be ignored. Get the signal The visualisation tool is OpenVIBE designer (./openvibe-designer.sh). A minimal useful program consist of two blocks: * get the signal, and * visualise the signal. Consult the quick start for detailed instructions. Make sure that the acquisition server is running, now run the visualisation program and see the result: This is a disaster with a lot of noice. And a topic for the next post.Affordable EEG and neurofeedback: OpenEEG, EEG-SMT2017-09-09T18:36:07+00:002017-09-09T18:36:07+00:00/blog/2017/09/09/affordable-eeg-and-neurofeedback-openeeg-eeg-smt<p>My old interest is to influece the brain to make it working more efficient.</p>
<p>One of the approaches is to learn complete relaxation, or in other word meditation. The book "<a href="http://www.amazon.de/dp/3426300702/">Meditation für Skeptiker</a>" by Ulrich Ott suggests a scientific evidence for this claim, and I decided to try.</p>
<p><!--more--></p>
<p>I tried and failed. I wasn't able to understand if I was doing the process right or not. I wanted to have some tool which would say if the brain activity slows down or not. I searched for something like "eeg for home" but there were no such thing, and usual eeg-devices were very costly.</p>
<p>Recently I found the project <a href="http://openeeg.sourceforge.net/doc/">OpenEEG</a>.</p>
<blockquote><p>The OpenEEG project is about making plans and software for do-it-yourself EEG devices available for free (as in GPL). It is aimed toward amateurs who would like to experiment with EEG.</p></blockquote>
<p>Then I found an already built OpenEEG-based device from <a href="https://www.olimex.com/">Olimex</a> (Europa/Bulgaria). The total cost of everything what required was around 150 euro, the internet-feedback about the firm and theirs electronics was good. So I've ordered it:</p>
<p><a href="https://www.olimex.com/Products/EEG/OpenEEG/EEG-SMT/">EEG-SMT</a><br />
Low cost open source EEG device, completely assembled, USB interface<br />
<a href="https://www.olimex.com/Products/EEG/OpenEEG/EEG-SMT/"><br />
<img src="/assets/2017/09/EEG-SMT-01.jpg" alt="EEG-SMT-01" width="310" height="230" class="alignnone size-full wp-image-523" /><br />
</a></p>
<p>Also required:</p>
<p>* 4 active electrodes, <a href="https://www.olimex.com/Products/EEG/Electrodes/EEG-AE/">EEG-AE</a><br />
* 1 passive electrode, <a href="https://www.olimex.com/Products/EEG/Electrodes/EEG-PE/">EEG-PE</a><br />
* <a href="https://www.olimex.com/Products/Components/Cables/USB-A-B-CABLE/">USB-A-B-CABLE</a></p>
<p>I got the package in several days. Everything was good packed.</p>
<p>The only problem is to find which one is the passive electrode. All the 5 look the same. I decided that the passive should be simplier, and found exaclty one without some (amplifier?) chip. Don't forget to mark the electrode to find it again easily.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comMy old interest is to influece the brain to make it working more efficient. One of the approaches is to learn complete relaxation, or in other word meditation. The book "Meditation für Skeptiker" by Ulrich Ott suggests a scientific evidence for this claim, and I decided to try. I tried and failed. I wasn't able to understand if I was doing the process right or not. I wanted to have some tool which would say if the brain activity slows down or not. I searched for something like "eeg for home" but there were no such thing, and usual eeg-devices were very costly. Recently I found the project OpenEEG. The OpenEEG project is about making plans and software for do-it-yourself EEG devices available for free (as in GPL). It is aimed toward amateurs who would like to experiment with EEG. Then I found an already built OpenEEG-based device from Olimex (Europa/Bulgaria). The total cost of everything what required was around 150 euro, the internet-feedback about the firm and theirs electronics was good. So I've ordered it: EEG-SMT Low cost open source EEG device, completely assembled, USB interface Also required: * 4 active electrodes, EEG-AE * 1 passive electrode, EEG-PE * USB-A-B-CABLE I got the package in several days. Everything was good packed. The only problem is to find which one is the passive electrode. All the 5 look the same. I decided that the passive should be simplier, and found exaclty one without some (amplifier?) chip. Don't forget to mark the electrode to find it again easily.Format dvd+rw before writing data2017-08-13T15:28:08+00:002017-08-13T15:28:08+00:00/blog/2017/08/13/format-dvdrw-before-writing-data<p>Writing a DWD+RW under Linux should be simple, something like:</p>
<pre><code>$ wodim speed=2 dev=/dev/sr0 -v -data ubuntu-16.04.3-desktop-i386.iso</code></pre>
<p>However, in my case it fails. Some background knowledge suggests to format the disc first, but blanking the disc fails too.</p>
<p><!--more--></p>
<p>Solution is: format the disc with another utility:</p>
<pre><code>$ dvd+rw-format -blank /dev/sr0</code></pre>
<p>After this step, writing does work.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comWriting a DWD+RW under Linux should be simple, something like: $ wodim speed=2 dev=/dev/sr0 -v -data ubuntu-16.04.3-desktop-i386.iso However, in my case it fails. Some background knowledge suggests to format the disc first, but blanking the disc fails too. Solution is: format the disc with another utility: $ dvd+rw-format -blank /dev/sr0 After this step, writing does work.AWS response status is always 2002017-07-29T10:36:46+00:002017-07-29T10:36:46+00:00/blog/2017/07/29/aws-response-status-is-always-200<p>There is a task, which can't be avoided when developing serverless applicatoins on Amazon Web Services:</p>
<p>How to return a custom status code from a REST API?</p>
<p>One of the approaches is to use "prefix mapping", like for example is shown in this amazon blog post: <a href="https://aws.amazon.com/blogs/compute/error-handling-patterns-in-amazon-api-gateway-and-aws-lambda/">Error Handling Patterns in Amazon API Gateway and AWS Lambda</a> by Bryan Liston.</p>
<p>The only problem is that the approach doesn't always work. After a long debuggin session with many false tries, I've found the reason.</p>
<p><!--more--></p>
<p>There is an AWS bug. More precisely, it is a feature because it is documented (<a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings-execution-console.html">Set up Data Mappings between Method and Integration</a>)):</p>
<blockquote><p>If you use '.+' as the selection pattern to filter responses, be aware that it may not match a response containing a newline ('\n') character. </p></blockquote>
<p>Therefore, such a rule (from the referenced blog post) is wrong:</p>
<p><code>
<pre>Selection pattern: “^[BadRequest].*”</pre>
<p></code></p>
<p>The correct expression is:</p>
<p><code>
<pre>Selection pattern: “^[BadRequest](\n|.)*”</pre>
<p></code></p>
<p>The last question is: why the response message could contain newlines? Easily: they are produced by throwing an RuntimeException, and Java serializes the exception to a multi-line string.</p>{"login"=>"olpa", "email"=>"olpa@uucode.com", "display_name"=>"olpa", "first_name"=>"Oleg", "last_name"=>"Paraschenko"}olpa@uucode.comThere is a task, which can't be avoided when developing serverless applicatoins on Amazon Web Services: How to return a custom status code from a REST API? One of the approaches is to use "prefix mapping", like for example is shown in this amazon blog post: Error Handling Patterns in Amazon API Gateway and AWS Lambda by Bryan Liston. The only problem is that the approach doesn't always work. After a long debuggin session with many false tries, I've found the reason. There is an AWS bug. More precisely, it is a feature because it is documented (Set up Data Mappings between Method and Integration)): If you use '.+' as the selection pattern to filter responses, be aware that it may not match a response containing a newline ('\n') character. Therefore, such a rule (from the referenced blog post) is wrong: Selection pattern: “^[BadRequest].*” The correct expression is: Selection pattern: “^[BadRequest](\n|.)*” The last question is: why the response message could contain newlines? Easily: they are produced by throwing an RuntimeException, and Java serializes the exception to a multi-line string.