[FieldTrip] redefine trials using different trigger as zero point

KatrinH Heimann katrinheimann at gmail.com
Sun Sep 28 19:02:40 CEST 2014


Thanks Anne! I will try that! :)
Katrin

2014-09-28 18:35 GMT+02:00 Anne Urai <anne.urai at gmail.com>:

> Dear Katrin,
>
> if you use a custom trialfun (
> http://fieldtrip.fcdonders.nl/example/making_your_own_trialfun_for_conditional_trial_definition)
> you can code the time between stimulus onset and response in an additional
> column. That way, you can shift the time axis of the data by this amount on
> each trial. For example:
>
>         % redefine trials
>         offset      = (data.trialinfo(:,RTcol));
>         prestim     = 1;
>         poststim    = 2;
>
>
>         cfg           = [];
>         cfg.begsample = round(offset - prestim*data.fsample);
>         cfg.endsample = round(offset + poststim*data.fsample);
>         data = ft_redefinetrial(cfg, data);
>
>
>         % then shift the time axis
>         cfg = [];
>         cfg.offset = -offset;
>         data = ft_redefinetrial(cfg, data);
>
>         % timelock
>         cfg = [];
>         cfg.keeptrials = 'yes';
>         data = ft_timelockanalysis(cfg, data);
>
> That way, your new data structure will now be response locked. Note that
> the timelockanalysis is optional, and only works when you have trials that
> are all the same length.
>
> If you do not want to use a custom trialfun, you could also rerun the same
> analysis as you have for the stimulus-locked data, but then taking the
> response code as your eventvalue.
>
> Good luck,
>
> ---
> Anne E. Urai, MSc
> PhD student | Institut für Neurophysiologie und Pathophysiologie
> | Universitätsklinikum Hamburg-Eppendorf
> Martinistrasse 52, 20246 Hamburg, Germany | http://anneurai.wordpress.com
>
>
>
>
>
> On 28 Sep 2014, at 11:54, KatrinH Heimann <katrinheimann at gmail.com> wrote:
>
> Dear all,
> I know I asked this already twice, but I did not get the right answer yet
> and just cannot figure it out myself.
> So, I did cut my data in quite large trials using ft_define trial and
> logging it to the beginning of a slide.
>
> cfg                     = [];
> cfg.dataset             = name;
> cfg.trialfun            = 'ft_trialfun_general'; % this is the default
> cfg.trialdef.eventtype  = 'trigger';
> cfg.trialdef.eventvalue = 'ceck'; % the value of the stimulus trigger
> cfg.trialdef.prestim    = 0.216; % in seconds
> cfg.trialdef.poststim   = 7.284; % in seconds (max time of check slide)
> cfg                     = ft_definetrial(cfg);
>
>
> % cancel out training trials
> cfg.trl([1:4],:) = [];
>
>
> %change timeline according to constant offset of 16 ms = 8 samples
> (because recorded with 500 hz)in
> %structure trial - plus delay reported by EGE = 18 ms = 9 samples
> cfg.trl(:,3)=cfg.trl(:,3)-17
>
>
>
>
>
>  Then I preprocessed these trials
>
> %% preprocess data
> cfg.channel    = 'all';
> cfg.preproc.detrend       = 'yes';
> cfg.preproc.demean = 'yes';
> cfg.preproc.baselinewindow = [-0.1 0]
> %
> mov_data           = ft_preprocessing(cfg);
> %
> save (strcat(sb,'mov_data') , 'mov_data')
>
>
>
> Now I wanna cut out smaller pieces that are centered around another
> trigger - the response of the subject. I did not use this trigger at the
> beginning as then defining a baselinewindow is impossible (as the response
> is always happening at a different time).
>
> I tried to just use ft_definetrial again, as I don't see a possibility to
> use ft_redefine trial:
>
> cfg = []
> cfg.dataset= strcat(sb,'mov_data.mat')
> cfg.trialdef.eventtype  = 'trigger';
> cfg.trialdef.eventvalue = 'resp'
> cfg.trialdef.prestim    = 0.75
> cfg.trialdef.poststim   = 0.75
>
>
> mov_data_small = ft_definetrial(cfg)
>
> but I get the error message:
>
> Error using ft_read_header (line 1833)
> unsupported header format (matlab)
>
> Error in ft_trialfun_general (line 71)
> hdr = ft_read_header(cfg.headerfile, 'headerformat', cfg.headerformat);
>
> Error in ft_definetrial (line 169)
>     [trl, event] = feval(cfg.trialfun, cfg);
>
>
>
>  I wonder if that is as the file produced by fieldtrip during the
> preprocessing is not one that is specified for ft_read_header - but how do
> I deal with this?
>
> Thanks a lot for your help
>
> Katrin
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140928/fd017ddd/attachment-0002.html>


More information about the fieldtrip mailing list