[FieldTrip] Problems with plotting time-frequency analysis results

Ella Weik ella.weik at gmail.com
Thu Apr 20 01:12:24 CEST 2017


Hi Fieldtrip Community,

We are currently trying to run a wavelet time frequency analysis. Our EEG
data is already preprocessed and epoched with EEGlab. We are able to read
in the data, define trials, and output values for TFR.powspctrm. However,
we do not see any of these values plotted on our figure with ft_singleplot.

This is the code we are using:

cfg = [];
cfg.dataset                  = dsname;
cfg.continuous             = 'no';
cfg.trialfun                   = 'wm_trialfun';
cfg.binNumber             = 13;
cfg.epochBaseInt         = -0.5;
cfg.epochInt                 = 1.5;
cfg.trialdef.prestim        = cfg.epochBaseInt - 0.01;
cfg.trialdef.poststim       = cfg.epochInt - 0.01 ;
cfg = ft_definetrial(cfg);
dataFIC = ft_preprocessing(cfg);
save dataFIC_DirCue dataFIC;
dataFIC_condX

cfg = [];
cfg.channel    = 'EEG';
cfg.trials     = 'all'
cfg.keeptrials = 'no';
cfg.output     = 'pow';
cfg.foi        = 2:0.5:50;
cfg.toi        = -0.4:0.01:1.4; %
cfg.method     = 'wavelet';
cfg.width      = 7;
cfg.length     = 2;
TFR = ft_freqanalysis(cfg, dataFIC);
save TFRwave_DirCue TFR

% plot the results
cfg = [];
cfg.parameter = 'powspctrm';
cfg.baseline     = [-0.4 0];
cfg.baselinetype = 'relative';
cfg.zlim         = [-3e-10 3e-10];
cfg.showlabels   = 'yes';
figure;
ft_singleplotTFR(cfg,TFR);


And this is our trial_function:

function [trl, event] = wm_trialfun(cfg);
hdr   = ft_read_header(cfg.dataset);
event = ft_read_event(cfg.dataset);
indx=[];
if cfg.binNumber
    for i = 1:size(event,2)
    if ismember(cfg.binNumber,event(i).bini)
    indx=[indx;1];
    else indx=[indx;0];
    end
    end
    ind = find(indx);
    sample = [event(ind).sample]';
else
    sample = [event(find(strcmp(cfg.codeLabel,
{event.codelabel}))).sample]';
end
epochBaseSamples = -1*cfg.epochBaseInt*hdr.Fs;
epochSamples = cfg.epochInt*hdr.Fs;
epochTotal = epochBaseSamples + epochSamples;
epochStarts = [1:epochTotal:sample(end)];
eventStarts = epochStarts + epochBaseSamples;
sampleGood = intersect(sample,eventStarts);
pretrig  = -round(cfg.trialdef.prestim  * hdr.Fs);
posttrig =  round(cfg.trialdef.poststim * hdr.Fs);
trl = [];
trl(:,1) = sampleGood + pretrig;
trl(:,2) = sampleGood + posttrig;
trl(:,3) = pretrig;

And this is the cfg:

channel: {128x1 cell}
               trials: 'all'
           keeptrials: 'no'
               output: 'pow'
                  foi: [1x15 double]
                  toi: [1x28 double]
               method: 'wavelet'
                width: 7
               length: 3
    outputfilepresent: 'overwrite'
             callinfo: [1x1 struct]
              version: [1x1 struct]
             feedback: 'text'
            inputlock: []
           outputlock: []
               gwidth: 3
                  pad: 0.9820
              padtype: 'zero'
              calcdof: 'no'
            precision: 'double'
     correctt_ftimwin: 'no'
          polyremoval: 0
           keeptapers: 'no'
             previous: [1x1 struct]


Any insights would be greatly appreciated with regards to why we cannot see
any values in our single plot figure. Also, we are not sure if the problem
rests in our plotting configuration or the data itself.

Best regards,
Ella
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170419/150ec83e/attachment-0001.html>


More information about the fieldtrip mailing list