Commit 50abb875 authored by Jesse Heckman's avatar Jesse Heckman
Browse files

updated vPrime with inital LSC TDT interaction code

parent 308691fd
...@@ -18,23 +18,22 @@ function handles = pb_createdir(handles) ...@@ -18,23 +18,22 @@ function handles = pb_createdir(handles)
fname = [cfg.expInitials '-' cfg.subjectid '-' cfg.datestring '-' cfg.recording '-0001.vc' ]; fname = [cfg.expInitials '-' cfg.subjectid '-' cfg.datestring '-' cfg.recording '-0001.vc' ];
while exist(fname,'file') if exist(fname,'file')
% Check for existing recordings % Check for existing recordings
quest = 'Recording already exists. Indicate how to proceed?'; quest = 'Recording already exists. Indicate how to proceed?';
answer = questdlg(quest,'Choices','Overwrite', 'Increment','Stop','Stop'); answer = questdlg(quest,'Choices','Overwrite', 'Append','Stop','Stop');
switch answer switch answer
case 'Overwrite' case 'Append'
break; while exist(fname,'file')
case 'Increment' cfg.recording = num2str(str2double(cfg.recording)+1,'%04d');
cfg.recording = num2str(str2double(cfg.recording)+1,'%04d'); fname = [cfg.expInitials '-' cfg.subjectid '-' cfg.datestring '-' cfg.recording '-0001.vc' ];
end
set(handles.editRec,'string',cfg.recording); set(handles.editRec,'string',cfg.recording);
case 'Stop' case 'Stop'
error('Run stopped.'); error('Run stopped.');
end end
fname = [cfg.expInitials '-' cfg.subjectid '-' cfg.datestring '-' cfg.recording '-0001.vc' ];
end end
handles.cfg = cfg; handles.cfg = cfg;
handles = pb_gethandles(handles); handles = pb_gethandles(handles);
......
...@@ -12,7 +12,6 @@ function [Dat,profile,dur] = pb_vSignalVC(handles) ...@@ -12,7 +12,6 @@ function [Dat,profile,dur] = pb_vSignalVC(handles)
bnumber = handles.cfg.blocknumber; bnumber = handles.cfg.blocknumber;
%% READ SIGNAL PARAMETERS %% READ SIGNAL PARAMETERS
signal(1) = block(bnumber).signal.ver; signal(1) = block(bnumber).signal.ver;
signal(2) = block(bnumber).signal.hor; signal(2) = block(bnumber).signal.hor;
signal = pb_vSafety(signal); signal = pb_vSafety(signal);
...@@ -22,41 +21,43 @@ function [Dat,profile,dur] = pb_vSignalVC(handles) ...@@ -22,41 +21,43 @@ function [Dat,profile,dur] = pb_vSignalVC(handles)
hSignal = pb_vCreateSignal(1, signal(2).duration, 10, signal(2).frequency, signal(2).type); hSignal = pb_vCreateSignal(1, signal(2).duration, 10, signal(2).frequency, signal(2).type);
%% FINALIZE SIGNAL %% FINALIZE SIGNAL
Dat.v.x = vSignal.x .* signal(1).amplitude; Dat.v.x = vSignal.x .* signal(1).amplitude;
profile.v = Dat.v.x;
Dat.v.t = (0:1:length(Dat.v.x)-1)/10; Dat.v.t = (0:1:length(Dat.v.x)-1)/10;
Dat.h.x = hSignal.x .* signal(2).amplitude; profile.h = Dat.h.x; profile.v = Dat.v.x;
Dat.h.x = hSignal.x .* signal(2).amplitude;
Dat.h.t = (0:1:length(Dat.h.x)-1)/10; Dat.h.t = (0:1:length(Dat.h.x)-1)/10;
profile.h = Dat.h.x;
Dat.v.amplitude = signal(1).amplitude; Dat.v.amplitude = signal(1).amplitude;
Dat.h.amplitude = signal(2).amplitude; Dat.h.amplitude = signal(2).amplitude;
dur = max([signal(1).duration signal(2).duration])+5; % add 5 extra seconds for delay of the system dur = max([signal(1).duration signal(2).duration])+10; % add 10 extra seconds for delay of the system
%% FEEDBACK GUI %% FEEDBACK GUI
updateBlock(handles,bnumber,signal); updateBlock(handles, signal);
handles = pb_gethandles(handles);
cb = handles.cfg.blocknumber; handles = pb_gethandles(handles);
dur = max([handles.block(cb).signal.ver.duration handles.block(cb).signal.hor.duration]); dur = max([handles.block(bnumber).signal.ver.duration handles.block(bnumber).signal.hor.duration]);
axes(handles.signals); cla; hold on; axes(handles.signals);
handles.signals.YLim = [-50 50]; cla; hold on;
handles.signals.XLim = [0 dur]; handles.signals.YLim = [-50 50];
handles.signals.XLim = [0 dur];
plot(Dat.v.t,Dat.v.x,'k'); plot(Dat.v.t,Dat.v.x,'k');
plot(Dat.h.t,Dat.h.x,'b'); plot(Dat.h.t,Dat.h.x,'b');
end end
function updateBlock(handles, bnumber, signal) function updateBlock(handles, signal)
% Updates the block information to the GUI % Updates the block information to the GUI
bn = pb_sentenceCase(num2str(bnumber,'%03d')); % count block bn = num2str(handles.cfg.blocknumber,'%03d'); % count block
set(handles.Bn,'string',bn); set(handles.Bn,'string',bn);
vs = ['V = ' pb_sentenceCase(signal(1).type) ... % VC stim vs = ['V = ' pb_sentenceCase(signal(1).type) ... % VC stim
', H = ' pb_sentenceCase(signal(2).type)]; ', H = ' pb_sentenceCase(signal(2).type)];
set(handles.Vs,'string',vs); set(handles.Vs,'string',vs);
end end
......
function pb_vClearTrial(handles) function cfg = pb_vClearTrial(stim, cfg)
% PB_VCLEARTRIAL(HANDLES) % PB_VCLEARTRIAL(HANDLES)
% %
% PB_VCLEARTRIAL(HANDLES) empties previous trial: data, stimuli, GUI, and % PB_VCLEARTRIAL(HANDLES) empties previous trial: data, stimuli, GUI, and
...@@ -8,12 +8,35 @@ function pb_vClearTrial(handles) ...@@ -8,12 +8,35 @@ function pb_vClearTrial(handles)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl % PBToolbox (2018): JJH: j.heckman@donders.ru.nl
tn = handles.cfg.trialnumber;
bn = handles.cfg.blocknumber; %% Remove ledhandle if it exists
nstim = numel(stim);
for iStm = 1:nstim
if isfield(stim(iStm),'ledhandle')
if ~isempty(stim(iStm).ledhandle)
stim(iStm).ledhandle.delete; % delete(leds)/switch off light;
end
end
end
%% Turn off sounds
for muxIdx = 1:2
% MUX(cfg.RZ6_1,muxIdx,0)
end
%% Initiate trial
tn = cfg.trialnumber;
bn = cfg.blocknumber;
disp([newline '<strong>New Trial started...</strong> '... disp([newline '<strong>New Trial started...</strong> '...
newline ' Trial: ' num2str(tn(2)) ' (B' num2str(bn) 'T' num2str(tn(1)) ')']); newline ' Trial: ' num2str(tn(2)) ' (B' num2str(bn) 'T' num2str(tn(1)) ')']);
if ispc
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).
end
end end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
function pb_vSetupTrial(stim,cfg) function [stim, cfg] = pb_vSetupTrial(stim,cfg)
% PB_VSETUPTRIAL() % PB_VSETUPTRIAL(STIM, CFG)
% %
% PB_VSETUPTRIAL() ... % PB_VSETUPTRIAL(STIM, CFG) sets up experimental parameters for Trial.
% %
% See also ... % See also PB_VPRIME, PB_VPRIMEGUI, PB_VRUNEXP.
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl % PBToolbox (2018): JJH: j.heckman@donders.ru.nl
...@@ -89,14 +89,6 @@ function pb_vSetupTrial(stim,cfg) ...@@ -89,14 +89,6 @@ function pb_vSetupTrial(stim,cfg)
end end
cfg.maxSamples = maxSamples; cfg.maxSamples = maxSamples;
%% Sound Acquisition
% if any(selsndacq)
% sndacq = stim(selsndacq);
% cfg.RP2_1.SetTagVal('eventAcq',sndacq.onevent+1);
% cfg.RP2_1.SetTagVal('delayAcq',sndacq.ondelay);
% cfg.RP2_1.SetTagVal('acqSamples',cfg.nsamples); % amount of DA samples
% end
%% Wait for? %% Wait for?
% This needs some tweaking % This needs some tweaking
% search for latest event with longest offset % search for latest event with longest offset
......
function pb_vTraces(h) function pb_vTraces(handles)
% PB_VTRACES() % PB_VTRACES(HANDLES)
% %
% PB_VTRACES() ... % PB_VTRACES(HANDLES) updates the trace velocity plots of eye and head in
% GUI.
% %
% See also ... % See also ...
...@@ -9,7 +10,7 @@ function pb_vTraces(h) ...@@ -9,7 +10,7 @@ function pb_vTraces(h)
%% PLOT TRACES %% PLOT TRACES
% head trace % head trace
axes(h.hTrace); hold on; axes(handles.hTrace); hold on;
ws = 20; b = (1/ws)*ones(1,ws); a = 1; ws = 20; b = (1/ws)*ones(1,ws); a = 1;
x = 0:.05:2.5; x = 0:.05:2.5;
...@@ -18,7 +19,7 @@ function pb_vTraces(h) ...@@ -18,7 +19,7 @@ function pb_vTraces(h)
plot(x,y); plot(x,y);
% eye trace % eye trace
axes(h.eTrace); hold on; axes(handles.eTrace); hold on;
ws = 20; b = (1/ws)*ones(1,ws); a = 1; ws = 20; b = (1/ws)*ones(1,ws); a = 1;
x = 0:.05:2.5; x = 0:.05:2.5;
...@@ -27,8 +28,8 @@ function pb_vTraces(h) ...@@ -27,8 +28,8 @@ function pb_vTraces(h)
plot(x,y); plot(x,y);
%% HIGHLIGHT CURRENT %% HIGHLIGHT CURRENT
te = pb_fobj(h.eTrace,'Type','Line'); te = pb_fobj(handles.eTrace,'Type','Line');
th = pb_fobj(h.hTrace,'Type','Line'); th = pb_fobj(handles.hTrace,'Type','Line');
col = pb_selectcolor(10,5); col = pb_selectcolor(10,5);
for iT = 1:length(th) for iT = 1:length(th)
...@@ -41,6 +42,7 @@ function pb_vTraces(h) ...@@ -41,6 +42,7 @@ function pb_vTraces(h)
te(iT).Color = col(1,:); te(iT).Color = col(1,:);
end end
end end
pause(1); % Hold for a sec!
end end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
...@@ -40,20 +40,21 @@ function pb_vRunExp(handles) ...@@ -40,20 +40,21 @@ function pb_vRunExp(handles)
vs.start; tic; vs.start; tic;
end end
% RUN TRIALS %% RUN TRIALS
for iTrial = 1:nTrials for iTrl = 1:nTrials
% Runs all trials within one block % Runs all trials within one block
updateTrial(handles); updateTrial(handles);
pb_vClearTrial(handles); stim = handles.block(iBlck).trial(iTrl).stim;
handles.cfg = pb_vClearTrial(stim,handles.cfg);
handles = pb_vStoreData(handles, bDat); pb_vSetupTrial(stim,cfg);
handles = updateCount(handles,'trial','count'); % pb_vRunTrial(experiment(iTrial));
pb_vTraces(handles); pause(1);
% pb_vFeedbackGUI(); %% <-- MAYBE NOT NECESSAIRY?
%pb_vSetupTrial(block(iBlock).trial(iTrial).stim,cfg); pb_vTraces(handles);
%pb_vRunTrial(experiment(iTrial)); handles = pb_vStoreData(handles, bDat);
%pb_vFeedbackGUI(); handles = updateCount(handles,'trial','count'); % update trial
end end
% STOP CHAIR % STOP CHAIR
......
function handles = pb_tdtinit(handles) function handles = pb_tdtinit(handles)
% PB_TDTINIT() % PB_TDTINIT(HANDLES)
% %
% PB_TDTINIT() ... % PB_TDTINIT(HANDLES) sets tdt initials prior to experimentation.
% %
% See also ... % See also PB_VPRIME, PB_VPRIMEGUI
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl % PBToolbox (2018): JJH: j.heckman@donders.ru.nl
......
function str = pb_sentenceCase(str) function str = pb_sentenceCase(str)
% PB_SENTENCECASE() % PB_SENTENCECASE(STR)
% %
% PB_SENTENCECASE() ... % PB_SENTENCECASE(STR) returns any input string in sentence case
% capitalization.
% %
% See also ... % See also ...
......
Supports Markdown
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