[FieldTrip] Updating trial information

Arana, S.L. (Sophie) S.Arana at donders.ru.nl
Fri Jul 19 11:47:02 CEST 2019


Hi Carolina,


It is true that filtering can cause edge effects. If you use ft_preprocessing on continuous data, you can make use of the option cfg.padding. See here for details http://www.fieldtriptoolbox.org/faq/how_does_the_filter_padding_in_preprocessing_work/‚Äč


Doing it like this will save you the trouble of having to redefine trials after artifact rejection.


Hope this helps,

Sophie

________________________________
From: Carolina Ogawa <carolyogawa at gmail.com>
Sent: Thursday, July 18, 2019 7:55 PM
To: Arana, S.L. (Sophie)
Subject: Re: [FieldTrip] Updating trial information

Hi, Sophie,

Thank you very much for your reply!

Filtering the data after cutting it into trials doesn't distort the edges of the trials? For this reason, I've always thought that it was better to filter the continuous data first and then cut it into trials. But maybe I should cut larger trials first and then cut the edges?

In case I want to stick to my order of processing steps (rereferencing / filtering => defining trials => rejecting segments with artifacts), how do I get the trial information (the time points for each event in my data, which is stored in "cfg.event" and "cfg.trl") updated after rejecting segments with  artifacts?


Best,
Carolina

On Thu, Jul 18, 2019 at 4:07 AM Arana, S.L. (Sophie) <S.Arana at donders.ru.nl<mailto:S.Arana at donders.ru.nl>> wrote:

Hi Carolina,


I am not sure whether there is a reason why you read the data in as continuous first? If not your pipeline might be more efficient if you first define the trials with ft_definetrial and then read in / segment / filter the data by passing the resulting cfgout to ft_preprocessing (basically following this tutorial http://www.fieldtriptoolbox.org/tutorial/preprocessing/) and subsequently use ft_databrowser on the already segmented trials.


If you need to stick to your order of processing steps, then maybe the function you are looking for is ft_redefinetrial, which allows you to cut data into trials at a later stage.


best,

Sophie


________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of Carolina Ogawa <carolyogawa at gmail.com<mailto:carolyogawa at gmail.com>>
Sent: Wednesday, July 17, 2019 5:22 PM
To: fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>
Subject: [FieldTrip] Updating trial information

Dear community,

My name is Carolina Ogawa, and I'm working with EEG at the University of Sao Paulo, Brazil. I intend to analyze oscillatory gamma activity from the EEG data I recorded.

I'd like to know how I get the trial information (the information stored in "cfg.event" and "cfg.trl") updated after rejecting segments of data (due to artifacts), so that my data will be correctly segmented into trials afterwards.

My pipeline involves, in the following order:

  1.  Rereferencing and filtering (ft_preprocesing)

(cfg definition)
...
data_filt      = ft_preprocessing(cfg);

  2.  Defining trials with ft_definetrial (so that I have the trials information stored on "cfgout.trl")

    cfg                            = [];
    cfg.dataset                 = fullfile(path_inputData,subject{i});
    cfg.trialdef.eventtype = 'Stimulus';
    cfg.trialfun                   = 'ft_trialfun_general';
    cfgout                         = ft_definetrial(cfg);

  3.  Removing segments with artifacts, using ft_databrowser and ft_rejectartifact. (EEG data is continuous up to this point).

    cfg               = [];
    cfg.continuous    = 'yes';
    cfg.channel       = 'all';
    cfg.viewmode      = 'butterfly';
    artif             = ft_databrowser(cfg, data_filt);

    cfg                        = [];
    cfg.artfctdef.minaccepttim = 0.010;
    cfg.artfctdef.reject       = 'partial';
    cfg.artfctdef.visual.artifact = artif.artfctdef.visual.artifact;
    data_rejInt = ft_rejectartifact(cfg, data_filt);


I tried using "ft_recodeevent", as follows:
cfg = [];
trl = cfgout.trl;
cfg.trl = trl;
cfg.eventtype = 'Stimulus';
[ev] = ft_recodeevent(cfg, data_rejInt);

but I get this error:
Error using ft_recodeevent (line 114) could not locate event structure in the data


Can someone tell me if there something wrong with the "cfg" settings of if I'm using an improper function to this situation? I also tried running "ft_rejectartifact" with "cfg" as the only input parameter, expecting that the output would be a "cfg" structure with an updated "trl" (as described in the "ft_rejectartifact" reference page). Instead, what I receive is the error:

Undefined function or variable "trl".
Error in ft_rejectartifact (line 252) if isempty(trl)


Any help would be appreciated,

Best,
Carolina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190719/67cfb96b/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list