Commit 5dfe4218 authored by Jesse Heckman's avatar Jesse Heckman

adjusted trialduration in vExp

parent 456aba50
......@@ -20,9 +20,27 @@ function handles = pb_getblock(handles)
%% Correct Block
block = pb_vPrimeZ(block,cfg);
%% Timing
cfg.trialdur = getdurations(block); % sets trialdur
handles.block = block;
handles.cfg = cfg;
end
function td = getduration(block)
% extracts trial and block dur
stimarr = [];
blocksz = length(block);
for bidx = 1:blocksz
trialsz = length(block(bidx).trial);
for tidx = 1:trialsz
stimarr(end+1) = block(bidx).trial(tidx).stim(end).offdelay;
end
end
td = ceil(max(stimarr)/500)/2; % rounds up max trial duration with .5 precision
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
......@@ -31,3 +49,4 @@ end
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_vRunTrial(cfg,stim)
function pb_vRunTrial(zbus, trialdur)
% PB_VRUNTRIAL(HANDLES)
%
% PB_VRUNTRIAL(HANDLES) ...
......@@ -8,17 +8,17 @@ function pb_vRunTrial(cfg,stim)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
%% Run zBus
cfg.zBus.zBusTrigA(0, 0, 2); % reset, clock start, (0,0,2): trigger entire rack, with a pulse structure, and 2 ms delay(2 ms = minimum).
zbus.zBusTrigA(0, 0, 2); % reset, clock start, (0,0,2): trigger entire rack, with a pulse structure, and 2 ms delay(2 ms = minimum).
%% Trigger event 1
% cfg.zBus.zBusTrigB(0, 0, 2); % start event 1, trial onset
cfg.zBus.zBusTrigB(0, 0, 2); % start event 1/trial onset; trigger zBus 4 = RA16;
zbus.zBusTrigB(0, 0, 2); % start event 1/trial onset; trigger zBus 4 = RA16;
%% Button Press
% disp('Waiting for RZ6 button press/sound/led/acquisition');
t = tic;
while toc(t)<2.5
while toc(t) < trialdur
% disp('waiting')
% do nothing
end % sound is played after this loop exits.
......
function handles = pb_vStoreData(handles, data)
function handles = pb_vStoreData(handles, data,stim)
% PB_VSTOREDATA(HANDLES, DATA)
%
% PB_VSTOREDATA(HANDLES, DATA) stores all the trial data and configurements
......@@ -15,21 +15,21 @@ function handles = pb_vStoreData(handles, data)
fname = [prefix '-' num2str(cfg.trialnumber(2),'%04d') '.vc'];
data = data; %% TO DO: <-- FIX: SELECT DATA FOR TRIAL ONLY
beta = setCFG(cfg); %% TO DO: <-- FIX: SELECT CFGs FOR TRIAL ONLY
beta = setCFG(cfg,stim); %% TO DO: <-- FIX: SELECT CFGs FOR TRIAL ONLY
save(fname,'data', 'beta', '-mat');
handles.cfg = cfg;
end
function beta = setCFG(cfg)
function beta = setCFG(cfg,stim)
% stores relevant handles into a new trial cfg
beta = struct('blocknumber',[],...
'trialnumber',[],...
'vestibularsignal',[],...
'nstim',[],...
'stim',[]);
'stim',stim);
beta.blocknumber = cfg.blocknumber;
beta.trialnumber = cfg.trialnumber;
......
......@@ -65,14 +65,14 @@ function pb_vRunExp(handles)
% setup trial
updateTrial(handles);
stim = handles.block(iBlck).trial(iTrl).stim;
handles.cfg = pb_vClearTrial(stim,handles.cfg);
handles.cfg = pb_vClearTrial(stim, handles.cfg);
[stim, handles.cfg] = pb_vSetupTrial(stim, handles.cfg);
trialTime = tic;
pb_vRunTrial(handles.cfg, stim);
pb_vRunTrial(handles.cfg.zBus, handles.cfg.trialdur);
pb_vTraces(handles);
handles = pb_vStoreData(handles, sig);
handles = pb_vStoreData(handles, sig, stim);
handles.cfg = updateCount(handles.cfg,'trial','count');
toc(trialTime)
end
......
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