[FieldTrip] common ft_freqbaseline for variable length trials

Wanja Moessing WanjaMoessing at gmx.de
Mon Jun 15 19:23:46 CEST 2015


Dear Fieldtripers,

We have EEG data with variable length trials and want to look at the time-frequency response around two triggers.
As we want to use the same baseline for both TOIs, we preprocess the complete trials (6-8s) with variable 
triallength and use ft_freqanalysis with keeptrials = 'yes'. Then baseline with ft_freqbaseline
and subsequently we would like to cut out trialwise the +/- 1.5s around each trigger and then average these pieces.
Information about the respective triggers is stored in .trialinfo as trigger+sample to be able to locate the triggers. 

For some reason I cannot seem to find an option to redefine and average the trials after baseline and wavelet analysis.
Attached is the code we use. I'd be thankful for any hints.

Kind Regards,
Wanja

----------------------------CODE---------------------------------------

    cfg                     =   [];
    cfg.keeptrials          =   'yes';
    cfg.keeptaper           =   'no';
    cfg.output              =   'pow';
    cfg.channel             =   {'FCz','Cz'};
    cfg.method              =   'wavelet';
    cfg.pad                 =   'maxperlen';
    cfg.foi                 =   [1:2:40];
    cfg.toi                 =   'all';
    cfg.width               =   9;
    cfg.conditions          =   [1.7,1.8,1.9,2.7,2.8,2.9];

    baselinecfg                     =    [];
    baselinecfg.baseline            =    [-1 0]; %1s before trialonset
    baselinecfg.baselinetype        =    'relchange';
    baselinecfg.parameter           =    'powspctrm';


   %loop over subjects and conditions
   for subject = 1:length(data_all_clean)
       curcon               =   0;
       for cond = cfg.conditions
           curcon           =   curcon+1;
           idx              =   0;
           cfg.trials       =   find(data_all_clean(subject).trialinfo(:,1) == cond); %contains info about the condition of each trial

            data_subj_Wave{1,curcon}   =   ft_freqanalysis(cfg,data_all_clean(subject));          %Data of subject x in condition y
            data_subj_Wave{6,curcon}   =   ft_freqbaseline(baselinecfg,data_subj_Wave{1,curcon}); %...and the baselined data
            data_subj_Wave{2,curcon}   =   cond;                                                  %pass information about the condition on
            data_subj_Wave{3,curcon}   =   length(cfg.trials);                                    % store N trials per condition
            data_subj_Wave{4,curcon}   =   data_all_clean(subject).trialinfo(1,2);                %SubjectNr
            data_subj_Wave{5,curcon}   =   data_all_clean(subject).trialinfo(1,3);                %SessionNr
        end
        data_all_Wave{1,subject}       =   data_subj_Wave;
        data_all_Wave{2,subject}       =   data_all_clean(subject).trialinfo(1,2);
        data_all_Wave{3,subject}       =   data_all_clean(subject).trialinfo(1,3);
    end



More information about the fieldtrip mailing list