[FieldTrip] Online preprocessing

Mariana Branco marianapbranco1 at gmail.com
Thu May 23 11:57:27 CEST 2013


Hi Jörn,

Thank you very much for answering. I definitely still have a lot to understand about online implementation, which I will do.

Another specific doubt came up when I was trying to understand the function ft_preprocessing. My offline data is composed of 40 trials of  approx. 9-10s paradigms. I have a cued motor task at 3s (lasting 5s) and I use 0s until 3s as baseline to each trial. 
In the examples used in fieldtrip it is possible to chose the 'demean' option and specify the baseline period in seconds. My question is how exactly does the ft_preprocessing function corrects the baseline? Also, the examples define the baseline window with negative time, but I defined the baselinewindow=[0 3]. Is it wrong?

Thank you again for all the advices, I will definitely pose more question in the future.

Mariana Branco

On 23 May 2013, at 11:37, "Jörn M. Horschig" <jm.horschig at donders.ru.nl> wrote:

> Hi Mariana,
> 
> On 5/23/2013 10:25 AM, Mariana Branco wrote:
>> Hello,
>> 
>> I am new in the BCI research field, and I am starting to implement an online BCI system using the Fieldtrip toolbox to detect ERD/ERS features. I already did two offline experiments using this toolbox, but now I am having some doubts about how to adapt the offline signal processing functions into real-time; I started by simulating real-time data from a file.
>> My questions are:
>> 1) To process the data real-time using ft_preprocessing is it first necessary to define trials (with ft_definetrial)? If so, how can I define the trial if it is real-time?
> 
> no, you should use ft_read_data directly. The way to go is to check the header of your buffer for new events using ft_read_event. Upon detection of a relevant trigger, you need to use the returned event sample to compute your beginning and endsample manually (this is what ft_definetrial, or more precisely, your trialfun, usually does).  Then you can use ft_read_data to read data from the buffer into memory. ft_read_data returns a datamatrix that can be used to create your data.trial field. Also, you need to manually create the rest of the data-structure.
>> 2) Is it possible to still use the function ft_preprocessing and ft_resampledata in real-time with the same specifications of offline procedure?
> It is definitely possible, once you converted the matrix to a regular fieldtrip structure. However, since it is about speed in online processing, you can think about using low-level functions of FieldTrip directly. Note that for resampling, you can also set up the shared memory (eg. acq2ftx) such that is downsamples right from the start.
> 
>> 3) When simulating data stream (with two matlab sessions) the function ft_realtime_powerestimate(cfg) reports an error related to the "arg 3 (overlap)" on the welch's method. How can I correct this?
> Do not use Welch's method, use another function. I don't know about this particular example function, but I think you would greatly benefit from finding out where the error is yourself. Note that online streaming od data *is* complicated and requires *you* to have knowledge about this.
>> 4) Also, for synchronous/triggered data analysis it is available the function ft_realtime_average. Is it possible to explain how can this example function be used for implementation of my own feature processing and extraction function. Does it preprocess the data in an alternative way to ft_preprocessing?
> It should be an example, yes. Usually, there should be, as explained above, some ft_read_event statement to read the trigger value(s). In that particular example, the trialfun is used rather than ft_read_data directly, but trialfun is basically a wrapper around ft_read_data. Also, in that example a bunch of trials is read in, not just one. The thing you need to do to adjust this is to filter out the event structure such that only in case of the trigger of interest some data processing is done (you can use ft_filter_event for this).
> 
> My best advise for you is to read all (most) example functions and adjust them so that they run in your lab. Then sketch a flow diagram how triggers/data will be sent and read, try to implement this yourself (by copy&pasting relevant parts out of the example functions). If you have specific questions, feel free to always ask, but as this stage (please excuse my bluntnessI think you do not really know what needs to be done. I could write a lot about this, but I think you will benefit more if you first try yourself (especially because I do not know how your lab is set up and how things needs to be adjusted). But, as just said, feel free to write again when you have other questions.
> 
> Good luck!
> Best,
> Jörn
> 
>> 
>> I am sorry for all the questions.
> 
> No problem, no  way to know everything :)
> 
>> Regards,
>> 
>> Mariana Branco
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> 
> 
> -- 
> Jörn M. Horschig
> PhD Student
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> Neuronal Oscillations Group
> FieldTrip Development Team
> 
> P.O. Box 9101
> NL-6500 HB Nijmegen
> The Netherlands
> 
> Contact:
> E-Mail: jm.horschig at donders.ru.nl
> Tel:    +31-(0)24-36-68493
> Web: http://www.ru.nl/donders
> 
> Visiting address:
> Trigon, room 2.30
> Kapittelweg 29
> NL-6525 EN Nijmegen
> The Netherlands
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip





More information about the fieldtrip mailing list