[FieldTrip] ft redefine trials: how to change trigger?

Max Cantor mcantor at umich.edu
Tue May 27 23:39:31 CEST 2014


I'm hesitant to say impossible, but I'm not sure how to do it off-hand.
Also, there may be some other complications, now that I think I understand
your situation better.

If you're trying to cut based on the buttonpresses, which are
inconsistent/unreliable, any large number of trials would make it
impractical to define/redefine your epoch for each one, especially since
this process would need to be customized for each subject. It might be
better to keep it in a larger window, or come up with a few general windows
to encompass, for instance 'early', 'on target', and 'late' button press
windows.

For all of the experiments I've worked on in which we've used / are using
fieldtrip for our data analysis pipeline, we've never used behavioral
responses for anything other than a control (as in, lack of response or
incorrect response leads to rejecting the trial), so I don't really know if
there is a particular systematic way to incorporate behavioral or floating
triggers like what you seem to be looking to do.

I might suggest, though keep in mind this is entirely speculative, rather
than trying to create a pinpoint window around the response, that instead
you use a wide window, and then either by viewing the data, or perhaps
using independent component analysis, try to pinpoint for each subject when
the button press may have occurred based on some kind of muscle artifact,
and then in later timelock/time-frequency/statistical analyses specify that
time window. Again, that is just me spitballing, but something
post-processing may be a better solution, if the behavioral response is
pivotal to the analysis of your experiment and not just for making sure the
subject was paying attention / understands the prompt, as in the
experiments I've worked on.


On Tue, May 27, 2014 at 5:02 PM, KatrinH Heimann <katrinheimann at gmail.com>wrote:

> Hi! Guys, your help is so much appreciated!
> So I try to be more clear!:
> So, yeah, Max, you are right! At the end I would like to use two different
> triggervalues.
>
> If I would use twice ft_definetrial then it would look like this:
>
> cfg                     = [];
>
> cfg.dataset             = '1.raw';
>
> cfg.trialfun            = 'ft_trialfun_general';
>
> cfg.trialdef.eventtype  = 'trigger';
>
> cfg.trialdef.eventvalue = 'stim'; % the value of the stimulus trigger for
> the beginning of baseline
>
> cfg.trialdef.prestim    = 0.5;  %the time of the fixation cross
>
> cfg.trialdef.poststim   = 1.5; %the time of the baseline (plus 0.5 buffer)
>
> cfg                = ft_redefinetrial(cfg);
>
>
> This baselinedata I could easily baselinecorrect using 100 ms of the
> fixationcrossperiod:
>
>
> cfg.channel    = 'all';
>
> cfg.preproc.demean = 'yes';
>
> cfg.preproc.baselinewindow = [-0.1 0]
>
> cfg.preproc.bpfilter = 'yes';
>
> cfg.preproc.bpfreq = [6 32];
>
>
> The stimulusdata would be defined using a trigger that corresponds to a
> button press:
>
>
> cfg                     = [];
>
> cfg.dataset             = '1.raw';
>
> cfg.trialfun            = 'ft_trialfun_general';
>
> cfg.trialdef.eventtype  = 'trigger';
>
> cfg.trialdef.eventvalue = 'resp'; % the value of the stimulus trigger for
> the beginning of baseline
>
> cfg.trialdef.prestim    = 0.5;  % 0.5 sec before button press
>
> cfg.trialdef.poststim   = 1.5; % 1.5 sec after button press (time that I
> wanna analyse)
>
> cfg                = ft_redefinetrial(cfg);
>
>
> However here I have the problem that I cannot correct with the same
> baseline than before as the buttonpress is not always at the same time so I
> don't know when the fixationcrossperiod is located...
>
>
> So I thought I could first "cut" bigger pieces and then redefine trials by
> cutting again (after the preprocessing), then with different eventvalues
> ...
>
> But you say that is not possible?
>
>
>
> Thanks a lot for your help!!!
>
>
> Katrin
>
>
>
> 2014-05-27 21:05 GMT+02:00 Max Cantor <mcantor at umich.edu>:
>
> Ya, it would definitely help if we could see your code, but I might have
>> another idea.
>>
>> When you say you have a fixation cross trigger, is this trigger being
>> recorded from your EEG recording equipment in such a way that it can be
>> represented as an event value in cfg.trialdef for ft_definetrial? If so, I
>> think you may be right that it can't be changed through ft_redefinetrial
>> (at least, as far as I can tell, no mention of this is made in the help
>> section of the function). That being said, if you run ft_definetrial
>> separately for both event values that should work.
>>
>> That being said, I may still be slightly confused about what you mean
>> when you say you want to change the trigger. Do you mean you want to create
>> a new trigger for your data off-line? I think it may be possible to create
>> custom triggers off-line through fieldtrip, but it's not something I've
>> tried personally, but if that is what you are trying to do, I could look
>> into it.
>>
>>
>> On Tue, May 27, 2014 at 2:44 PM, kousik sarathy <sarathykousik at gmail.com>wrote:
>>
>>> Hey Katrin,
>>>
>>> It seems to me that Max's suggestion would suffice. But you seem to be
>>> looking for something else. Could you elaborate a little bit as to what you
>>> need?
>>>
>>> --
>>> Regards,
>>> Kousik Sarathy, S
>>>
>>>
>>>
>>> On Tue, May 27, 2014 at 8:30 PM, KatrinH Heimann <
>>> katrinheimann at gmail.com> wrote:
>>>
>>>> Dear Max, thanks a lot for your prompt answer. Unfortunately this is
>>>> not what I am looking for (I found an example like this in the tutorial). I
>>>> would like to change the trigger for one of the two conditions, let it be
>>>> now the response of the subject, as this is where the stimulus actually
>>>> starts... Defining two different timewindows is not enough... Can you also
>>>> help me with that? Thanks a million! Katrin
>>>>
>>>>
>>>> 2014-05-27 18:58 GMT+02:00 Max Cantor <mcantor at umich.edu>:
>>>>
>>>> Hi Katrin,
>>>>>
>>>>> It may help to see your code, but hopefully this will help. It should
>>>>> be as simple as taking your epoched data from ft_definetrial and
>>>>> ft_preprocessing, then creating two configurations for your timewindows and
>>>>> running ft_redefinetrial.
>>>>>
>>>>> For example (from the fieldtrip tutorial, slightly simplified by me
>>>>> for explanatory purposes):
>>>>>
>>>>> ***
>>>>>
>>>>> % find the interesting segments of data
>>>>>
>>>>> cfg                             = [];
>>>>>                      % empty configuration
>>>>> cfg.dataset                 = 'Subject01.ds';
>>>>>            % name of CTF dataset
>>>>> cfg.trialdef.eventtype    = 'backpanel trigger';
>>>>> cfg.trialdef.prestim       = 1;
>>>>> cfg.trialdef.poststim     = 2;
>>>>> cfg.trialdef.eventvalue   = 3;
>>>>>               % event value of FIC
>>>>> cfg                             = ft_definetrial(cfg);
>>>>>
>>>>> % preprocess the data
>>>>>
>>>>> cfg.channel                 = {'MEG'};
>>>>> dataFIC                      = ft_preprocessing(cfg);
>>>>>
>>>>> % define time window
>>>>>
>>>>> cfg                            = [];
>>>>>
>>>>> cfg.toilim                   = [-0.5 0];
>>>>> dataPre                     = ft_redefinetrial(cfg, dataFIC);
>>>>>
>>>>> cfg.toilim                   = [0.8 1.3];
>>>>> dataPost                   = ft_redefinetrial(cfg, dataFIC);
>>>>>
>>>>> ***
>>>>>
>>>>> So if your code resembles this, you are defining in
>>>>> cfg.trialdef.prestim and cfg.trialdef.poststim a timewindow that
>>>>> encompasses both your baseline period and stimulus period, then for
>>>>> cfg.toilim in the ft_redefinetrial section you are setting one to your
>>>>> baseline period and the other to your stimulus period, and outputting them
>>>>> into separate variables.
>>>>>
>>>>> Hopefully this helps. Also, if you haven't done so already, I would
>>>>> strongly recommend you run through the tutorial, as it may help answer
>>>>> questions like this in the future (assuming I've properly identified the
>>>>> issue).
>>>>>
>>>>> Good luck,
>>>>>
>>>>> Max
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, May 27, 2014 at 12:10 PM, KatrinH Heimann <
>>>>> katrinheimann at gmail.com> wrote:
>>>>>
>>>>>> Dear all,
>>>>>>
>>>>>> my name is Katrin Heimann, I am phd student at the University of
>>>>>> Parma. New to Fieldtrip.
>>>>>> I am doing an EEG analysis, still in the preprocessing phase.
>>>>>> It is a within trials design. I would like to compare a baseline
>>>>>> period with an experimental condition (visual stimulus).
>>>>>>
>>>>>>  I have a trigger after a fixation cross, then a baseline period
>>>>>> (approx 1 sec) , then the period of my stimulus (1 sec- starting with a
>>>>>> bottom press (trigger)).
>>>>>>
>>>>>>  As I would like to apply the same baseline correction for both (the
>>>>>> fixationcross period)  I planned to first define my trials as long trials
>>>>>> including the timewindows of baseline and the stimulus period, applying
>>>>>> filter and baselinecorrection on those long pieces. However, as I do not
>>>>>> wanna do the artifact detection on the whole pieces (but seperately for
>>>>>> baseline and stimulus, to avoid that I have to throw away too many trials)
>>>>>> I would like to redefine my trials then, cutting out only baseline period
>>>>>> and only stimulus period (starting with another trigger
>>>>>> (triggervalue=resp)..
>>>>>>
>>>>>> *Unfortunately I do not understand how I can change the trigger used
>>>>>> with ft redefine trial. *
>>>>>>
>>>>>> Anybody who could give me an example how that is done?
>>>>>> Thanks a million
>>>>>> Katrin
>>>>>>
>>>>>> _______________________________________________
>>>>>> fieldtrip mailing list
>>>>>> fieldtrip at donders.ru.nl
>>>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Max Cantor
>>>>> Research Assistant
>>>>> Computational Neurolinguistics Lab
>>>>> University of Michigan
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>
>>
>>
>> --
>> Max Cantor
>> Research Assistant
>> Computational Neurolinguistics Lab
>> University of Michigan
>>
>> _______________________________________________
>> 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
>



-- 
Max Cantor
Research Assistant
Computational Neurolinguistics Lab
University of Michigan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140527/ca1f6d34/attachment-0002.html>


More information about the fieldtrip mailing list