[FieldTrip] Trials are not averaging

Selena Zhang selenazh at usc.edu
Wed Aug 9 20:24:17 CEST 2023

Hello all,

I'm new to FieldTrip so I would appreciate any help I can get.
I'm trying to plot the connectivity of many different channels with the
direct transfer function.

My problem right now is that once I get the output of ft_freqanalysis, the
time scale just runs through all of the trials instead of just the length
of one trial. I did ft_definetrial, and it properly defined all 54 trials,
although it didn't detect any events, so I'm not sure what the problem
could be.

Here is my code:

cfg = [];
cfg.trialfun = 'ft_trialfun_general';
cfg.eventtype = 1;
cfg.trialdfef.eventvalue = 1; % limits to only valid and Go trials (in case
of GNG)
cfg.trialdef.prestimulus = min2/fs;
cfg.trialdef.poststimulus = min3/fs;
cfg.dataset = 'Users/selenazhang/Documents/MATLAB/blxlab/data/Data P024
Direct Reach/connectivity/P24DR_rawdata.mat';
cfg.trialdef.ntrials = length(trials);
cfg.trialdef.length = (min2+min3+1)/fs;
[cfg] = ft_definetrial(cfg);

cfg.channel = 'all';
cfg.continuous = 'yes';
[preprocess_data] = ft_preprocessing(cfg, rawdata);

cfg = [];
cfg.method = 'mtmconvol'; % multi taper time-freq analysis
cfg.output = 'powandcsd'; % power and cross spectrum
cfg.channel = 'all';
cfg.trials = 'all';
cfg.pad = 3; % adding padding allows for desired foi
cfg.channelcmb = {'all' 'all'}; % which channels to cross spectrum
cfg.taper = 'hanning';
cfg.foi = 13:1:30; % frequency of interests [13 30] Hz
cfg.t_ftimwin = ones(1,length(cfg.foi))*.4; % moving window in seconds as a
1xnumfoi vector
cfg.toi = '99%'; % overlap of each window, like step size
cfg.avgovertrials = 'yes';
[freqanalysis_data] = ft_freqanalysis(cfg, preprocess_data);

Any idea of what could be wrong? (rawdata is structured the way
ft_datatyperaw describes) Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230809/1e2228cc/attachment.htm>

More information about the fieldtrip mailing list