" BCI Metronome"

Forum for software developers to discuss BCI2000 software development
Locked
darvish_sam
Posts: 18
Joined: 02 May 2012, 21:29

" BCI Metronome"

Post by darvish_sam » 28 Oct 2013, 20:00

Dear all,

I am wondering how BCI2000 manages its timing. In other words. is it only the DataIOFilter that calls the process class of the data acquisition module and then waits for the required time to receive the data from the amplifier's buffer? or there is another metronome that adjusts its timing?
The reason that I am asking this question is that while the WaitForData function in the data acquisition module of TMSi.cpp (The provided coded by BCI2000 to receive data from Refa TMSi EEG amplifiers), even though TMSi claims that it sends its buffer contents sample by sample to the PC, it looks like, the PC can't receive it ay faster than every 8 ms, regardless of the value of Sampling frequency and the sampleBlockSize parameters. Thus I was thinking maybe there are some other processes of BCI2000 running continuously in the background that prevent it to read the buffer content regularly.

Thank you for your reply in advance.
Regards,
Sam

mellinger
Posts: 1052
Joined: 12 Feb 2003, 11:06

Re: " BCI Metronome"

Post by mellinger » 29 Oct 2013, 09:06

Hi,

BCI2000 indeed relies on the timing of data packets by the amplifier for its entire timing. Despite the obvious drawbacks of this approach, it is not easily possible to design a better method in such a way that the resulting improvement would justify the additional complications.

Some points:
1) For many amplifiers, timing of received data packets is quite stable, i.e. no improvement would be possible.
2) In cases with unreliable timing, it would not be a solution to just use some separate time base, and resample data into that time base as they arrive. Rather, it would be necessary to dynamically determine a compromise between the amplifier's sample clock, and the separate time base, and use an adaptive buffering scheme to minimize buffering (=delay) without being affected by the jitter of the incoming data packets (which requires a minimum buffer size, depending on the actual amount of jitter present).
3) In Windows user space programs, it is not easy to control timing of execution without affecting performance. Basically, one needs to make a choice between high CPU load, or a timing uncertainty of 10 to 20 ms (the time slice of the Win32 scheduler), such that there will be practically no advantage over the present situation.
4) At a typical display update rate of 60Hz, video updates will have a timing uncertainty of about 17ms. Improving timing beyond that limit will have no practical benefit unless a CRT is used as a display.
5) For brain signals used in typical BCI paradigms, bandwidth limits apply such that it makes little sense to improve timing beyond an accuracy of 15 to 20ms (compare to the peak width of ERPs, or the period of "carrier signals" such as SMRs, which both provide a lower limit for the delay involved in causal interaction between user and system).

A second aspect of your question regards the size of data packets themselves. A minimum packet duration of 8ms appears quite reasonable, considering the fact that higher updates will increase system load, and offer no practical benefit. Also, at a sampling rate of 250Hz, a sample's duration will amount to 4ms, so this is nearly as close as it can get.

Best regards,
Juergen

darvish_sam
Posts: 18
Joined: 02 May 2012, 21:29

Re: " BCI Metronome"

Post by darvish_sam » 30 Oct 2013, 04:50

Dear Juergen,
Thank you for your very prompt response.
So, if I am correct, it not windows or BCI2000 other programs that hold the CPU, but it is the amplifier itself which does not allow its buffer features to be updated faster than every 8 ms, regardless of the value of the sampling frequency.
I also do agree with you in saying that having a BCI system with a roundtrip time less than 16-20 ms would not of much benefit, considering the frequency range of SMR signals which we are working on.
The only thing I don't understand completely is in the last paragraph were you mentioned with FS=250 Hz, the sample's duration becomes 4 ms. Actually for all sampling frequencies of 128,256,512, 1024 Hz, it always gives you the 8ms long packets of data. Am I missing something?

Kind regards,
Sam

mellinger
Posts: 1052
Joined: 12 Feb 2003, 11:06

Re: " BCI Metronome"

Post by mellinger » 30 Oct 2013, 14:52

Hi Sam,

you are not missing anything. I just tried to point out that, for EEG amplifiers with their typically low sampling rates, 8ms is quite close to a single sample's duration already.

Regards,
Juergen

darvish_sam
Posts: 18
Joined: 02 May 2012, 21:29

Re: " BCI Metronome"

Post by darvish_sam » 01 Nov 2013, 03:45

Dear Juergen,
Thank you for the clarification. Now, I totally understand it.

Kind regards,
Sam

Locked

Who is online

Users browsing this forum: No registered users and 1 guest