[FieldTrip] shifting data time

Wong-Barnum, Mona mona at sdsc.edu
Wed Nov 23 23:52:27 CET 2016


Hi Anne:

Thank you so much for your thoughtful suggestion!  I will give it a try.

Yes, we would like to have all the time continuous because we need to make some analysis based on the entire duration.

Happy Thanksgiving (if you are in the US)!

cheers,
Mona


On Oct 28, 2016, at 1:36 AM, anne Hauswald <anne.hauswald at me.com<mailto:anne.hauswald at me.com>> wrote:

Hi Mona,

if you do
cfg=[];
all=ft_appenddata(cfg, data1, data2, data3, data4);

you get among the other fields
all=
time: {1x4 cell} %assuming each dataset equals one trial, which is what you want to replace.

you could try to create a matrix, based on your sampling rate with all the continuous time points, here just for illustration:
all_timepoints=[0:0.025:9.975]  %adapt to your sampling rate and length of data, be very sure the end of one file is the beginning of the next one. (This is giving you all points from 0 to 9.975 with steps of 0.025)
trl_timepoints=mat2cell(all_timepoints, 1, [100 100 100 100]) %here I create 4 cell arrays, corresponding e.g. to 4 trials

will result in
trl_timepoints =
    [1x100 double]    [1x100 double]    [1x100 double]    [1x100 double]

with continuous time information (trial 1 starts at 0, trial 2 at 2.5, trials 3 at 5, and trial 4 at 7.5) of the same length.
this you can then use to replace the original time information:

all_data.time_old=all_data.time %if you want to keep the original time information
all_data.time=trl_timepoints

In general: are you really sure that you need the continuous time information? There are many processing and analyses steps that can be done on the appended time information…

There might be more elegant ways to do this.

Hope there is no typo and that it helps
Best Anne

*********************************************
    Mona Wong
    Web & iPad Application Developer
    San Diego Supercomputer Center

    "To handle yourself, use your head;
    to handle others, use your heart."

-- Eleanor Roosevelt
*********************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20161123/76da96be/attachment-0001.html>


More information about the fieldtrip mailing list