Commit 087e7402 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

clear code

parent 6bc6026d
...@@ -27,33 +27,33 @@ function pb_vRunExp(handles) ...@@ -27,33 +27,33 @@ function pb_vRunExp(handles)
rc = pb_runPupil; rc = pb_runPupil;
[ses,str] = pb_runLSL('ot',false); [ses,str] = pb_runLSL('ot',false);
%% CORE BODY %% CORE BODY
% iterate experiment % iterate experiment
for iBlck = 1:nblocks for iBlck = 1:nblocks
% Runs blocks of trials with a vestibular condition % Runs blocks of trials with a vestibular condition
ses.start;
pb_startPupil(rc);
nTrials = length(block(iBlck).trial); nTrials = length(block(iBlck).trial);
handles = updateCount(handles,'trial','reset'); handles = updateCount(handles,'trial','reset');
[bDat(iBlck),profile,dur] = pb_vSignalVC(handles); % reads, checks, creates & plots vestibular signals [bDat(iBlck),profile,dur] = pb_vSignalVC(handles); % reads, checks, creates & plots vestibular signals
pb_startLSL(ses);
pb_startPupil(rc);
% START CHAIR if ~ismac && ~debug
if ~ismac && ~debug % START CHAIR
send_profile(profile); send_profile(profile);
pb_sendServo(vs,profile);
vs = vs_servo; pb_startServo(vs);
vs.enable; pause(1);
vs.start; blockTime = tic;
end end
blockTime = tic;
%% RUN TRIALS %% RUN TRIALS
% iterate trials
for iTrl = 1:nTrials for iTrl = 1:nTrials
% Runs all trials within one block % Runs all trials within one block
trialTime = tic; trialTime = tic;
updateTrial(handles); updateTrial(handles);
...@@ -76,19 +76,15 @@ function pb_vRunExp(handles) ...@@ -76,19 +76,15 @@ function pb_vRunExp(handles)
elapsedTime = toc(blockTime); elapsedTime = toc(blockTime);
if elapsedTime < dur; pause(dur-floor(elapsedTime)); end % wait untill chair is finished running before disabling. if elapsedTime < dur; pause(dur-floor(elapsedTime)); end % wait untill chair is finished running before disabling.
vs.stop; pb_stopServo(vs)
vs.disable;
delete(vs);
[sv,pv] = read_profile; Dat = pb_readServo(vs);
Dat.sv = sv;
Dat.pv = pv;
end end
handles = updateCount(handles,'block','count'); handles = updateCount(handles,'block','count');
pb_stopPupil(rc); pb_stopPupil(rc);
% STOP LSL pb_stopLSL(ses);
ses.stop;
if ~exist('LSL_Dat','var') if ~exist('LSL_Dat','var')
LSL_Data = {}; LSL_Data = {};
...@@ -99,10 +95,11 @@ function pb_vRunExp(handles) ...@@ -99,10 +95,11 @@ function pb_vRunExp(handles)
% LSL_Dat.ot_dat = str(3).read; % LSL_Dat.ot_dat = str(3).read;
% TODO: SAVE LSL DATA % TODO: SAVE LSL DATA
% save(lsl_file, 'LSL_Dat');
end end
%% CHECK OUT
%% CHECK OUT
% finalizes experiment, and resets handles.
pb_vEndExp(handles.cfg); pb_vEndExp(handles.cfg);
pb_vInitialize(handles,false); pb_vInitialize(handles,false);
...@@ -151,19 +148,18 @@ function send_profile(profile) ...@@ -151,19 +148,18 @@ function send_profile(profile)
vs = vs_servo; vs = vs_servo;
vs.write_profile(profile.v,profile.h); vs.write_profile(profile.v,profile.h);
delete(vs);
end end
function [sv,pv] = read_profile function Dat = read_profile(vs)
% read profile % read profile
vs = vs_servo;
[sv.vertical,sv.horizontal] = vs.read_profile_sv; [sv.vertical,sv.horizontal] = vs.read_profile_sv;
[pv.vertical,pv.horizontal] = vs.read_profile_pv; [pv.vertical,pv.horizontal] = vs.read_profile_pv;
delete(vs); delete(vs);
Dat.sv = sv;
Dat.pv = pv;
end end
......
function pb_startLSL(ses)
% PB_STARTLSL()
%
% PB_STARTLSL() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
ses.start;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_stopLSL(ses)
% PB_STOPLSL()
%
% PB_STOPLSL() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
ses.stop
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function D = pb_readServo(vs)
% PB_READSERVO()
%
% PB_READSERVO() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
[sv.vertical,sv.horizontal] = vs.read_profile_sv;
[pv.vertical,pv.horizontal] = vs.read_profile_pv;
delete(vs);
D.sv = sv;
D.pv = pv;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function vs = pb_runServo()
% PB_RUNSERVO()
%
% PB_RUNSERVO() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
vs = vs_servo;
vs.enable;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_startServo(vs)
% PB_STARTSERVO()
%
% PB_STARTSERVO() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
vs.start;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_stopServo(vs)
% PB_STOPSERVO()
%
% PB_STOPSERVO() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
vs.stop;
vs.disable;
delete(vs);
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