Hello everyone,
I am trying to use the IOPort function of Psychtoolbox to record EEG
data. As you can see in the code below, what I am doing is filling the
audio buffer, opening a Parallel Port, sending a trigger (in this case
"1"), playing the audio, and then closing all ports. (And doing this 20
times.)
This works fine when I am recording the EEG, but when I analyze the
data, I see that the time between the trigger and the pulse varies, with
a standard deviation of about 20 ms. Do you have any idea why this might
be? I am fairly new to psychtoolbox so I'm sure the code could be
improved. For instance, am I doing something wrong by filling the audio
buffer every time? Or is it wrong to open the port after filling the
audio buffer? Would it help to reverse the order?
I am asking because when we use a commercial software, this jitter (i.e.
standard deviation) is somewhere around 5 ms, which is acceptable.
The OS running the script is Windows XP, and is installed on a laptop.
Any help would be much appreciated.
Hakan
-------------------------------------------------------------------------
Here's the code I use;
[y, freq, nbits] = wavread('MonoPulse100ms');
wavedataShort = y';
nrchannels = size(wavedataShort,1);
shortPulse = PsychPortAudio('Open', [], [], 3, freq, nrchannels);
i=0
while i<20
trigger=1
PsychPortAudio('FillBuffer', shortPulse, wavedataShort);
myport=IOPort('OpenSerialPort','COM2');
IOPort('Write',myport,char(trigger));
PsychPortAudio('Start', shortPulse, repetitions, 0, 1);
PsychPortAudio('Stop', shortPulse, 1);
IOPort('CloseAll')
i=i+1
end
I am trying to use the IOPort function of Psychtoolbox to record EEG
data. As you can see in the code below, what I am doing is filling the
audio buffer, opening a Parallel Port, sending a trigger (in this case
"1"), playing the audio, and then closing all ports. (And doing this 20
times.)
This works fine when I am recording the EEG, but when I analyze the
data, I see that the time between the trigger and the pulse varies, with
a standard deviation of about 20 ms. Do you have any idea why this might
be? I am fairly new to psychtoolbox so I'm sure the code could be
improved. For instance, am I doing something wrong by filling the audio
buffer every time? Or is it wrong to open the port after filling the
audio buffer? Would it help to reverse the order?
I am asking because when we use a commercial software, this jitter (i.e.
standard deviation) is somewhere around 5 ms, which is acceptable.
The OS running the script is Windows XP, and is installed on a laptop.
Any help would be much appreciated.
Hakan
-------------------------------------------------------------------------
Here's the code I use;
[y, freq, nbits] = wavread('MonoPulse100ms');
wavedataShort = y';
nrchannels = size(wavedataShort,1);
shortPulse = PsychPortAudio('Open', [], [], 3, freq, nrchannels);
i=0
while i<20
trigger=1
PsychPortAudio('FillBuffer', shortPulse, wavedataShort);
myport=IOPort('OpenSerialPort','COM2');
IOPort('Write',myport,char(trigger));
PsychPortAudio('Start', shortPulse, repetitions, 0, 1);
PsychPortAudio('Stop', shortPulse, 1);
IOPort('CloseAll')
i=i+1
end