Back to the main page.

Bug 1784 - How to stop the buffer inside the matlab?

Reported 2012-10-16 23:32:00 +0200
Modified 2019-08-10 11:56:13 +0200
Product: FieldTrip
Component: realtime
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 major
Assigned to:
Depends on:
See also:

Soheila - 2012-10-16 23:32:23 +0200

I can not stop the buffer inside the matlab, even after using buffer('tcpserver', 'exit'); it doesn't stop and I should use task manager to terminate the matlab and make it stop! I heard about "demo_buffer.exe" to run the buffer in windows, but it doesn't have a Win64 version. (I think the problem is similar to bug 934, but I didn't find a good solution for that one in comments! )

Boris Reuderink - 2012-10-17 14:59:29 +0200

Dear Soheila, That is indeed very annoying. Probably you can run the demo_buffer.exe in the win32, since most 64-bit versions of Windows can run 32-bit application just fine. I'll add a README file to explain this. Does that provide an adequate workaround? Boris

Boris Reuderink - 2012-10-17 15:12:03 +0200

Added a README in SVN r6766. Maybe we should reconsider the naming of the platforms after the mex-file convention... *** This bug has been marked as a duplicate of bug 934 ***

Soheila - 2012-10-19 00:00:49 +0200

Dear Boris I used demo_buffer.exe, but it doesn't work! Matlab can not read from that buffer. Is the problem with buffer or I should use a different function from what have been used for reading or writing from/to the buffer that is initialized in matlab? For example, hdr = buffer('get_hdr', [], ft_host, ft_port) doesn't work for reading header from this buffer. Soheila

Boris Reuderink - 2012-10-19 09:22:54 +0200

That is unexpected. Could you explain what does happen instead? Does demo_buffer.exe display an error when you try to read the header?

Soheila - 2012-10-19 16:49:51 +0200

NO, no message or error is displayed in demo_buffer.exe window, but matlab doesn't respond to command. I should use CTRL-C to stop the process in matlab! (The OS is 64-bit Windows 7)

Boris Reuderink - 2012-10-22 12:03:46 +0200

I notice that you use 'buffer' to interact with the FieldTrip buffer. This mex-file is currently a private function of FieldTrip; users are supposed to use ft_read_header etc. On a Windows 64-bit machine I did the following: 1) Start win32 demo_buffer.exe. 2) in MATLAB: >> ft_read_header('buffer://localhost:1972') ??? Error using ==> buffer ERROR: the buffer returned an error (517) [snip] 3) start sine2ft.exe to create signals, and press 'connect' 4) In MATLAB: >> ft_read_header('buffer://localhost:1972') [snip] ans = Fs: 2000 nChans: 16 nSamples: 60416 [snip] This shows that reading the header (2) gives an error (but it does not hang!). This happens because no data has been written to the buffer yet. When we create some data in (3), this succeeds in (4). Could you try to replicate these steps? And if you get different results, could you update to the latest version of FieldTrip, and see if the problem persists?

Soheila - 2012-10-23 23:42:40 +0200

I did what you asked me step by step and and the result is: it works good with fake sine2ft.exe, but when I want to use the real MEG data which come from ACQ workstation (I don't have matlab on Acquisition workstation and I send it to Stim PC using acq2ftx), even ft_read_header('buffer://:1972') doesn't work. I tried last version and then updated the fieldtrip but in both cases this error occurs: Error using buffer ERROR: failed to create socket (1) Error in ft_read_header (line 920) orig = buffer('get_hdr', [], host, port); I think even with using the ft_read_header we need to have access to buffer using this command: buffer('get_hdr', [], host, port); Do you have any idea to fix the problem? </p>

Boris Reuderink - 2012-10-25 14:56:44 +0200

Hi Soheila, So, it does work with the sine2ft program, which shows that on the MATLAB-client side things are working fine. The error message states that it can't connect to this server. My hunch is that 1) either the FT buffer server is running on a different port or address, or 2) it is not running at all. You can try to pinpointing the problem by connecting deliberately to a non-existing server. Do you get the same message? If you do, you should attempt to find the correct address & port for your serving program. Perhaps you local technical staff can help you with this. I close this bug, since this is more user support than bug related. If you have more questions, please ask on the FieldTrip list. Boris

Soheila - 2012-10-25 16:04:43 +0200

No, the problem is not the server, because when I initiate the buffer inside the matlab, it works perfect! I've started using the realtime part of Fieldtrip for developing MEG neurofeedback in our lab since February. I'm familiar with addresses,TCP/IP connection, delay estimation and lots of other concepts related to this application of fieldtrip. In this point, I think the problem is with demo_buffer and at least in my Win7 machine, it doesn't work. For current applications, I can continue using internal buffer and the only problem is shutting down of matlab, but I'd appreciate if you could generate a 64bit Win7 compatible version of demo_buffer for future applications. Best Regards, Soheila

Boris Reuderink - 2012-11-02 13:29:59 +0100

I am no longer working on FieldTrip. Hence, I donate all my bugs to the joint development user.

Robert Oostenveld - 2019-08-10 11:56:13 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on