From 49200600c1d7a295080ae8f928d40e32ca99a30b Mon Sep 17 00:00:00 2001 From: matkovic Date: Sat, 10 Jun 2017 23:48:35 +0200 Subject: First commit --- openvibe-scenarios/free-will-bci-1-acquisition.xml | 1204 ++++++++++++++++++++ .../free-will-bci-2-classifier-trainer.xml | 692 +++++++++++ scripts/python-learning.py | 157 +++ 3 files changed, 2053 insertions(+) create mode 100644 openvibe-scenarios/free-will-bci-1-acquisition.xml create mode 100644 openvibe-scenarios/free-will-bci-2-classifier-trainer.xml create mode 100644 scripts/python-learning.py diff --git a/openvibe-scenarios/free-will-bci-1-acquisition.xml b/openvibe-scenarios/free-will-bci-1-acquisition.xml new file mode 100644 index 0000000..523ade9 --- /dev/null +++ b/openvibe-scenarios/free-will-bci-1-acquisition.xml @@ -0,0 +1,1204 @@ + + OpenViBE + 1.3.0 + + + (0x000011b9, 0x00002dbe) + Stimulation multiplexer + (0x07db4efa, 0x472b0938) + + + (0x6f752dd0, 0x082a321e) + Input stimulations 1 + + + (0x6f752dd0, 0x082a321e) + Input stimulations 2 + + + + + (0x6f752dd0, 0x082a321e) + Multiplexed stimulations + + + + + (0x1fa7a38f, 0x54edbe0b) + -48.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 640.000000 + + + (0x4e7b798a, 0x183beafb) + (0xd5da9c1d, 0x1cc7dbf9) + + + (0xad100179, 0xa3c984ab) + 117 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x005f6b9c) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xcfad85b0, 0x7c6d841c) + 2 + + + (0xfba64161, 0x65304e21) + + + + + + (0x00001ab6, 0x00007dc8) + Stimulation listener + (0x65731e1d, 0x47de5276) + + + (0x6f752dd0, 0x082a321e) + Stimulation stream 1 + + + + + (0xa88b3667, 0x0871638c) + Log level to use + Debug + Information + false + + + + + (0x1fa7a38f, 0x54edbe0b) + 16.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 656.000000 + + + (0x4e7b798a, 0x183beafb) + (0xf451ad91, 0x14c75f86) + + + (0xad100179, 0xa3c984ab) + 121 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x00274198) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 1 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + (0xfba64161, 0x65304e21) + + + + + + (0x00002750, 0x00001fb2) + Signal display + (0x0055be5f, 0x087bdd12) + + + (0x5ba36127, 0x195feae1) + Data + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + (0x6ab26b81, 0x0f8c02f3) + Channel Units + + + + + (0x5de046a6, 0x086340aa) + Display Mode + Scan + Scan + false + + + (0x33a30739, 0x00d5299b) + Auto vertical scale + Per channel + Per channel + false + + + (0x512a166f, 0x5c3ef83f) + Scale refresh interval (secs) + 5 + 5 + false + + + (0x512a166f, 0x5c3ef83f) + Vertical Scale + 100 + 100 + false + + + (0x512a166f, 0x5c3ef83f) + Vertical Offset + 0 + 0 + false + + + (0x512a166f, 0x5c3ef83f) + Time Scale + 10 + 10 + false + + + (0x2cdb2f0b, 0x12f231ea) + Bottom ruler + true + true + false + + + (0x2cdb2f0b, 0x12f231ea) + Left ruler + false + false + false + + + (0x2cdb2f0b, 0x12f231ea) + Multiview + false + false + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -16.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 304.000000 + + + (0x4e7b798a, 0x183beafb) + (0x92c056a7, 0x2dc71aff) + + + (0x527ad68d, 0x16d746a0) + + + + (0xad100179, 0xa3c984ab) + 87 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0020f6e8) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 9 + + + (0xcfad85b0, 0x7c6d841c) + 3 + + + + + (0x000032a2, 0x00004de0) + Keyboard stimulator + (0x00d317b9, 0x6324c3ff) + + + (0x6f752dd0, 0x082a321e) + Outgoing Stimulations + + + + + (0x330306dd, 0x74a95f98) + Filename + ${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt + ${Path_Data}/plugins/stimulation/simple-keyboard-to-stimulations.txt + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -176.000000 + + + (0x1fa963f5, 0x1a638cd4) + 23 + + + (0x207c9054, 0x3c841b63) + 528.000000 + + + (0x4e7b798a, 0x183beafb) + (0x8d89d3b7, 0x8339d210) + + + (0xad100179, 0xa3c984ab) + 126 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x00450264) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xce18836a, 0x9c0eb403) + 1 + + + + + (0x00003f97, 0x0000658d) + Player Controller + (0x5f426dce, 0x08456e13) + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + + + (0x2c132d6e, 0x44ab0d97) + Stimulation name + OVTK_StimulationId_Label_00 + OVTK_StimulationId_Label_02 + false + + + (0xcc14d8d6, 0xf27ecb73) + Action to perform + Pause + Stop + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -96.000000 + + + (0x1fa963f5, 0x1a638cd4) + 23 + + + (0x207c9054, 0x3c841b63) + 448.000000 + + + (0x4e7b798a, 0x183beafb) + (0x568d148e, 0x650792b3) + + + (0xad100179, 0xa3c984ab) + 105 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0041bb9e) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 2 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + (0x0000430f, 0x00004aa4) + Acquisition client + (0x35d225cb, 0x3e6e3a5f) + + + (0x403488e7, 0x565d70b6) + Experiment information + + + (0x5ba36127, 0x195feae1) + Signal stream + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + (0x013df452, 0xa3a8879a) + Channel localisation + + + (0x6ab26b81, 0x0f8c02f3) + Channel units + + + + + (0x79a9edeb, 0x245d83fc) + Acquisition server hostname + ${AcquisitionServer_HostName} + ${AcquisitionServer_HostName} + false + + + (0x007deef9, 0x2f3e95c6) + Acquisition server port + 1024 + 1024 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -192.000000 + + + (0x1fa963f5, 0x1a638cd4) + 23 + + + (0x207c9054, 0x3c841b63) + 256.000000 + + + (0x4e7b798a, 0x183beafb) + (0x0d4656c0, 0xc95b1fa8) + + + (0xad100179, 0xa3c984ab) + 106 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0061952f) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xc80ce8af, 0xf699f813) + 5 + + + (0xce18836a, 0x9c0eb403) + 2 + + + + + (0x00006664, 0x00000edf) + CSV File Writer + (0x2c9312f1, 0x2d6613e5) + + + (0x5ba36127, 0x195feae1) + Input stream + + + + + (0x330306dd, 0x74a95f98) + Filename + record-[$core{date}-$core{time}].csv + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-sig-[$core{date}-$core{time}].csv + false + + + (0x79a9edeb, 0x245d83fc) + Column separator + ; + ; + false + + + (0x007deef9, 0x2f3e95c6) + Precision + 10 + 10 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -16.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 198.000000 + + + (0x4e7b798a, 0x183beafb) + (0x229d1207, 0xebac8ab0) + + + (0x527ad68d, 0x16d746a0) + + + + (0xad100179, 0xa3c984ab) + 92 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x016872c7) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 3 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + (0x00006664, 0x00000ee0) + CSV File Writer + (0x2c9312f1, 0x2d6613e5) + + + (0x6f752dd0, 0x082a321e) + Input stream + + + + + (0x330306dd, 0x74a95f98) + Filename + record-[$core{date}-$core{time}].csv + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-stim-[$core{date}-$core{time}].csv + false + + + (0x79a9edeb, 0x245d83fc) + Column separator + ; + ; + false + + + (0x007deef9, 0x2f3e95c6) + Precision + 10 + 10 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + 32.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 512.000000 + + + (0x4e7b798a, 0x183beafb) + (0x229d1207, 0xebac8ab0) + + + (0x527ad68d, 0x16d746a0) + + + + (0xad100179, 0xa3c984ab) + 92 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0020f6e8) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 3 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + (0x00007957, 0x000045fc) + Stimulation Filter + (0x02f96101, 0x5e647cb8) + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + + + (0x6f752dd0, 0x082a321e) + Modified Stimulations + + + + + (0x09e59e57, 0x8d4a553a) + Default action + Reject + Reject + false + + + (0x512a166f, 0x5c3ef83f) + Time range begin + 0 + 0 + false + + + (0x512a166f, 0x5c3ef83f) + Time range end + 0 + 0 + false + + + (0x09e59e57, 0x8d4a553a) + Action to perform + Select + Select + false + + + (0x2c132d6e, 0x44ab0d97) + Stimulation range begin + OVTK_StimulationId_Label_00 + OVTK_StimulationId_Label_01 + false + + + (0x2c132d6e, 0x44ab0d97) + Stimulation range end + OVTK_StimulationId_Label_0F + OVTK_StimulationId_Label_01 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -96.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 576.000000 + + + (0x4e7b798a, 0x183beafb) + (0x47859b3f, 0x1dfdf5cd) + + + (0x61d11811, 0x71e65362) + + + + (0xad100179, 0xa3c984ab) + 107 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x003d89e1) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xce18836a, 0x9c0eb403) + 6 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + (0x00007957, 0x000045fd) + Stimulation Filter + (0x02f96101, 0x5e647cb8) + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + + + (0x6f752dd0, 0x082a321e) + Modified Stimulations + + + + + (0x09e59e57, 0x8d4a553a) + Default action + Reject + Reject + false + + + (0x512a166f, 0x5c3ef83f) + Time range begin + 0 + 0 + false + + + (0x512a166f, 0x5c3ef83f) + Time range end + 0 + 0 + false + + + (0x09e59e57, 0x8d4a553a) + Action to perform + Select + Select + false + + + (0x2c132d6e, 0x44ab0d97) + Stimulation range begin + OVTK_StimulationId_Label_00 + OVTK_StimulationId_Label_0A + false + + + (0x2c132d6e, 0x44ab0d97) + Stimulation range end + OVTK_StimulationId_Label_0F + OVTK_StimulationId_Label_0A + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -96.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 688.000000 + + + (0x4e7b798a, 0x183beafb) + (0x47859b3f, 0x1dfdf5cd) + + + (0x61d11811, 0x71e65362) + + + + (0xad100179, 0xa3c984ab) + 107 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0026aa9c) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xce18836a, 0x9c0eb403) + 6 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + + + (0x00000de2, 0x00004c62) + + (0x000011b9, 0x00002dbe) + 0 + + + (0x00001ab6, 0x00007dc8) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -25 + + + (0x358ae8b5, 0x0f8bacd1) + 640 + + + (0x3f0a3b27, 0x570913d2) + -6 + + + (0x6267b5c5, 0x676e3e42) + 656 + + + + + (0x00000f72, 0x000029c3) + + (0x000032a2, 0x00004de0) + 0 + + + (0x00007957, 0x000045fc) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -158 + + + (0x358ae8b5, 0x0f8bacd1) + 528 + + + (0x3f0a3b27, 0x570913d2) + -118 + + + (0x6267b5c5, 0x676e3e42) + 576 + + + + + (0x00001ce5, 0x00005f56) + + (0x000011b9, 0x00002dbe) + 0 + + + (0x00006664, 0x00000ee0) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -25 + + + (0x358ae8b5, 0x0f8bacd1) + 640 + + + (0x3f0a3b27, 0x570913d2) + 10 + + + (0x6267b5c5, 0x676e3e42) + 512 + + + + + (0x000025f1, 0x000036df) + + (0x0000430f, 0x00004aa4) + 1 + + + (0x00006664, 0x00000edf) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -174 + + + (0x358ae8b5, 0x0f8bacd1) + 241 + + + (0x3f0a3b27, 0x570913d2) + -38 + + + (0x6267b5c5, 0x676e3e42) + 198 + + + + + (0x00003a78, 0x00004f9a) + + (0x000032a2, 0x00004de0) + 0 + + + (0x00007957, 0x000045fd) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -158 + + + (0x358ae8b5, 0x0f8bacd1) + 528 + + + (0x3f0a3b27, 0x570913d2) + -118 + + + (0x6267b5c5, 0x676e3e42) + 688 + + + + + (0x000047d8, 0x00004fe7) + + (0x00007957, 0x000045fc) + 0 + + + (0x000011b9, 0x00002dbe) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -73 + + + (0x358ae8b5, 0x0f8bacd1) + 576 + + + (0x3f0a3b27, 0x570913d2) + -70 + + + (0x6267b5c5, 0x676e3e42) + 632 + + + + + (0x0000547f, 0x00003283) + + (0x000032a2, 0x00004de0) + 0 + + + (0x00003f97, 0x0000658d) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -158 + + + (0x358ae8b5, 0x0f8bacd1) + 528 + + + (0x3f0a3b27, 0x570913d2) + -112 + + + (0x6267b5c5, 0x676e3e42) + 448 + + + + + (0x00005e4e, 0x0000148d) + + (0x00007957, 0x000045fd) + 0 + + + (0x000011b9, 0x00002dbe) + 1 + + + + (0x1b32c44c, 0x1905e0e9) + -73 + + + (0x358ae8b5, 0x0f8bacd1) + 688 + + + (0x3f0a3b27, 0x570913d2) + -70 + + + (0x6267b5c5, 0x676e3e42) + 647 + + + + + (0x00006f5f, 0x0000311f) + + (0x0000430f, 0x00004aa4) + 1 + + + (0x00002750, 0x00001fb2) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -174 + + + (0x358ae8b5, 0x0f8bacd1) + 241 + + + (0x3f0a3b27, 0x570913d2) + -38 + + + (0x6267b5c5, 0x676e3e42) + 289 + + + + + + + + (0x000078f4, 0x0000293f) + <u><b><big>Overview</big></b></u> + +This scenario is used for collecting data from acquisition client + and saving it to a csv file. + +Keyboard stimulations are also logged (and saved to csv file): + <i>a</i> or <i>p</i> mark stimulation time, + <i>z</i> finishes this scenario. + + + (0x473d9a43, 0x97fc0a97) + 928.000000 + + + (0x7234b86b, 0x2b8651a5) + -112.000000 + + + + + + + (0x00001bb7, 0x000007cd) + Default window + 1 + (0xffffffff, 0xffffffff) + (0xffffffff, 0xffffffff) + 1 + + + (0x4c90d4ad, 0x7a2554ec) + 320 + + + (0x7b814cca, 0x271df6dd) + 475 + + + + + (0x00001f0e, 0x00000ff8) + Default tab + 2 + (0x00001bb7, 0x000007cd) + 0 + (0xffffffff, 0xffffffff) + 1 + + + (0x00000e21, 0x000020fb) + Vertical split + 4 + (0x00001f0e, 0x00000ff8) + 0 + (0xffffffff, 0xffffffff) + 2 + + + (0x237e56d2, 0x10cd68ae) + 277 + + + (0x54e45f5b, 0x76c036e2) + 136 + + + + + (0x00000dcf, 0x00002041) + 3 + (0x00000e21, 0x000020fb) + 0 + (0x000032a2, 0x00004de0) + 0 + + + (0x0000709d, 0x0000789f) + 3 + (0x00000e21, 0x000020fb) + 1 + (0x00002750, 0x00001fb2) + 0 + + + + + (0x790d75b8, 0x3bb90c33) + + + + (0x8c1fc55b, 0x7b433dc2) + + + + (0x9f5c4075, 0x4a0d3666) + + + + (0xf36a1567, 0xd13c53da) + + + + (0xf6b2e3fa, 0x7bd43926) + + + + (0xf8034a49, 0x8b3f37cc) + + + + \ No newline at end of file diff --git a/openvibe-scenarios/free-will-bci-2-classifier-trainer.xml b/openvibe-scenarios/free-will-bci-2-classifier-trainer.xml new file mode 100644 index 0000000..233a30e --- /dev/null +++ b/openvibe-scenarios/free-will-bci-2-classifier-trainer.xml @@ -0,0 +1,692 @@ + + OpenViBE + 1.3.0 + + + (0x00000124, 0x0000214f) + Python scripting + (0x5dc4f669, 0xd3fd4d64) + + + (0x6f752dd0, 0x082a321e) + EndStimulation + + + + + (0x007deef9, 0x2f3e95c6) + Clock frequency (Hz) + 64 + 64 + false + + + (0xb0d0db45, 0x49cbc34a) + Script + + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/scripts/python-learning.py + false + + + (0x330306dd, 0x74a95f98) + InputCSVSignal + + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-sig-[2017.05.15-23.11.00].csv + false + + + (0x330306dd, 0x74a95f98) + InputCSVStimulations + + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-stim-[2017.05.15-23.11.00].csv + false + + + (0x330306dd, 0x74a95f98) + SaveFile + + + false + + + (0x007deef9, 0x2f3e95c6) + WindowSize (ms) + 100 + 100 + false + + + (0x007deef9, 0x2f3e95c6) + NumOfPrevWindows + 5 + 4 + false + + + (0x007deef9, 0x2f3e95c6) + NumOfWindowsBefore + 0 + 4 + false + + + (0x007deef9, 0x2f3e95c6) + NumOfWindowsAfter + 0 + 0 + false + + + (0x007deef9, 0x2f3e95c6) + K-folds + 4 + 10 + false + + + + + (0x17ee7c08, 0x94c14893) + + + + (0x1fa7a38f, 0x54edbe0b) + 16.000000 + + + (0x1fa963f5, 0x1a638cd4) + 34 + + + (0x207c9054, 0x3c841b63) + 224.000000 + + + (0x30a4e5c9, 0x83502953) + + + + (0x4e7b798a, 0x183beafb) + (0x2a651510, 0xb4fad0d4) + + + (0x527ad68d, 0x16d746a0) + + + + (0x61d11811, 0x71e65362) + + + + (0xad100179, 0xa3c984ab) + 102 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x00055fbe) + + + (0xc67a01dc, 0x28ce06c1) + + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 2 + + + (0xf191c1c8, 0xa0123976) + + + + (0xfba64161, 0x65304e21) + + + + + + (0x00000d51, 0x000039af) + CSV File Reader + (0x641d0717, 0x02884107) + + + (0x6f752dd0, 0x082a321e) + Output stream + + + + + (0x330306dd, 0x74a95f98) + Filename + + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-stim-[2017.05.15-23.11.00].csv + false + + + (0x79a9edeb, 0x245d83fc) + Column separator + ; + ; + false + + + (0x2cdb2f0b, 0x12f231ea) + Don't use the file time + false + false + false + + + (0x007deef9, 0x2f3e95c6) + Unused parameter + 32 + 0 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -128.000000 + + + (0x1fa963f5, 0x1a638cd4) + 45 + + + (0x207c9054, 0x3c841b63) + 496.000000 + + + (0x30a4e5c9, 0x83502953) + + + + (0x4e7b798a, 0x183beafb) + (0x3bf57676, 0xad3aaefa) + + + (0xad100179, 0xa3c984ab) + 97 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0001d5c4) + + + (0xc73e83ec, 0xf855c5bc) + true + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xce18836a, 0x9c0eb403) + 4 + + + + + (0x000055e6, 0x00000489) + Player Controller + (0x5f426dce, 0x08456e13) + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + + + (0x2c132d6e, 0x44ab0d97) + Stimulation name + OVTK_StimulationId_Label_00 + OVTK_StimulationId_TrialStop + false + + + (0xcc14d8d6, 0xf27ecb73) + Action to perform + Pause + Stop + false + + + + + (0x1fa7a38f, 0x54edbe0b) + 96.000000 + + + (0x1fa963f5, 0x1a638cd4) + 23 + + + (0x207c9054, 0x3c841b63) + 240.000000 + + + (0x4e7b798a, 0x183beafb) + (0x568d148e, 0x650792b3) + + + (0xad100179, 0xa3c984ab) + 105 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x00284de3) + + + (0xc73e83ec, 0xf855c5bc) + false + + + (0xce18836a, 0x9c0eb403) + 2 + + + (0xcfad85b0, 0x7c6d841c) + 1 + + + + + (0x00006c4c, 0x000002b3) + CSV File Reader + (0x641d0717, 0x02884107) + + + (0x5ba36127, 0x195feae1) + Output stream + + + + + (0x330306dd, 0x74a95f98) + Filename + + E:/Tilen/FAX/2. stopnja/UI/projekt-bci/free-will/signals/record-sig-[2017.05.15-23.11.00].csv + false + + + (0x79a9edeb, 0x245d83fc) + Column separator + ; + ; + false + + + (0x2cdb2f0b, 0x12f231ea) + Don't use the file time + false + false + false + + + (0x007deef9, 0x2f3e95c6) + Samples per buffer + 32 + 32 + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -128.000000 + + + (0x1fa963f5, 0x1a638cd4) + 45 + + + (0x207c9054, 0x3c841b63) + 384.000000 + + + (0x30a4e5c9, 0x83502953) + + + + (0x4e7b798a, 0x183beafb) + (0x3bf57676, 0xad3aaefa) + + + (0xad100179, 0xa3c984ab) + 97 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x0007fed6) + + + (0xc73e83ec, 0xf855c5bc) + true + + + (0xc80ce8af, 0xf699f813) + 1 + + + (0xce18836a, 0x9c0eb403) + 4 + + + + + (0x00006ed7, 0x000003cf) + Signal display + (0x0055be5f, 0x087bdd12) + + + (0x5ba36127, 0x195feae1) + Data + + + (0x6f752dd0, 0x082a321e) + Stimulations + + + (0x6ab26b81, 0x0f8c02f3) + Channel Units + + + + + (0x5de046a6, 0x086340aa) + Display Mode + Scan + Scan + false + + + (0x33a30739, 0x00d5299b) + Auto vertical scale + Per channel + Per channel + false + + + (0x512a166f, 0x5c3ef83f) + Scale refresh interval (secs) + 5 + 5 + false + + + (0x512a166f, 0x5c3ef83f) + Vertical Scale + 100 + 100 + false + + + (0x512a166f, 0x5c3ef83f) + Vertical Offset + 0 + 0 + false + + + (0x512a166f, 0x5c3ef83f) + Time Scale + 10 + 10 + false + + + (0x2cdb2f0b, 0x12f231ea) + Bottom ruler + true + true + false + + + (0x2cdb2f0b, 0x12f231ea) + Left ruler + false + false + false + + + (0x2cdb2f0b, 0x12f231ea) + Multiview + false + false + false + + + + + (0x1fa7a38f, 0x54edbe0b) + -64.000000 + + + (0x1fa963f5, 0x1a638cd4) + 45 + + + (0x207c9054, 0x3c841b63) + 432.000000 + + + (0x4e7b798a, 0x183beafb) + (0x92c056a7, 0x2dc71aff) + + + (0x527ad68d, 0x16d746a0) + + + + (0xad100179, 0xa3c984ab) + 87 + + + (0xc46b3d00, 0x3e0454e1) + (0x00000000, 0x00024b35) + + + (0xc73e83ec, 0xf855c5bc) + true + + + (0xce18836a, 0x9c0eb403) + 9 + + + (0xcfad85b0, 0x7c6d841c) + 3 + + + + + + + (0x00000e16, 0x00006760) + + (0x00006c4c, 0x000002b3) + 0 + + + (0x00006ed7, 0x000003cf) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + -99 + + + (0x358ae8b5, 0x0f8bacd1) + 384 + + + (0x3f0a3b27, 0x570913d2) + -91 + + + (0x6267b5c5, 0x676e3e42) + 417 + + + + + (0x000011ac, 0x000063f9) + + (0x00000d51, 0x000039af) + 0 + + + (0x00006ed7, 0x000003cf) + 1 + + + + (0x1b32c44c, 0x1905e0e9) + -99 + + + (0x358ae8b5, 0x0f8bacd1) + 496 + + + (0x3f0a3b27, 0x570913d2) + -91 + + + (0x6267b5c5, 0x676e3e42) + 432 + + + + + (0x00004464, 0x0000753e) + + (0x00000124, 0x0000214f) + 0 + + + (0x000055e6, 0x00000489) + 0 + + + + (0x1b32c44c, 0x1905e0e9) + 39 + + + (0x358ae8b5, 0x0f8bacd1) + 224 + + + (0x3f0a3b27, 0x570913d2) + 80 + + + (0x6267b5c5, 0x676e3e42) + 240 + + + + + + + + (0x6160f9b8, 0x37b083c2) + <u><b><big>Overview</big></b></u> + +This scenario is used to train data for the "free will experiment". +Main Python script settings are: + signals (csv) + keyboard stimulations (csv) + output file (python pickle) - trained (e.g. ./python-out-[$core{date}-$core{time}].pkl) + + + + (0x473d9a43, 0x97fc0a97) + -96.000000 + + + (0x7234b86b, 0x2b8651a5) + -64.000000 + + + + + + + (0x00003e01, 0x000020d2) + 3 + (0xffffffff, 0xffffffff) + (0x00006ed7, 0x000003cf) + 0 + + + (0x0c60317a, 0x7480157f) + Default window + 1 + (0xffffffff, 0xffffffff) + (0xffffffff, 0xffffffff) + 1 + + + (0x4c90d4ad, 0x7a2554ec) + 1 + + + (0x7b814cca, 0x271df6dd) + 1 + + + + + (0x4eff2d5e, 0x057e5a93) + Default tab + 2 + (0x0c60317a, 0x7480157f) + 0 + (0xffffffff, 0xffffffff) + 1 + + + (0x00b5ee2a, 0x40e0a42c) + Empty + 0 + (0x4eff2d5e, 0x057e5a93) + 0 + (0xffffffff, 0xffffffff) + 0 + + + + + (0x790d75b8, 0x3bb90c33) + Yann Renard / Fabien Lotte + + + (0x8c1fc55b, 0x7b433dc2) + + + + (0x9f5c4075, 0x4a0d3666) + Classifier Training + + + (0xf36a1567, 0xd13c53da) + + + + (0xf6b2e3fa, 0x7bd43926) + Motor Imagery + + + (0xf8034a49, 0x8b3f37cc) + INRIA + + + \ No newline at end of file diff --git a/scripts/python-learning.py b/scripts/python-learning.py new file mode 100644 index 0000000..d144678 --- /dev/null +++ b/scripts/python-learning.py @@ -0,0 +1,157 @@ +import numpy as np +import pandas +from math import ceil, floor +from sklearn.model_selection import train_test_split +from sklearn import svm +from sklearn.model_selection import KFold, StratifiedKFold, permutation_test_score +from sklearn import linear_model +from sklearn.svm import SVC +import pickle +import matplotlib.pyplot as plt +import numpy.fft as fft +from sklearn import datasets + +class MyOVBox(OVBox): + def __init__(self): + OVBox.__init__(self) + # Names of CSV files + self.signalFileName = "" + self.stimFileName = "" + # Name of Save File + self.saveFileName = "" + # other variables + self.windowSize = 0 # window size in ms + self.numOfPreviousWindowsAsOne = 0 # number of windows before actual stimulation to be marked as 1 + self.numOfWindowsBefore = 0 # number of windows before those marked as 1, to be marked as 0 + self.numOfWindowsAfter = 0 # number of windows after those marked as 1, to be marked as 0 + + + def filter_signal(self, sampleRate, numberOfSamplesWindow, stimulationTimes, splittedSignal): + """ returns tuple of filtered (signal chunks, classes) """ + splittedSignal_filtrd = [] + classes_filtrd = [] + + temp_classes = np.zeros(len(splittedSignal)) + + for stim in stimulationTimes: + index = int(floor(stim*sampleRate/numberOfSamplesWindow)) + temp_classes[index] = 1 + for i in range(1, self.numOfPreviousWindowsAsOne): + temp_classes[index-i] = 1 + + tmp_cls_winds = temp_classes[(index - self.numOfPreviousWindowsAsOne - self.numOfWindowsBefore):index+self.numOfWindowsAfter] + tmp_sig_winds = np.concatenate(splittedSignal[(index - self.numOfPreviousWindowsAsOne - self.numOfWindowsBefore):index+self.numOfWindowsAfter]) + + if len(tmp_sig_winds)/len(tmp_cls_winds)!=numberOfSamplesWindow: # if np.array_split does not split in equal windows + tmp_sig_winds = np.lib.pad(tmp_sig_winds, ((0, int(len(tmp_cls_winds)*numberOfSamplesWindow-len(tmp_sig_winds))),(0, 0)), 'edge') # pad with same values on end of array + + classes_filtrd.extend(tmp_cls_winds) + splittedSignal_filtrd.extend(np.array_split(tmp_sig_winds, len(tmp_cls_winds))) + + return (splittedSignal_filtrd, classes_filtrd) + + + def avg_k_fold(self, data, classes, k=4): + """ return average CA of k-fold cross validation """ + avg_val = 0 + + kf = KFold(n_splits=k) + for train, test in kf.split(data): + clf = svm.SVC(kernel='linear', C=1).fit(data[train], classes[train]) + cur_score = clf.score(data[test], classes[test]) + avg_val += cur_score + # print cur_score + return avg_val/k + + + def permutation_significance_classification_score(self, X, y, k_folds=4): + n_classes = np.unique(y).size + + svm = SVC(kernel='linear') + cv = StratifiedKFold(k_folds) + + score, permutation_scores, pvalue = permutation_test_score(svm, X, y, scoring="accuracy", cv=cv, n_permutations=200, n_jobs=1) + print("Classification score %s (pvalue : %s)" % (score, pvalue)) + + plt.hist(permutation_scores, 20, label='Permutation scores') + ylim = plt.ylim() + plt.plot(2 * [score], ylim, '--g', linewidth=3, + label='Classification Score' + ' (pvalue %s)' % pvalue) + plt.plot(2 * [1. / n_classes], ylim, '--k', linewidth=3, label='Luck') + + plt.ylim(ylim) + plt.legend() + plt.xlabel('Score') + plt.show() + + + def initialize(self): + # Names of CSV files + self.signalFileName = self.setting['InputCSVSignal'] + self.stimFileName = self.setting['InputCSVStimulations'] + # Name of Save File + self.saveFileName = self.setting['SaveFile'] + # other variables + self.windowSize = int(self.setting['WindowSize (ms)']) # in ms + self.numOfPreviousWindowsAsOne = int(self.setting['NumOfPrevWindows']) + self.numOfWindowsBefore = int(self.setting['NumOfWindowsBefore'])-1 + self.numOfWindowsAfter = int(self.setting['NumOfWindowsAfter'])+1 + self.k_folds = int(self.setting['K-folds']) + + print "Reading files..." + # read CSV files + signalArray = pandas.read_csv(self.signalFileName, delimiter=";", encoding="utf-8-sig") + stimsArray = pandas.read_csv(self.stimFileName, delimiter=";", encoding="utf-8-sig") + print "Files read!" + + # sort information from tables (pandas dataframe) + time = signalArray['Time (s)'] + electrodes = signalArray.iloc[:, 1:signalArray.shape[1]-1] + sampleRate = signalArray['Sampling Rate'][0] + stimulationTimes = stimsArray['Time (s)'] + + numberOfSamplesWindow = floor(self.windowSize / ((1/sampleRate)*1000)) # number of samples for approximately self.windowSize ms + + splittedSignal = np.array_split(electrodes, ceil(len(time)/numberOfSamplesWindow)) # split signal into chunks of specified length + + s_c = self.filter_signal(sampleRate, numberOfSamplesWindow, stimulationTimes, splittedSignal) # filter signal and return sparsed version of chunks and assign classes + splittedSignal_filtrd = s_c[0] + classes_filtrd = s_c[1] + + splittedSignal_filtrd_means = np.array(np.mean(splittedSignal_filtrd, axis=1)) # for each window calculate mean value + # additional attributes could be added besides splittedSignal_filtrd_means + classes_filtrd = np.array(classes_filtrd) + + # print average k-fold CA + print "Average " + str(self.k_folds) + "-folds value: " + str(self.avg_k_fold(splittedSignal_filtrd_means, classes_filtrd, k=self.k_folds)) + #self.permutation_significance_classification_score(splittedSignal_filtrd_means, classes_filtrd, k_folds=2) # k_folds=2, last long if k is bigger + + if self.saveFileName: + clf = svm.SVC(kernel='linear', C=1).fit(splittedSignal_filtrd_means, classes_filtrd) + clf.fit(splittedSignal_filtrd_means, classes_filtrd) + + print "Saving to pickle file: " + self.saveFileName + pickle.dump(clf, open(self.saveFileName, 'wb')) + print "Learned score: " + str(clf.score(splittedSignal_filtrd_means, classes_filtrd)) + + # send finish stimulation output (for OpenViBE) + self.finishBySendingStimulation(32774) # OVTK_StimulationId_TrialStop code + + + def finishBySendingStimulation(self, stimulationCode): + stimSetFinish = OVStimulationSet(self.getCurrentTime(), self.getCurrentTime()+1./self.getClock()) + stimSetFinish.append(OVStimulation(stimulationCode, self.getCurrentTime(), 0.)) + self.output[0].append(stimSetFinish) + + + def process(self): + + return + + def uninitialize(self): + # nop + + return + +box = MyOVBox() -- cgit v1.2.1