[FieldTrip] problem with ft_freqanalysis foi

Elliott, Grace Mae gelliott at unc.edu
Fri Feb 4 18:26:08 CET 2022


Hi all,

I'm brand new to fieldtrip, so I apologize for what may be a remedial question. I have resting-state continuous EEG data (71 channels, sampling rate 1000Hz, 7 minutes in length) and I'm trying to write a script to analyze connectivity with WPLI. I'm running into two issues right now:

1.) When I try to specify a frequency range with cfg.foi in ft_freqanalysis, I keep receiving an error that the frequencies are above the Nyquist. My sampling rate is 1000Hz, so I'm confused about this error when I'm only entering values up to 60Hz.

2.) When I forgo using cfg.foi and run through the script, I keep ending up with a WPLI spectrum matrix of NaN values and an error message that WPLI requires >1 trial. I've tried segmenting my data and trying to keep trials throughout frequency analysis, but this does not appear to be working.

Thank you to all readers - I am open to any suggestions! The script I've been using:

%load set from EEGLAB
datafile = pop_loadset('data.set')

%format set into fieldtrip compatible structure
hdr = ft_read_header('data.set')
ftdata = []
ftdata.time = datafile.times
ftdata.trial = ft_read_data('data.set','data',hdr)
ftdata.label = hdr.label
ftdata.fsample = 1000.0
ftdata.dimord = 'chan_time'

%segment data
cfg0 = []
cfg0.length = 105250
cfg0.overlap = 0
freq1 = ft_redefinetrial(cfg0, ftdata)

%check datatyppe
data2 = ft_datatype(freq1)

cfg2 = []
cfg2.covariance = 'yes'
cfg2.keeptrials = 'yes'
[freq] = ft_timelockanalysis(cfg2, freq1)

%frequency analysis
cfg8 = []
cfg8.method = 'mtmfft'
cfg8.taper = 'hanning'
cfg8.keeptrials = 'yes'
cfg8.output = 'powandcsd'
cfg8.foi = 9.0:1.0:20.0
freq.label = hdr.label
freq.fsample = 1000.0
freq10 = ft_freqanalysis(cfg8, freq)

%check datatype
data5 = ft_datatype(freq10)

%calculate wpli
cfg4 = []
cfg4.method = 'wpli'
[wpli] = ft_connectivityanalysis(cfg4, freq10)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220204/ce760edb/attachment.htm>


More information about the fieldtrip mailing list