Some problem using the fieldtripbuffer

teris tam teristam at GMAIL.COM
Fri Jan 15 03:28:18 CET 2010


Dear Robert,

It's very nice to hear from you!

I have done some test in matlab trying to get down to the root of the
problem. I have observed that the problem only occur if there is a repeated
pulling of header information of the fieldtripbuffer by read_header(), e.g.
when the matlab code is waiting for a new block of data. Adding some time
delay between subsequent calls of read_header() seems to alleviate the
issue:

hdr = read_header(filename, 'cache',true);
pause(0.1);

 Interestingly, repeated calling of read_data() to get the most recent data
doesn't seem to have any problem, even if no time delay is added between
calls.

I have tried to start 2 matlab sessions to investigate whether the error
comes from matlab or from the fieildtripbuffer server. When one matlab
session fails to connect, the other session cannot connect to the server
either (They are not connecting in parallel. I start the other session right
after the first session reports error). However, the code is able to connect
to the buffer again after waiting for 3-4s.

I guess the problem is that repeatedly calling of read_header() may jam the
buffer server. read_data() may take a longer time to process in matlab and
so adding a time delay for the server to recover. We can verify this if we
can get into the debug information of the buffer server (if there is any).
Currently I work around the issue by adding a delay between read_header() or
just use read_data() to get the most recent data.

Best regards,
Teris

On Fri, Jan 15, 2010 at 4:54 AM, Robert Oostenveld <
r.oostenveld at fcdonders.ru.nl> wrote:

> Hi Teris,
>
> I have also occasionally encountered the problem with opening a TCP
> connection on windows (i.e. bci2000). The error means that the client
> (MATLAB) is not able to make a connection to the server (the fieldtrip
> buffer which is running under BCI2000).
>
> On a Linux or OSX only setup (both the matlab client and the buffer server
> running on linux and/or OSX) the problem never happened to me. I don't know
> where in the code the problem is, and since it is so difficult to reproduce,
> I also don't know where to start looking in the code. If it results in
> problems for you, then I suggest you do something like
>
> function varargout = retry_read_header(varargin)
> retry = 100;
> while retry>0
>   try
>       varargout = read_header(varargin{:});
>       break;
>   end
>   retry = retry - 1;
> end
>
> and something similar for read_data and read_event.
>
> Of course it would be better if the problem were fully diagnosed and
> subsequently fixed, so any suggestions are welcome.
>
> best regards,
> Robert
>
>
>
> -----------------------------------------------------------
> Robert Oostenveld, PhD
> Senior Researcher
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> tel.: +31 (0)24 3619695
> e-mail: r.oostenveld at donders.ru.nl
> web: http://www.ru.nl/neuroimaging
> skype: r.oostenveld
> -----------------------------------------------------------
>
> On 12 Jan 2010, at 8:20, teris tam wrote:
>
> Dear all,
>         I am trying to read the signal from BCI2000 in MATLAB using the
> fieldtripbuffer. I use the code given in the BCI2000 wiki at
> http://www.bci2000.org/wiki/index.php/Programming_Tutorial:Working_with_the_FieldTrip_buffer
> .
>         It was able to read and plot the signal from BCI2000 correctly for
> a certain period of time, but eventually it stopped and reported "ERROR:
> failed to create socket (-2)". I was able to connect to and read from the
> buffer again if I re-run the program.
>         Does anyone have an idea why this error occur and how to solve it?
>         Thanks a lot!
> Best regards,
> Teris
>
>
> -----------------------------------------------------------
> Robert Oostenveld, PhD
> Senior Researcher
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> tel.: +31 (0)24 3619695
> e-mail: r.oostenveld at donders.ru.nl
> web: http://www.ru.nl/neuroimaging
> skype: r.oostenveld
> -----------------------------------------------------------
>
> ----------------------------------
>
> The aim of this list is to facilitate the discussion between users of the
> FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and
> EEG analysis.
>
> http://listserv.surfnet.nl/archives/fieldtrip.html
>
> http://www.ru.nl/fcdonders/fieldtrip/
>

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20100115/267fee1f/attachment-0002.html>


More information about the fieldtrip mailing list