Commit 7d1aeca0 authored by Jesse Heckman's avatar Jesse Heckman

update vPrime data storing, debugging minor fixes, adding multiple simultanipous leds

parent d05332ea
......@@ -22,8 +22,8 @@ function cfg = pb_vClearTrial(stim, cfg)
%% Turn off sounds
for muxIdx = 1:2
% MUX(cfg.RZ6_1,muxIdx,0)
for muxIdx = 1:4
MUX(cfg.RZ6_1,muxIdx,0)
end
%% Initiate trial
......
......@@ -14,11 +14,10 @@ function [stim, cfg] = pb_vSetupTrial(stim,cfg)
%% LED
if any(selled)
led = stim(selled);
nled = numel(led);
% nled = 2
n = nled*2; % LEDs need to be turned on and off
s = ledpattern(n);
led = pb_vSimuLEDl(stim(selled));
nled = numel(led);
n = nled*2; % LEDs need to be turned on and off
s = ledpattern(n);
cnt = 0;
for iLed = 1:nled
......@@ -44,7 +43,7 @@ function [stim, cfg] = pb_vSetupTrial(stim,cfg)
for ii = 1:2
cnt = cnt+1;
if ii==1
if ii == 1
s(cnt).set(led(iLed).Z,cfg.ledcolours{col},1);
s(cnt).intensity(cfg.ledcolours{col},led(iLed).intensity); % Vestibular range 0-100;
else
......@@ -52,7 +51,7 @@ function [stim, cfg] = pb_vSetupTrial(stim,cfg)
end
end
end
stim(find(selled,1)).ledhandle = ledcontroller_pi('dcn-led06','dcn-led07');
stim(find(selled,1)).ledhandle = ledcontroller_pi('dcn-led06','dcn-led07','dcn-led09','dcn-led10');
stim(find(selled,1)).ledhandle.write(s);
end
......
function pb_vStoreData(cfg, Dat)
function pb_vStoreData(h, dat, idx)
% PB_VSTOREBLOCKDAT
%
% PB_VSTOREBLOCKDAT(cfg, Dat) stores 'Dat' Data in files.
......@@ -7,6 +7,13 @@ function pb_vStoreData(cfg, Dat)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
cfg = h.cfg;
dat(iBlck).event_data = str(1).read;
dat(iBlck).pupil_labs = str(2).read;
dat(iBlck).optitrack = str(3).read;
dat(iBlck).block_info = handles.block(iBlck);
[~,fn] = pb_fext(cfg.fname);
file = [cfg.dname filesep 'block_info_' fn '.mat'];
save(file, 'Dat');
......
......@@ -27,7 +27,7 @@ function pb_vEndExp
%% Let's run some LEDs instead
leds = ledcontroller_pi('dcn-led09','dcn-led10','dcn-led06','dcn-led07');
leds = ledcontroller_pi('dcn-led06','dcn-led07','dcn-led09','dcn-led10');
pb_lightshow(leds);
%% Mop up
......
......@@ -29,9 +29,9 @@ function pb_vRunExp(handles)
Dat = pb_dataobj(nblocks);
% initialize recordings
rc = pb_runPupil;
[ses,str] = pb_runLSL;
expTime = tic;
rc = pb_runPupil;
[ses,str,idx] = pb_runLSL;
expTime = tic;
%% START BLOCK
% iterate experimental blocks
......@@ -95,11 +95,7 @@ function pb_vRunExp(handles)
pb_stopLSL(ses);
% store data
Dat(iBlck).event_data = str(1).read;
Dat(iBlck).pupil_labs = str(2).read;
Dat(iBlck).optitrack = str(3).read;
Dat(iBlck).block_info = handles.block(iBlck);
pb_vStoreData(handles.cfg, Dat);
pb_vStoreData(handles, Dat, idx);
% update block information
handles.cfg = pb_updatecount(handles.cfg,'block','count');
......
......@@ -15,8 +15,8 @@ function pb_lightshow(leds)
ig = ir;
% Sequence needs updating due to new SLC distribution
seq1 = [0:2:9 fliplr(16:2:63)];
seq2 = [1:2:9 fliplr(17:2:63)];
seq1 = [0:2:9 fliplr(16:2:63)]; %% [0:2:63];
seq2 = [1:2:9 fliplr(17:2:63)]; %% [1:2:63];
for iC = 1:n
if mod(iC,2) == 0
......
function led = pb_vSimuLED(led)
% PB_VSIMULED
%
% PB_VSIMULED(led) merges multiple leds with exact same timings but different locations together as one led pattern.
%
% See also PB_VSETUPTRIAL, PB_VRUNTRIAL
% PBToolbox (2019): JJH: j.heckman@donders.ru.nl
tmp(1) = led(1);
ctmp = 1;
for iT = 2:length(led)
if led(iT).onevent == led(iT-1).onevent && ... % if LED has same on- and offset
led(iT).offevent == led(iT-1).offevent && ...
led(iT).ondelay == led(iT-1).ondelay && ...
led(iT).offdelay == led(iT-1).offdelay
if led(iT).Z ~= tmp(ctmp).Z % but different location (sanity check)
tmp(ctmp).Z = [tmp(ctmp).Z,led(iT).Z];
end
else
ctmp = ctmp+1;
tmp(ctmp) = led(iT);
end
end
led = tmp;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2019) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function [ses,str] = pb_runLSL2(varargin)
% PB_RUNLSL2
%
% PB_RUNLSL2(varargin) creates a LSL session for VC.
%
% See also PB_VRUNEXP
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
de = pb_keyval('de', varargin, true);
pl = pb_keyval('pl', varargin, true);
gz = pb_keyval('gz', varargin, false);
pd = pb_keyval('pd', varargin, false);
ot = pb_keyval('ot', varargin, true);
tmp = {};
streams = {'type=''Digital Events @ lslder01'' and name=''Digital Events 0''', ...
'type=''Pupil Capture @ pupil-desktop'' and name=''Pupil Python Representation - Eye 0''', ...
'type=''Pupil Capture @ pupil-desktop'' and name=''Gaze Python Representation''', ...
'type=''Pupil Capture @ pupil-desktop'' and name=''Pupil Primitive Data - Eye 0''', ...
'type=''OptiTrack Mocap @ DCN-OT01'' and name=''Rigid Bodies'''};
if de; tmp(end+1) = streams(1); end
if pl; tmp(end+1) = streams(2); end
if gz; tmp(end+1) = streams(3); end
if pd; tmp(end+1) = streams(4); end
if ot; tmp(end+1) = streams(5); end
streams = tmp;
ses = lsl_session();
ls = length(streams);
str = lsl_istream.empty(0,ls);
clear tmp;
for iStrm = 1:ls
% Find, select and make streams for LSL.
tmp = strrep(streams(iStrm),'type=''','');
tmp = tmp{1}(1:find(tmp{1} == '@',1)-2);
info = lsl_resolver(streams{iStrm});
l = info.list();
if isempty(l); error('No streams found'); end
str(iStrm) = lsl_istream(info{1});
ses.add_stream(str(iStrm));
end
c = 1;
if de; addlistener(str(c),'DataAvailable', @listener); c = c+1; end
if pl; addlistener(str(c),'DataAvailable', @listener); c = c+1; end
if gz; addlistener(str(c),'DataAvailable', @listener); c = c+1; end
if pd; addlistener(str(c),'DataAvailable', @listener); c = c+1; end
if ot; addlistener(str(c),'DataAvailable', @listener); end
end
function listener(~, event)
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
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