Commit d907512b authored by Jesse Heckman's avatar Jesse Heckman
Browse files

updated vPrime dataobj

parent 0ca49c27
classdef pb_dataobj < handle
% PB_DATAOBJ()
%
% PB_VCREATEDAT() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
properties (Access=public)
vestibular_signal = [];
event_data = [];
pupil_labs = [];
optitrack = [];
block_info = [];
end
methods
function obj = pb_dataobj(n)
% constructor
if nargin ~= 0
if nargin < 1
n = 1;
end
obj(n,1) = pb_dataobj; % Preallocate object array
end
end
function delete(obj)
% DELETE - destructor
delete(obj);
end
function dump(this)
% DUMP - show the content of the internal variables
this.vestibular_signal
this.event_data
this.pupil_labs
this.block_info
end
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
classdef pb_dataobj < handle
% PB_VCREATEDAT()
%
% PB_VCREATEDAT() ...
%
% See also ...
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
% LEDPATTERN
% Create a collection of stimulus patterns for the PA_LEDS
% class.
% s = ledpattern creates a single pattern
% s = ledpattern(n) creates a vector of n patterns
% s = ledpattern(m,n) creates a mxn matrix of patterns
%
% See also INTENSITY, SET, CLEAR, CLEAR_ALL, GET_LEDS, DELETE,
% DUMP.
properties (Access=protected)
intensity_red = uint16(50);
intensity_grn = uint16(50);
leds_red = zeros(128, 1);
leds_grn = zeros(128, 1);
end
methods
function obj = ledpattern(m,n)
% PA_LEDPATTERN constructor
if nargin ~= 0 % Allow nargin == 0 syntax
if nargin < 2
n = 1;
end
obj(m, n) = ledpattern; % Preallocate object array
end
end
function intensity(this, color, value)
% INTENSITY(color, value)
% Set the intensity of the red or green leds
% if color starts with 'r' the intensity of the red leds is set
% by manpulating the PWM output duty cycle. Otherwise the green
% intensity is set.
% The value should be in the range 1..50
if color(1) == 'r'
this.intensity_red = uint16(value);
else
this.intensity_grn = uint16(value);
end
end
function delete(obj) %#ok<INUSD>
% DELETE - destructor
end
function set(this, lednr, color, value)
% SET(lednr, color, value)
% Turn the led with color on output lednr on or off, depending
% on the value paramater. 0 is off, otherwise on. If not specified,
% value is assumed to be 1
%
% Note that LEDNRs start at 0!
if nargin < 4
value = 1;
end
if color(1) == 'r'
this.leds_red(lednr+1) = (value ~= 0);
else
this.leds_grn(lednr+1) = (value ~= 0);
end
end
function clear(this, lednr, color)
% CLEAR(lednr, color)
% Shorthand for SET(lednr, color, 0);
this.set(lednr, color, 0);
end
function clear_all(this)
% CLEAR_ALL
% Turn all leds off.
this.leds_red = zeros(128,1);
this.leds_grn = zeros(128,1);
end
function [r, g, ir, ig] = get_leds(this)
% [leds_red, leds_grn,intens_red, intens_grn] = GET_LEDS;
% Returns the value of the internal variables holding led
% values and intensities.
if nargout > 0
r=this.leds_red;
end
if nargout > 1
g=this.leds_grn;
end
if nargout > 2
ir=this.intensity_red;
end
if nargout > 3
ig=this.intensity_grn;
end
end
function dump(this)
% DUMP - show the content of the internal variables
this.intensity_red
this.intensity_grn
this.leds_red' %#ok<NOPRT>
this.leds_grn' %#ok<NOPRT>
end
end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2018) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -26,8 +26,8 @@ function pb_vRunExp(handles)
% set block information
block = handles.block;
nblocks = handles.cfg.Blocks;
Dat(nblocks) = struct('VS',[],'EV',[],'PL_Gaze',[],'PL_Python',[],'PL_Primitive',[],'OT_Rigid',[],'BlockInfo',[]);
Dat = pb_dataobj(nblocks);
% initialize recordings
rc = pb_runPupil;
[ses,streams] = pb_runLSL;
......@@ -44,8 +44,8 @@ function pb_vRunExp(handles)
handles = updateCount(handles,'trial','reset');
% store signal data
[sig,profile,dur] = pb_vSignalVC(handles); % reads, checks, creates & plots vestibular signals
Dat(iBlck).VS = sig;
[sig,profile,dur] = pb_vSignalVC(handles); % reads, checks, creates & plots vestibular signals
%Dat(iBlck).vestibular_signal = sig;
% start recording
pb_startLSL(ses);
......@@ -89,7 +89,7 @@ function pb_vRunExp(handles)
elapsedTime = toc(blockTime);
if elapsedTime < dur; pause(dur-floor(elapsedTime)+6); end % wait untill chair is finished running before disabling.
pb_stopServo(vs);
Dat = pb_readServo(vs);
Dat(iBlck) = pb_readServo(vs, Dat(iBlck));
delete(vs);
end
......@@ -98,12 +98,10 @@ function pb_vRunExp(handles)
pb_stopLSL(ses);
% store data
Dat(iBlck).EV = streams(1).read;
Dat(iBlck).PL_Python = streams(2).read;
%Dat(iBlck).PL_Gaze = streams(3).read;
%Dat(iBlck).PL_Primitive = streams(4).read;
Dat(iBlck).OT_Rigid = streams(3).read;
Dat(iBlck).BlockInfo = handles.block(iBlck);
Dat(iBlck).event_data = streams(1).read;
Dat(iBlck).pupil_labs = streams(2).read;
Dat(iBlck).optitrack = streams(3).read;
Dat(iBlck).block_info = handles.block(iBlck);
% update block information
handles.cfg = updateCount(handles.cfg,'block','count');
......
function D = pb_readServo(vs)
function Dat = pb_readServo(vs, Dat)
% PB_READSERVO
%
% PB_READSERVO(vs) reads vestibular in- and output profiles and stores
......@@ -11,8 +11,8 @@ function D = pb_readServo(vs)
[sv.vertical,sv.horizontal] = vs.read_profile_sv;
[pv.vertical,pv.horizontal] = vs.read_profile_pv;
D.sv = sv;
D.pv = pv;
Dat.vestibular_signal.sv = sv;
Dat.vestibular_signal.pv = pv;
delete(vs);
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