Note that this reference documentation is identical to the help that is displayed in Matlab when you type “help ft_poll_buffer”.
FT_POLL_BUFFER polls the FieldTrip buffer described by 'filename' for the number of events and samples. You can also use this function to wait up to a given amount of milliseconds until the number of samples OR the number of events present in the buffer is bigger than a specified threshold. The output of this function is a struct with elements 'nsamples' and 'nevents', that always contain the current quantities. (So in case of timeouts, these might be smaller than the thresholds). Examples -------- The following will immediately return the two quantities: >> numbers = ft_poll_buffer('buffer://localhost:1972'); The following will wait up to 50 milliseconds for more than 100 samples in the buffer. thr = []; thr.nsamples = 100; timeout = 50; numbers = ft_poll_buffer('buffer://localhost:1972', thr, timeout); The following will wait up to 80 milliseconds for more than 30 events in the buffer. thr = []; thr.nevents = 30; timeout = 80; numbers = ft_poll_buffer('buffer://localhost:1972', thr, timeout); Repeatedly wait for new data (either samples or events): lastNum = []; lastNum.nevents = 0; lastNum.nsamples = 0; timeout = 100; while someCriterion newNum = ft_poll_buffer('buffer://localhost:1972', lastNum, timeout); if newNum.nsamples > lastNum.nsamples ... read and process samples ... if newNum.nevents > lastNum.nevents ... read and process events ... lastNum = newNum; end
Share this page: