Page 1 of 1

Implement callback-driven signal source

Posted: 14 Sep 2012, 17:01
by akhambhati
Hello,

I've got a signal source (Neuralynx) that I'd like to implement with BCI2000. I noticed an existing Neuralynx-based project but it seems to use an outdated MATLAB API.

The most recent API includes callback functionality that automatically pushes in new records/samples from the DAQ when they become available (on a separate thread). This means that the user does not need to worry about threading etc. since the data automatically comes in if threads are available. I am wondering how such callback functionality might play with BCI2000 Process() calls for retrieving incoming data.

Has anyone handled this case with other signal source APIs?

Thanks,
Ankit

Re: Implement callback-driven signal source

Posted: 17 Sep 2012, 05:16
by gschalk
Hi,

In fact, this fits perfectly with the concept in Process(), i.e., Process is called by the BCI2000 framework, and then does not return until all data are there. So, if you implement a separate thread for getting data from the Neuralynx (thread 2) and if BCI2000 is thread 1, you want to do something like:

Thread 1:

Process()
wait_for_data_from_thread2();
get_data_from_thread2();
copy_data_into_BCI2000_output_signal();


Thread 1:

while not exit
{
if (data_from_Neuralynx == ready)
signal_thread1;
}


I hope this helps.

Gerv