Commit 464e3707 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

update vPrime: clean up, improvement of vestibular checks

parent 6f3316b2
function [safe,threshold] = pb_vCheckVelSignal(signal)
% PB_VCHECKVELSIGNAL
%
% PB_VCHECKVELSIGNAL(signal) checks if the velocity profile of the signal
% exceeds a certain threshold.
%
% See also PB_VCREATESIGNAL, PB_VSAFETY
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
safe = true;
threshold = 50; % Should be 50 d/s: DO NOT CHANGE!!
SR = 10;
mvel = SR * max(abs(diff(signal)));
if mvel>threshold; safe = false; end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -36,8 +36,16 @@ function [Dat,profile,dur] = pb_vSignalVC(handles)
Dat.v.amplitude = signal(1).amplitude;
Dat.h.amplitude = signal(2).amplitude;
% dur = max([signal(1).duration signal(2).duration])+10; % add 10 extra seconds for delay of the system
%% CHECK SAFETY FINAL SIGNAL
[hSafe,~] = pb_vCheckVelSignal(Dat.h.x);
[vSafe,mvel] = pb_vCheckVelSignal(Dat.v.x);
if ~hSafe || ~vSafe
error(['Vestibular signals were not safe! (velocity exceeds ' num2str(mvel) ')']);
end
%% FEEDBACK GUI
updateBlock(handles, signal);
......@@ -48,18 +56,21 @@ function [Dat,profile,dur] = pb_vSignalVC(handles)
cla; hold on;
handles.signals.YLim = [-50 50];
handles.signals.XLim = [0 dur];
plot(Dat.v.t,Dat.v.x,'k');
plot(Dat.h.t,Dat.h.x,'b');
dv = 10 * [0 diff(Dat.v.x)];
dh = 10 * [0 diff(Dat.h.x)];
plot(Dat.v.t,dv,'k');
plot(Dat.h.t,dh,'b');
end
function updateBlock(handles, signal)
% Updates the block information to the GUI
bn = num2str(handles.cfg.blocknumber,'%03d'); % count block
bn = num2str(handles.cfg.blocknumber,'%03d');
set(handles.Bn,'string',bn);
vs = ['V = ' pb_sentenceCase(signal(1).type) ... % VC stim
vs = ['V = ' pb_sentenceCase(signal(1).type) ...
', H = ' pb_sentenceCase(signal(2).type)];
set(handles.Vs,'string',vs);
......
......@@ -24,9 +24,9 @@ function pb_vRunExp(handles)
handles = pb_vInitialize(handles, true);
% set block information
block = handles.block;
nblocks = handles.cfg.Blocks;
Dat = pb_dataobj(nblocks);
block = handles.block;
nblocks = handles.cfg.Blocks;
Dat = pb_dataobj(nblocks);
% initialize recordings
rc = pb_runPupil;
......@@ -40,12 +40,9 @@ function pb_vRunExp(handles)
% Runs blocks of trials with a vestibular condition
% set block information
nTrials = length(block(iBlck).trial);
handles = updateCount(handles,'trial','reset');
% store signal data
[sig,profile,dur] = pb_vSignalVC(handles); % reads, checks, creates & plots vestibular signals
%Dat(iBlck).vestibular_signal = sig;
nTrials = length(block(iBlck).trial);
handles = updateCount(handles,'trial','reset');
[sig,profile,dur] = pb_vSignalVC(handles);
% start recording
pb_startLSL(ses);
......@@ -117,7 +114,7 @@ function pb_vRunExp(handles)
toc(experimentTime)
end
%-- Feedback functions --%
%-- GUI feedback functions --%
function updateTrial(handles)
% Updates the trial information to the GUI
......
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