Problem with sending triggers from keyboard although triggers for sound events do work (Matlab, Cogent2000)

Post Reply
GoskaW
Posts: 1
Joined: Wed Feb 07, 2018 8:34 pm

Problem with sending triggers from keyboard although triggers for sound events do work (Matlab, Cogent2000)

Post by GoskaW » Wed Feb 07, 2018 9:03 pm

Hello,

I would truly appreciate your help. I try to send triggers from a keyboard to BioSemi. Although triggers assigned to sound events are visible on the screen, nothing happens when I press defined buttons. I use Matlab (8.1.0.604 (R2013a)) and Cogent2000 toolbox. I am attaching a problematic part of my script. It is important for me that all the triggers are visible for me in the moment of key presses. Could you help me with a piece of advice what shall I change/do?

Cheers!
GoskaW

% for each block
for blkNr = 1:3;

%for each random stimuli:
for songNr = blkOrder(blkNr, :)
sendtrigger(chorales{songNr, 2}, ioObject); % send start-of-sequence trigger for sound --> WORKS
playsound(songNr);
wait(chorales{songNr, 4});
% t0 needed for calculation of reaction times
t0=time;
logstring( t0);
wait(2000 );
readkeys;
logkeys;
% Check key pressed, give an appropriate error code and calculate
% reaction time for 1 condition
n = countkeydown;
[ key, t ] = lastkeydown;
rt = 0;
% everything below is saved in the results file, but no triggers are visible on the screen
if n == 0; % no key pressed
error = 0;
message = 'no response';
rt=9999;
elseif key ~= keymap.W & key ~= keymap.G % keys other than G or W pressed
error = 2;
message = 'invalid key press ';
rt=9999;
elseif key == keymap.W%tinnitus recovery
error=1;
message='TI recovery '
rt = t - t0; % here calculate reaction time
elseif key ==keymap.G;
error=2;
message='no RI '
rt=9999;
else
error=2;
message='another error '
rt=9999;
readkeys;

% here I try to send triggers from a keyboard
if error==1
sendtrigger(trigery{1,1}, ioObject);
elseif error==2
sendtrigger(trigery{1,2}, ioObject);
end
clearkeys;
end
waitkeydown(Inf,71); % take a break after each block / press space to continue
end

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest