[FieldTrip] Single trial baseline correction in ft_preprocessing

Duru Gun Ozkan durugun.ozkan at uniroma1.it
Fri Sep 20 08:35:08 CEST 2019


Dear Stephen,

Thank you for your response. It seemed like your suggestion helped, but I
thave another potential issue now.
The problem is, when I use *ft_databrowser *to visualise the trials after
baseline corection loop, I can no longer see the markers, even if I
add * cfg.plotevents
= 'yes'*. I can see that this information exists in the data structure, so
I'm not sure if this is a problem per se. But the bigger issue is, after
running these loops, the data becomes very large (even after being
appended), impossible to save, and slows down the rest of my analysis,
where regular baseline correction doesn't cause this.

 Any ideas where I might be going wrong? I suspect I might have used the
wrong kinds of brackets, but the curly brackets as in your suggestion
caused an error about cell structures, and when I run it as I wrote, the
data structures actually look fine.Or it might be the way that I made a
loop to append the data, instead of spelling it out for all of the 360
trials.

Another somewhat related question, is it possible to have the baseline
window outside of the defined trial length?

 Here is what I did:

 for trial_index = 1:360

     cfg                = [];
     cfg.demean         = 'yes';
     cfg.baselinewindow = [BaselineWindow(trial_index,1)
BaselineWindow(trial_index,2)];
     cfg.trials         = trial_index;
     bl_end_E(trial_index)  = ft_preprocessing(cfg, data_end_E);

 end

%% This results in the struct:
 bl_end_E =   1×360 struct array with 8 fields:
    hdr
    fsample
    trialinfo
    sampleinfo
    trial
    time
    label
    cfg

%% Then I append the data:
 data_base_end_E = bl_end_E(1);

 for trial_ind = 2:360

     cfg                 = [];
     cfg.keepsampleinfo  = 'yes';
     data_base_end_E     =
ft_appenddata(cfg,data_base_end_E,bl_end_E(trial_ind));

 end

%% This results in losing hdr and fsample fields: data_base_end_E =
struct with fields:

         label: {29×1 cell}
     trialinfo: [360×4 double]
    sampleinfo: [360×2 double]
         trial: {1×360 cell}
          time: {1×360 cell}
           cfg: [1×1 struct]
%% So I add them back:
  base_end_E.hdr = data_end_E.hdr;
  base_end_E.fsample = data_end_E.fsample;

    %% Visual data inspection
    cfg                   = [];
    cfg.viewmode  = 'vertical';
    cfg.continuous = 'no';
    cfg.blocksize   = 1.5;
    cfg.channel     = {'all'};
    cfg                   = ft_databrowser(cfg,data_base_end_E);


Thanks again for the help!

Duru

-- 
*Duru G**ü**n **Ö**zkan*


*Ph.D. student in Cognitive Social and Affective Neuroscience.*


*Department of Psychology.University of Rome "La Sapienza".Via dei Marsi 78
- 00185 - Roma.*
 *e-mail: durugun.ozkan at uniroma1.it <vanessa.era at uniroma1.it>*
*https://agliotilab.org/lab-staff/phd-students/2nd-year#anchor
<https://agliotilab.org/lab-staff/phd-students/2nd-year#anchor>*

> Hi Duru,

>   Use cfg.trials = trial_index
>   Put the output in a struct, i.e. bl{trial_index}
>   Then combine with ft_append_data([],bl{:});

>   Hope this helps,
>   Stephen


>   On Tue, 17 Sep 2019, 19:30 Duru Gun Ozkan, <durugun.ozkan at uniroma1.it>
>   wrote:

> Hi everyone,
>
> I have a question regarding specifying a different baseline correction
> time for each trial in ft_preprocessing.
> I had 360 audio stimuli all of which had different lengths. My trigger is
> located at the end of each stimuli, and I would like to place the baseline
> correction between 200 ms before stimulus start and stimulus start.
> I have a matrix for cfg.baselinewindow called BaselineWindow such as this:
> -1.83018 -1.630182
> -1.69807 -1.498071
> -0.58653 -0.38653
> -1.07604 -0.876039
> -2.2608 -2.060803
> -0.80863 -0.608632
> -1.55663 -1.356629
> -0.94261 -0.742605
> -1.20845 -1.008448 ...
> I tried to create a loop:
>
> for trial_index = 1:360
>
>      cfg = [];
>      cfg.demean        = 'yes';
>      cfg.baselinewindow = [BaselineWindow(trial_index,1)
> BaselineWindow(trial_index,2)];
>
>      data_baselined_end_E = ft_preprocessing(cfg, data_end_E);
>
>  end
>
> This didn't work because it kept running the preprocessing with all the
> baselines with all trials, instead of keeping to its specific trial.
>
> My question is, is there another way to specify individual baselines for
> individual trials? Or can anyone suggest to improve this loop to have the
> data preprocessed with its specific baseline windows?
>
> Thank you in advance.
>
> Best,
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190920/964b60a5/attachment.html>


More information about the fieldtrip mailing list