Implement callback-driven signal source

Forum for software developers to discuss BCI2000 software development
Locked
akhambhati
Posts: 11
Joined: 23 Mar 2011, 14:29

Implement callback-driven signal source

Post by akhambhati » 14 Sep 2012, 17:01

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

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

Re: Implement callback-driven signal source

Post by gschalk » 17 Sep 2012, 05:16

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

Locked

Who is online

Users browsing this forum: No registered users and 2 guests