|
|
@@ -48,7 +48,7 @@ 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)]
|
|
|
|
n_tactilos = box:get_setting(3)
|
|
|
|
segment_start = _G[box:get_setting(4)]
|
|
|
|
segment_stop = _G[box:get_setting(5)]
|
|
|
|
|
|
|
@@ -61,7 +61,6 @@ function initialize(box) |
|
|
|
-- box:log("Info", string.format("pop %d %d", id[1], id[2]))
|
|
|
|
|
|
|
|
row_votes = {}
|
|
|
|
col_votes = {}
|
|
|
|
|
|
|
|
do_debug = false
|
|
|
|
|
|
|
@@ -89,12 +88,10 @@ function process(box) |
|
|
|
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
|
|
|
@@ -104,18 +101,12 @@ function process(box) |
|
|
|
if segment_status == 1 and identifier >= row_base and identifier <= OVTK_StimulationId_LabelEnd then
|
|
|
|
|
|
|
|
-- assume rows before cols
|
|
|
|
if identifier < col_base then
|
|
|
|
if identifier < (row_base + n_tactilos) 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
|
|
|
|
|
|
|
|
|
|
|
@@ -145,9 +136,7 @@ function process(box) |
|
|
|
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
|
|
|
|
row_votes[t[2]] = row_votes[t[2]] + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
@@ -164,24 +153,18 @@ function process(box) |
|
|
|
-- 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 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"));
|
|
|
|
end
|
|
|
|
|
|
|
|
if do_debug then
|
|
|
|
local rowVotes = 0
|
|
|
|
local colVotes = 0
|
|
|
|
for ir, val in pairs(row_votes) do
|
|
|
|
rowVotes = rowVotes + val
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
@@ -189,7 +172,6 @@ function process(box) |
|
|
|
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
|