Looking for Matlab code to implement the Pscyhomotor Vigilance Task (PVT)

Hi,
I'm not sure if this is the correct place to post this, if not, I apologize. I am looking for code to run the Psychomotor Vigilance Task. It is a visual vigilance task that is commonly used in fatigue research. If anyone has options they would be willing to share, particularly if you have used it in published research, it would be much appreciated.
Thank,
Ben

2 Comments

I would recommend a GUI with an indicator randomly going on/off periodically over the testing period and recording mouse clicks. Seems quite simple. What have you done? Show us some code and as a specific question.
Thanks, I am hoping it is straightforward to program and that someone has actually implemented it already. My programming abilities are limited so I am asking if anyone has already created the program in Matlab and would be willing to share. I apologize if this is the wrong forum for such a request.

Sign in to comment.

Answers (1)

I coded this quickly. Here is a back bone for the PVT. Modify as desired.
function [sleepAttack,lapse,good,tooFast,excessiveClick]=pscyhomotorVT(lengthTime)
%input length of time you desire for test duration (seconds)
%outputs provide data on how many occurances of each category happen
%When the red light appears, hit any key, continue until test is complete
gui=uifigure('Position',[300 300 950 600],'Color','k','KeyPressFcn',@keyPress);
Rect = uipanel(gui,'Units','pixels','Position',[465 290 20 20],...
'BackgroundColor','r','BorderType','none','Visible','off');
pause('on');
rng('shuffle');
tooFast=0;good=0;lapse=0;excessiveClick=0;count=0;
pause(3);
tStart=clock;
while etime(clock,tStart)<lengthTime
pause('on');
pause(rand*10+1);
Rect.Visible='on';
Tstart=clock;
flag=1;
for k=1:120
pause(.25);
end
Rect.Visible='off';
flag=0;
count=count+1;
end
sleepAttack=count-sum([tooFast,good,lapse]);
function keyPress(~,~)
d=etime(clock,Tstart)*1000;
if ~flag
excessiveClick=excessiveClick+1;
return;
end
pause('off');
if d<150
tooFast=tooFast+1;
elseif d<500
good=good+1;
else
lapse=lapse+1;
end
end
end

Categories

Find more on Debugging and Improving Code in Help Center and File Exchange

Asked:

on 10 Feb 2022

Commented:

on 14 Feb 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!