|
|
|
|
|
|
|
|
dofile(box:get_config("${Path_Data}") .. "/plugins/stimulation/lua-stimulator-stim-codes.lua")
|
|
|
dofile(box:get_config("${Path_Data}") .. "/plugins/stimulation/lua-stimulator-stim-codes.lua")
|
|
|
|
|
|
|
|
|
row_base = _G[box:get_setting(2)]
|
|
|
row_base = _G[box:get_setting(2)]
|
|
|
col_base = _G[box:get_setting(3)]
|
|
|
|
|
|
|
|
|
n_tactilos = box:get_setting(3)
|
|
|
segment_start = _G[box:get_setting(4)]
|
|
|
segment_start = _G[box:get_setting(4)]
|
|
|
segment_stop = _G[box:get_setting(5)]
|
|
|
segment_stop = _G[box:get_setting(5)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- box:log("Info", string.format("pop %d %d", id[1], id[2]))
|
|
|
-- box:log("Info", string.format("pop %d %d", id[1], id[2]))
|
|
|
|
|
|
|
|
|
row_votes = {}
|
|
|
row_votes = {}
|
|
|
col_votes = {}
|
|
|
|
|
|
|
|
|
|
|
|
do_debug = false
|
|
|
do_debug = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
box:log("Info", string.format("Clear votes"))
|
|
|
box:log("Info", string.format("Clear votes"))
|
|
|
end
|
|
|
end
|
|
|
-- zero the votes
|
|
|
-- zero the votes
|
|
|
col_votes = {}
|
|
|
|
|
|
row_votes = {}
|
|
|
row_votes = {}
|
|
|
target_fifo = List.new()
|
|
|
target_fifo = List.new()
|
|
|
-- fixme fixed 20
|
|
|
-- fixme fixed 20
|
|
|
for i = 0,20 do
|
|
|
for i = 0,20 do
|
|
|
col_votes[i] = 0
|
|
|
|
|
|
row_votes[i] = 0
|
|
|
row_votes[i] = 0
|
|
|
end
|
|
|
end
|
|
|
segment_status = 1
|
|
|
segment_status = 1
|
|
|
|
|
|
|
|
|
if segment_status == 1 and identifier >= row_base and identifier <= OVTK_StimulationId_LabelEnd then
|
|
|
if segment_status == 1 and identifier >= row_base and identifier <= OVTK_StimulationId_LabelEnd then
|
|
|
|
|
|
|
|
|
-- assume rows before cols
|
|
|
-- assume rows before cols
|
|
|
if identifier < col_base then
|
|
|
|
|
|
|
|
|
if identifier < (row_base + n_tactilos) then
|
|
|
local t = {"row", identifier - row_base}
|
|
|
local t = {"row", identifier - row_base}
|
|
|
List.pushright(target_fifo,t)
|
|
|
List.pushright(target_fifo,t)
|
|
|
if do_debug then
|
|
|
if do_debug then
|
|
|
box:log("Info", string.format("Push row target %d", identifier - row_base ))
|
|
|
box:log("Info", string.format("Push row target %d", identifier - row_base ))
|
|
|
end
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
box:log("Info", string.format("Pred fifo %s %d is target", t[1], t[2]))
|
|
|
box:log("Info", string.format("Pred fifo %s %d is target", t[1], t[2]))
|
|
|
end
|
|
|
end
|
|
|
if t[1]=="row" then
|
|
|
if t[1]=="row" then
|
|
|
row_votes[t[2]] = row_votes[t[2]] + 1
|
|
|
|
|
|
else
|
|
|
|
|
|
col_votes[t[2]] = col_votes[t[2]] + 1
|
|
|
|
|
|
|
|
|
row_votes[t[2]] = row_votes[t[2]] + 1
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- output the vote after the segment end when we've matched all predictions
|
|
|
-- output the vote after the segment end when we've matched all predictions
|
|
|
|
|
|
|
|
|
local maxRowIdx, maxRowValue = arrayMax(row_votes)
|
|
|
local maxRowIdx, maxRowValue = arrayMax(row_votes)
|
|
|
local maxColIdx, maxColValue = arrayMax(col_votes)
|
|
|
|
|
|
|
|
|
|
|
|
if maxRowValue == 0 and maxColValue == 0 then
|
|
|
|
|
|
|
|
|
if maxRowValue == 0 then
|
|
|
box:log("Warning", string.format("Classifier predicted 'no p300' for all flashes of the trial"));
|
|
|
box:log("Warning", string.format("Classifier predicted 'no p300' for all flashes of the trial"));
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
if do_debug then
|
|
|
if do_debug then
|
|
|
local rowVotes = 0
|
|
|
local rowVotes = 0
|
|
|
local colVotes = 0
|
|
|
|
|
|
for ir, val in pairs(row_votes) do
|
|
|
for ir, val in pairs(row_votes) do
|
|
|
rowVotes = rowVotes + val
|
|
|
rowVotes = rowVotes + val
|
|
|
end
|
|
|
end
|
|
|
for ir, val in pairs(col_votes) do
|
|
|
|
|
|
colVotes = colVotes + val
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
box:log("Info", string.format("Vote [%d %d] wt [%d,%d]", maxRowIdx+row_base, maxColIdx+col_base, maxRowValue, maxColValue))
|
|
|
|
|
|
box:log("Info", string.format(" Total [%d %d]", rowVotes, colVotes))
|
|
|
|
|
|
|
|
|
box:log("Info", string.format("Vote [%d] wt [%d]", maxRowIdx+row_base, maxRowValue))
|
|
|
end
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local now = box:get_current_time()
|
|
|
local now = box:get_current_time()
|
|
|
|
|
|
|
|
|
box:send_stimulation(1, maxRowIdx + row_base, now, 0)
|
|
|
box:send_stimulation(1, maxRowIdx + row_base, now, 0)
|
|
|
box:send_stimulation(2, maxColIdx + col_base, now, 0)
|
|
|
|
|
|
|
|
|
|
|
|
segment_status = 0
|
|
|
segment_status = 0
|
|
|
end
|
|
|
end
|