„scenarios/scripts/p300-tactile-accumulator.lua“ ändern
This commit is contained in:
parent
44d07712eb
commit
8ba5957791
@ -52,6 +52,8 @@ function initialize(box)
|
||||
segment_start = _G[box:get_setting(4)]
|
||||
segment_stop = _G[box:get_setting(5)]
|
||||
|
||||
col_base = row_base + n_tactilos
|
||||
|
||||
-- 0 inactive, 1 segment started, 2 segment stopped (can vote)
|
||||
segment_status = 0
|
||||
|
||||
@ -61,6 +63,7 @@ function initialize(box)
|
||||
-- box:log("Info", string.format("pop %d %d", id[1], id[2]))
|
||||
|
||||
row_votes = {}
|
||||
col_votes = {}
|
||||
|
||||
do_debug = false
|
||||
|
||||
@ -88,10 +91,12 @@ 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
|
||||
@ -101,12 +106,18 @@ function process(box)
|
||||
if segment_status == 1 and identifier >= row_base and identifier <= OVTK_StimulationId_LabelEnd then
|
||||
|
||||
-- assume rows before cols
|
||||
if identifier < (row_base + n_tactilos) then
|
||||
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
|
||||
|
||||
|
||||
@ -137,6 +148,8 @@ function process(box)
|
||||
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
|
||||
|
||||
@ -153,18 +166,24 @@ 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 then
|
||||
if maxRowValue == 0 and maxColValue == 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] wt [%d]", maxRowIdx+row_base, maxRowValue))
|
||||
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))
|
||||
end
|
||||
|
||||
|
||||
@ -172,6 +191,7 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user