Commit 588bfc63 authored by Jussi Lindgren's avatar Jussi Lindgren
Browse files

Demos: Changed basic P300 to use the TCP Tagging

- Refactored the scenarios for simplicity
- Added a .lua evidence accumulator
- Added signal monitoring scenario
- The scenarios are now started and stopped automatically
parent e5349a3a
<OpenViBE-Classifier-Box XMLVersion="3">
<OpenViBE-Classifier-Box Creator="OpenViBE" CreatorVersion="1.1.0+git" FormatVersion="4">
<Strategy-Identifier class-id="(0xffffffff, 0xffffffff)">Native</Strategy-Identifier>
<Algorithm-Identifier class-id="(0x2ba17a3c, 0x1bd46d84)">Linear Discrimimant Analysis (LDA)</Algorithm-Identifier>
<Stimulations>
<Class-Stimulation class-id="1">OVTK_StimulationId_Target</Class-Stimulation>
<Class-Stimulation class-id="2">OVTK_StimulationId_NonTarget</Class-Stimulation>
<Class-Stimulation class-id="0">OVTK_StimulationId_Target</Class-Stimulation>
<Class-Stimulation class-id="1">OVTK_StimulationId_NonTarget</Class-Stimulation>
</Stimulations>
<OpenViBE-Classifier>
<LDA>
<Classes>1 2</Classes>
<Weights> 2.788846e-01 -1.122471e+00 2.164470e+00 -2.957937e+00 2.632470e+00 -1.638885e+00 6.718423e-01 -7.494955e-01 2.379651e+00 -4.224808e+00 3.950335e+00 -1.852475e+00 -6.092394e-02 5.627513e-02 1.828955e+00 -3.954360e+00 4.690897e+00 -5.166551e+00 6.151087e+00 -7.059424e+00 6.432108e+00 -4.336309e+00 2.218110e+00 -1.074637e+00 5.929140e-01 6.133761e-01 -3.101826e+00 5.048640e+00 -3.994446e+00 1.083226e-01 4.256880e+00 -6.873903e+00 7.055432e+00 -5.111542e+00 1.944769e+00 5.581962e-01 -1.676402e+00 2.001469e+00 -1.758784e+00 8.965195e-01 7.835967e-01 -3.182957e+00 4.310634e+00 -2.844162e+00 -7.053243e-01 3.378794e+00 -4.059860e+00 2.886281e+00 -6.357868e-03 -3.753546e+00 6.490507e+00 -6.529640e+00 4.608213e+00 -1.664671e+00 -1.729412e+00 4.667642e+00 -5.899998e+00 5.417937e+00 -4.484638e+00 4.006807e+00 -4.812335e+00 6.103574e+00 -7.079280e+00 6.160450e+00 -4.630850e+00 3.491447e+00 -3.148471e+00 3.054428e+00 -2.820719e+00 2.331788e+00 -1.871674e+00 1.418598e+00 -7.692494e-01 -7.786517e-02 3.789148e-01 -2.811530e-01 -2.903889e-01 8.881550e-01 -1.118793e+00 6.134973e-01 1.058749e-01 -5.624865e-01 1.542167e+00 -3.016252e+00 3.962291e+00 -3.673483e+00 2.351598e+00 -9.832863e-01 4.307074e-01 -7.254268e-01 9.597880e-01 -2.879473e-01 -6.670603e-01 9.716788e-01 -4.880760e-01 -5.029065e-01 1.293465e+00 -2.062114e+00 2.454176e+00 -1.968836e+00 7.584638e-01 -2.974238e-01 7.048767e-01 -1.385533e+00 9.633263e-01 -2.736620e-01 -2.678118e-01 6.337444e-01 -1.005500e+00 1.015370e+00 6.687944e-02 -1.141423e+00 1.467313e+00 -4.432029e-01 -1.135294e+00 2.515996e+00 -3.343496e+00 3.543582e+00 -2.443267e+00 2.340056e-01 1.581325e+00 -1.468838e+00 -3.439434e-02 1.453805e+00 -1.788584e+00 7.089513e-01 1.447161e+00 -3.067459e+00 3.667993e+00 -3.252550e+00 2.033979e+00 -5.313978e-01 -9.364283e-01 1.697950e+00 -2.495870e+00 3.408867e+00 -3.763545e+00 3.124299e+00 -1.795916e+00 8.306866e-01 -9.991886e-01 2.020367e+00 -2.645615e+00 2.179694e+00 -4.116460e-01 -1.873979e+00 3.574389e+00 -3.596222e+00 1.815104e+00 -1.566036e-01 -2.857118e-01 7.772513e-03 3.410261e-01 -1.243986e+00 1.750566e+00 -1.378135e+00 5.584738e-01 4.745912e-02 -8.158169e-01 1.588576e+00 -2.049209e+00 1.781106e+00 -1.138149e+00 5.943333e-01 -9.959784e-01 2.635706e+00 -4.264460e+00 4.126643e+00 -2.568374e+00 1.155718e+00 -6.790422e-01 7.992789e-01 -5.023935e-01 1.783391e-01 -6.232566e-02 5.086320e-01 -5.835395e-01 4.923490e-01 -5.633949e-01 6.785578e-01 -5.501961e-01 2.632669e-01 1.587462e-02 -3.697765e-01 5.981566e-01 -9.209487e-01 7.606069e-01 -1.257886e-01 -4.329710e-01 1.713266e-01 5.377232e-01 -1.287311e+00 1.571565e+00 -1.333638e+00 5.628408e-01 3.082389e-01 -1.014827e+00 9.812811e-01 -4.590905e-01 -3.178201e-01 1.082162e+00 -1.413803e+00 5.445176e-01 3.833224e-01 -1.302872e-02 -1.669525e+00 3.614410e+00 -5.024037e+00 5.749633e+00 -5.845777e+00 5.973101e+00 -6.012042e+00 6.054453e+00 -5.705018e+00 5.129180e+00 -4.542303e+00 4.232312e+00 -4.139350e+00 3.698846e+00 -2.835621e+00 1.360124e+00 3.616565e-01 -1.752720e+00 1.834871e+00 -6.532813e-01 -7.340541e-01 9.730762e-01 -4.200004e-01</Weights>
<Bias-distance>-2.53985</Bias-distance>
<Coefficient-probability>-4.14929</Coefficient-probability>
<LDA version="1">
<Classes>0 1 </Classes>
<Class-config-list>
<Class-config>
<Weights> 3.434092e+000 2.705205e+000 2.086142e+000 1.594799e+000 1.231493e+000 9.581091e-001 7.258104e-001 4.831216e-001 1.901807e-001 -1.624920e-001 -5.629088e-001 -9.776181e-001 -1.334017e+000 -1.577847e+000 -1.673846e+000 -1.625628e+000 -1.475285e+000 -1.273815e+000 -1.089853e+000 -9.287371e-001 -7.822289e-001 -6.663571e-001 -6.104988e-001 -6.165613e-001 -6.306103e-001 -5.826009e-001 -4.212622e-001 -1.382083e-001 2.233983e-001 5.964180e-001 9.201849e-001 1.145087e+000 1.248840e+000 1.243446e+000 1.170518e+000 1.042176e+000 8.767856e-001 7.397948e-001 6.881664e-001 7.366396e-001 8.488970e-001 9.680029e-001 1.016899e+000 9.569641e-001 7.719242e-001 4.917017e-001 1.732677e-001 -1.479380e-001 -4.359757e-001 -6.524118e-001 -7.743571e-001 -8.174914e-001 -7.979972e-001 -7.355631e-001 -6.904219e-001 -7.209770e-001 -8.344268e-001 -1.010158e+000 -1.205415e+000 -1.364479e+000 -1.425065e+000 -1.366499e+000 -1.215070e+000 -9.831914e-001 -6.658455e-001 -2.763964e-001 1.321727e-001 5.001361e-001 7.735486e-001 9.407206e-001 1.054063e+000 1.196583e+000 1.437459e+000 1.798990e+000 2.269188e+000 2.833756e+000 2.424267e+002 2.257611e+002 2.137178e+002 2.106454e+002 2.132259e+002 2.141048e+002 2.095676e+002 2.033879e+002 2.029140e+002 2.114264e+002 2.245883e+002 2.345922e+002 2.377758e+002 2.379615e+002 2.421230e+002 2.528255e+002 2.651464e+002 2.712601e+002 2.680619e+002 2.599821e+002 2.541965e+002 2.531206e+002 2.518413e+002 2.431471e+002 2.249577e+002 2.026226e+002 1.837407e+002 1.707598e+002 1.588604e+002 1.413403e+002 1.170053e+002 9.191275e+001 7.371371e+001 6.436686e+001 5.863041e+001 4.984555e+001 3.707988e+001 2.638283e+001 2.481421e+001 3.332532e+001 4.579538e+001 5.520206e+001 6.062199e+001 6.788309e+001 8.324502e+001 1.065870e+002 1.310536e+002 1.495513e+002 1.614860e+002 1.728274e+002 1.895248e+002 2.109972e+002 2.303253e+002 2.409464e+002 2.431054e+002 2.434376e+002 2.481200e+002 2.565654e+002 2.621273e+002 2.590737e+002 2.487108e+002 2.383863e+002 2.343835e+002 2.359352e+002 2.364496e+002 2.306878e+002 2.205487e+002 2.135155e+002 2.153543e+002 2.244847e+002 2.338086e+002 2.380825e+002 2.392942e+002 2.445471e+002 2.586597e+002 2.789935e+002 4.468064e+002 4.239043e+002 4.248295e+002 4.203987e+002 3.902671e+002 3.646270e+002 3.629376e+002 3.545009e+002 3.211344e+002 2.943518e+002 2.913024e+002 2.799948e+002 2.445961e+002 2.178666e+002 2.146860e+002 2.020538e+002 1.666528e+002 1.423388e+002 1.415910e+002 1.305076e+002 9.823791e+001 7.946273e+001 8.407391e+001 7.727933e+001 5.066141e+001 3.945746e+001 5.083663e+001 4.922326e+001 2.856578e+001 2.436917e+001 4.104524e+001 4.255658e+001 2.542922e+001 2.541369e+001 4.427610e+001 4.580769e+001 2.920517e+001 3.041689e+001 4.871027e+001 4.798181e+001 3.015880e+001 3.115999e+001 4.766641e+001 4.379313e+001 2.411109e+001 2.427204e+001 3.833645e+001 3.074456e+001 8.559288e+000 6.850707e+000 1.702316e+001 4.085874e+000 -2.231973e+001 -2.777166e+001 -2.335324e+001 -4.324713e+001 -7.518487e+001 -8.542128e+001 -8.735025e+001 -1.140272e+002 -1.505847e+002 -1.641400e+002 -1.703156e+002 -2.008847e+002 -2.385271e+002 -2.515589e+002 -2.579533e+002 -2.882401e+002 -3.228688e+002 -3.316025e+002 -3.347399e+002 -3.615128e+002 -3.903541e+002 -3.926745e+002 -3.909804e+002 -4.129742e+002</Weights>
<Bias>-0.732402</Bias>
</Class-config>
<Class-config>
<Weights> 1.468671e+000 1.139725e+000 8.610058e-001 6.551117e-001 5.198994e-001 4.235491e-001 3.364961e-001 2.316383e-001 9.713011e-002 -5.228631e-002 -2.058491e-001 -3.593909e-001 -4.977705e-001 -5.942216e-001 -6.368792e-001 -6.291036e-001 -5.834634e-001 -5.044126e-001 -4.095518e-001 -3.157517e-001 -2.439381e-001 -2.187321e-001 -2.400007e-001 -2.889696e-001 -3.318311e-001 -3.405924e-001 -3.036683e-001 -2.100426e-001 -5.716983e-002 1.317133e-001 3.128379e-001 4.395425e-001 4.897473e-001 4.749661e-001 4.204584e-001 3.578356e-001 3.192350e-001 3.149937e-001 3.450923e-001 3.953789e-001 4.469702e-001 4.892185e-001 5.092231e-001 4.956822e-001 4.407182e-001 3.367923e-001 1.932630e-001 2.815875e-002 -1.252046e-001 -2.372722e-001 -2.934513e-001 -3.075615e-001 -2.956700e-001 -2.713938e-001 -2.519518e-001 -2.578920e-001 -3.028288e-001 -3.894065e-001 -5.022084e-001 -6.019157e-001 -6.635225e-001 -6.859249e-001 -6.610191e-001 -5.750917e-001 -4.258399e-001 -2.431952e-001 -6.357440e-002 9.130921e-002 2.184216e-001 3.193277e-001 4.006294e-001 4.988884e-001 6.535626e-001 8.857274e-001 1.199449e+000 1.575036e+000 1.931937e+002 1.795685e+002 1.700473e+002 1.669164e+002 1.670313e+002 1.652038e+002 1.596132e+002 1.537258e+002 1.527416e+002 1.581890e+002 1.662238e+002 1.713543e+002 1.718020e+002 1.710329e+002 1.739037e+002 1.813857e+002 1.892605e+002 1.921223e+002 1.886133e+002 1.825625e+002 1.788878e+002 1.784298e+002 1.770270e+002 1.697511e+002 1.560049e+002 1.402579e+002 1.276673e+002 1.190624e+002 1.103916e+002 9.719009e+001 7.951480e+001 6.225498e+001 5.051937e+001 4.478066e+001 4.074938e+001 3.406083e+001 2.498071e+001 1.834736e+001 1.877615e+001 2.600679e+001 3.516451e+001 4.167303e+001 4.577824e+001 5.210539e+001 6.466202e+001 8.242783e+001 1.000619e+002 1.129707e+002 1.216221e+002 1.306798e+002 1.438775e+002 1.598758e+002 1.733272e+002 1.800891e+002 1.812492e+002 1.818994e+002 1.858670e+002 1.918147e+002 1.946740e+002 1.909706e+002 1.825531e+002 1.749498e+002 1.720122e+002 1.722799e+002 1.707965e+002 1.644952e+002 1.556346e+002 1.497847e+002 1.503967e+002 1.554622e+002 1.597209e+002 1.601280e+002 1.589704e+002 1.614934e+002 1.704428e+002 1.830880e+002 -3.401275e+001 -2.710886e+001 -2.600548e+001 -2.644902e+001 -1.870585e+001 -7.015843e+000 -7.449469e-001 4.712901e+000 1.839198e+001 3.499500e+001 4.516100e+001 5.389732e+001 6.967695e+001 8.644705e+001 9.523185e+001 1.017642e+002 1.142757e+002 1.263740e+002 1.298917e+002 1.315520e+002 1.394725e+002 1.469714e+002 1.466189e+002 1.458835e+002 1.524904e+002 1.592568e+002 1.592251e+002 1.602075e+002 1.690850e+002 1.778154e+002 1.796651e+002 1.826436e+002 1.927672e+002 2.012925e+002 2.019411e+002 2.030872e+002 2.101458e+002 2.140927e+002 2.095367e+002 2.055484e+002 2.072256e+002 2.055201e+002 1.960380e+002 1.885142e+002 1.876315e+002 1.841939e+002 1.745814e+002 1.687877e+002 1.706464e+002 1.704589e+002 1.650220e+002 1.642437e+002 1.708598e+002 1.745740e+002 1.725839e+002 1.747549e+002 1.829360e+002 1.865939e+002 1.836986e+002 1.843619e+002 1.898718e+002 1.898471e+002 1.833509e+002 1.809434e+002 1.834908e+002 1.808482e+002 1.730419e+002 1.707670e+002 1.741691e+002 1.730347e+002 1.679870e+002 1.694727e+002 1.765826e+002 1.788130e+002 1.771899e+002 1.817473e+002</Weights>
<Bias>-0.696572</Bias>
</Class-config>
</Class-config-list>
</LDA>
</OpenViBE-Classifier>
</OpenViBE-Classifier-Box>
</OpenViBE-Classifier-Box>
\ No newline at end of file
function arrayMax(a)
if #a == 0 then return nil, nil end
local maxIdx, maxValue = 1, a[1]
for i = 2, #a do
if maxValue < a[i] then
maxIdx, maxValue = i, a[i]
end
end
return maxIdx, maxValue
end
-- For handling target fifo
List = {}
function List.new ()
return {first = 0, last = -1}
end
function List.pushright (list, value)
local last = list.last + 1
list.last = last
list[last] = value
end
function List.popleft (list)
local first = list.first
if first > list.last then
error("list is empty")
end
local value = list[first]
list[first] = nil -- to allow garbage collection
list.first = first + 1
return value
end
function List.isempty (list)
if list.first > list.last then
return true
else
return false
end
end
-- this function is called when the box is initialized
function initialize(box)
dofile(box:get_config("${Path_Data}") .. "/plugins/stimulation/lua-stimulator-stim-codes.lua")
row_base = _G[box:get_setting(2)]
col_base = _G[box:get_setting(3)]
segment_start = _G[box:get_setting(4)]
segment_stop = _G[box:get_setting(5)]
-- 0 inactive, 1 segment started, 2 segment stopped (can vote)
segment_status = 0
-- the idea is to push the flash states to the fifo, and when predictions arrive (with some delay), they are matched in oldest-first fashion.
target_fifo = List.new()
-- box:log("Info", string.format("pop %d %d", id[1], id[2]))
row_votes = {}
col_votes = {}
do_debug = false
end
-- this function is called when the box is uninitialized
function uninitialize(box)
end
function process(box)
-- loops until box is stopped
while box:keep_processing() do
-- first, parse the timeline stream
for stimulation = 1, box:get_stimulation_count(2) do
-- gets the received stimulation
local identifier, date, duration = box:get_stimulation(2, 1)
-- discards it
box:remove_stimulation(2, 1)
if identifier == segment_start then
if do_debug then
box:log("Info", string.format("Trial start"))
box:log("Info", string.format("Clear votes"))
end
-- zero the votes
col_votes = {}
row_votes = {}
target_fifo = List.new()
-- fixme fixed 20
for i = 0,20 do
col_votes[i] = 0
row_votes[i] = 0
end
segment_status = 1
end
-- Does the identifier code a flash? if so, put into fifo
if segment_status == 1 and identifier >= row_base and identifier <= OVTK_StimulationId_LabelEnd then
-- assume rows before cols
if identifier < col_base then
local t = {"row", identifier - row_base}
List.pushright(target_fifo,t)
if do_debug then
box:log("Info", string.format("Push row target %d", identifier - row_base ))
end
else
local t = {"col", identifier - col_base}
List.pushright(target_fifo,t)
if do_debug then
box:log("Info", string.format("Push col target %d", identifier - col_base ))
end
end
end
if identifier == segment_stop then
box:log("Info", string.format("Trial stop"))
segment_status = 2
end
end
-- then parse the classifications
for stimulation = 1, box:get_stimulation_count(1) do
-- gets the received stimulation
local identifier, date, duration = box:get_stimulation(1, 1)
-- discards it
box:remove_stimulation(1, 1)
-- Is it an in-class prediction?
if identifier == OVTK_StimulationId_Target then
local t = List.popleft(target_fifo)
if do_debug then
box:log("Info", string.format("Pred fifo %s %d is target", t[1], t[2]))
end
if t[1]=="row" then
row_votes[t[2]] = row_votes[t[2]] + 1
else
col_votes[t[2]] = col_votes[t[2]] + 1
end
end
if identifier == OVTK_StimulationId_NonTarget then
local t = List.popleft(target_fifo)
if do_debug then
box:log("Info", string.format("Pred fifo %s %d is nontarget", t[1], t[2]))
end
end
end
if segment_status == 2 and List.isempty(target_fifo) then
-- output the vote after the segment end when we've matched all predictions
local maxRowIdx, maxRowValue = arrayMax(row_votes)
local maxColIdx, maxColValue = arrayMax(col_votes)
if do_debug then
box:log("Info", string.format("Vote [%d %d] wt [%d,%d]", maxRowIdx+row_base, maxColIdx+col_base, maxRowValue, maxColValue))
end
local now = box:get_current_time()
box:send_stimulation(1, maxRowIdx + row_base, now, 0)
box:send_stimulation(2, maxColIdx + col_base, now, 0)
segment_status = 0
end
box:sleep()
end
end
-- this function is called when the box is initialized
function initialize(box)
dofile(box:get_config("${Path_Data}") .. "/plugins/stimulation/lua-stimulator-stim-codes.lua")
stim = _G[box:get_setting(2)]
launchTime = box:get_setting(3)
end
-- this function is called when the box is uninitialized
function uninitialize(box)
end
-- this function is called once by the box
function process(box)
box:send_stimulation(1, stim, launchTime, 0)
end
......@@ -7,6 +7,14 @@
#include <string>
#include <algorithm>
// For stimulussender
#include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <sys/timeb.h>
using boost::asio::ip::tcp;
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
......@@ -14,6 +22,90 @@ using namespace OpenViBE::Plugins;
using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SimpleVisualisation;
/*
* \class StimulusSender
* \brief Simple client to send stimuli to Acquisition Server TCP Tagging
* \todo Refactor to its own file
*/
class StimulusSender {
public:
~StimulusSender()
{
if(m_oStimulusSocket.is_open())
{
std::cout << "Disconnecting\n";
m_oStimulusSocket.close();
}
}
StimulusSender(void)
: m_oStimulusSocket(m_ioService), m_bConnectedOnce(false)
{
}
boolean connect(const char* sAddress, const char* sStimulusPort)
{
//m_pStimulusSocket = new tcp::socket(m_ioService);
boost::system::error_code error;
tcp::resolver resolver(m_ioService);
// Stimulus port
std::cout << "Connecting to stimulus port [" << sAddress << " : " << sStimulusPort << "]\n";
tcp::resolver::query query = tcp::resolver::query(tcp::v4(), sAddress, sStimulusPort);
m_oStimulusSocket.connect(*resolver.resolve(query), error);
if(error)
{
std::cout << "Connection error: " << error << "\n";
return false;
}
m_bConnectedOnce = true;
return true;
}
boolean sendStimuli(uint64 ui64Stimuli)
{
if(!m_bConnectedOnce) {
return false;
}
timeb time_buffer;
ftime(&time_buffer);
const uint64 posixTime = time_buffer.time*1000ULL + time_buffer.millitm;
if(!m_oStimulusSocket.is_open())
{
std::cout << "Cannot send stimulation, socket is not open\n";
return false;
}
uint64 l_ui64tmp = 0;
try
{
boost::asio::write(m_oStimulusSocket, boost::asio::buffer((void *)&l_ui64tmp, sizeof(uint64)));
boost::asio::write(m_oStimulusSocket, boost::asio::buffer((void *)&ui64Stimuli, sizeof(uint64)));
//boost::asio::write(m_oStimulusSocket, boost::asio::buffer((void *)&posixTime, sizeof(uint64)));
boost::asio::write(m_oStimulusSocket, boost::asio::buffer((void *)&l_ui64tmp, sizeof(uint64)));
}
catch (boost::system::system_error l_oError)
{
std::cout << "Issue '" << l_oError.code().message().c_str() << "' with writing stimulus to server\n";
}
return true;
}
private:
boost::asio::io_service m_ioService;
tcp::socket m_oStimulusSocket;
OpenViBE::boolean m_bConnectedOnce;
};
namespace
{
class _AutoCast_
......@@ -175,6 +267,14 @@ boolean CBoxAlgorithmP300SpellerVisualisation::initialize(void)
m_iSelectedRow=-1;
m_iSelectedColumn=-1;
m_pStimulusSender = new StimulusSender();
if(!m_pStimulusSender->connect("localhost", "15361"))
{
this->getLogManager() << LogLevel_Warning << "Unable to connect to AS TCP Tagging, stimuli wont be forwarded.\n";
}
m_bTableInitialized=false;
return true;
......@@ -182,6 +282,12 @@ boolean CBoxAlgorithmP300SpellerVisualisation::initialize(void)
boolean CBoxAlgorithmP300SpellerVisualisation::uninitialize(void)
{
if(m_pStimulusSender)
{
delete m_pStimulusSender;
m_pStimulusSender = NULL;
}
if(m_pSelectedFontDescription)
{
pango_font_description_free(m_pSelectedFontDescription);
......@@ -315,31 +421,22 @@ boolean CBoxAlgorithmP300SpellerVisualisation::process(void)
boolean l_bFlash=false;
int l_iRow=-1;
int l_iColumn=-1;
boolean l_bIsTarget = false;
// Pass the stimulation to AS in any case
m_pStimulusSender->sendStimuli(l_ui64StimulationIdentifier);
if(l_ui64StimulationIdentifier >= m_ui64RowStimulationBase && l_ui64StimulationIdentifier < m_ui64RowStimulationBase+m_ui64RowCount)
{
l_iRow=(int)(l_ui64StimulationIdentifier-m_ui64RowStimulationBase);
l_bFlash=true;
if(l_iRow==m_iLastTargetRow)
{
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_Target, l_pStimulationSet->getStimulationDate(j), 0);
}
else
{
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_NonTarget, l_pStimulationSet->getStimulationDate(j), 0);
}
l_bIsTarget = (l_iRow==m_iLastTargetRow);
}
if(l_ui64StimulationIdentifier >= m_ui64ColumnStimulationBase && l_ui64StimulationIdentifier < m_ui64ColumnStimulationBase+m_ui64ColumnCount)
{
l_iColumn=(int)(l_ui64StimulationIdentifier-m_ui64ColumnStimulationBase);
l_bFlash=true;
if(l_iColumn==m_iLastTargetColumn)
{
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_Target, l_pStimulationSet->getStimulationDate(j), 0);
}
else
{
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_NonTarget, l_pStimulationSet->getStimulationDate(j), 0);
}
l_bIsTarget = (l_iColumn==m_iLastTargetColumn);
}
if(l_ui64StimulationIdentifier == OVTK_StimulationId_VisualStimulationStop)
{
......@@ -377,6 +474,18 @@ boolean CBoxAlgorithmP300SpellerVisualisation::process(void)
&CBoxAlgorithmP300SpellerVisualisation::_cache_change_font_cb_,
m_pFlashFontDescription,
m_pNoFlashFontDescription);
if(l_bIsTarget)
{
m_pStimulusSender->sendStimuli(OVTK_StimulationId_Target);
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_Target, l_pStimulationSet->getStimulationDate(j), 0);
}
else
{
m_pStimulusSender->sendStimuli(OVTK_StimulationId_NonTarget);
l_oFlaggingStimulationSet.appendStimulation(OVTK_StimulationId_NonTarget, l_pStimulationSet->getStimulationDate(j), 0);
}
}
}
m_pTargetFlaggingStimulationEncoder->process(OVP_GD_Algorithm_StimulationStreamEncoder_InputTriggerId_EncodeBuffer);
......@@ -458,6 +567,11 @@ boolean CBoxAlgorithmP300SpellerVisualisation::process(void)
&l_vWidgets,
NULL);
m_pStimulusSender->sendStimuli(OVTK_StimulationId_BaselineStart);
m_pStimulusSender->sendStimuli(m_iTargetRow + m_ui64RowStimulationBase);
m_pStimulusSender->sendStimuli(m_iTargetColumn + m_ui64ColumnStimulationBase);
m_pStimulusSender->sendStimuli(OVTK_StimulationId_BaselineStop);
if(l_vWidgets.size() == 1)
{
if(GTK_IS_LABEL(l_vWidgets[0]))
......
......@@ -16,6 +16,8 @@
#define OVP_ClassId_BoxAlgorithm_P300SpellerVisualisation OpenViBE::CIdentifier(0x195E41D6, 0x6E684D47)
#define OVP_ClassId_BoxAlgorithm_P300SpellerVisualisationDesc OpenViBE::CIdentifier(0x31DE2B0D, 0x028202E7)
class StimulusSender; // fwd declare
namespace OpenViBEPlugins
{
namespace SimpleVisualisation
......@@ -115,6 +117,8 @@ namespace OpenViBEPlugins
std::map < unsigned long, std::map < unsigned long, CBoxAlgorithmP300SpellerVisualisation::SWidgetStyle > > m_vCache;
std::list < std::pair < int, int > > m_vTargetHistory;
StimulusSender* m_pStimulusSender;
};
class CBoxAlgorithmP300SpellerVisualisationDesc : public OpenViBE::Plugins::IBoxAlgorithmDesc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment