Dateien hochladen nach „scenarios/scripts“

This commit is contained in:
Tobias Baumann 2022-05-24 14:29:03 +00:00
parent 0ed96f676b
commit d72f4118e3

View File

@ -48,7 +48,7 @@ function initialize(box)
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)]
@ -61,7 +61,6 @@ function initialize(box)
-- 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
@ -89,12 +88,10 @@ function process(box)
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
@ -104,18 +101,12 @@ function process(box)
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
@ -146,8 +137,6 @@ function process(box)
end end
if t[1]=="row" then if t[1]=="row" then
row_votes[t[2]] = row_votes[t[2]] + 1 row_votes[t[2]] = row_votes[t[2]] + 1
else
col_votes[t[2]] = col_votes[t[2]] + 1
end end
end end
@ -164,24 +153,18 @@ function process(box)
-- 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("Vote [%d] wt [%d]", maxRowIdx+row_base, maxRowValue))
box:log("Info", string.format(" Total [%d %d]", rowVotes, colVotes))
end end
@ -189,7 +172,6 @@ function process(box)
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