[FieldTrip] Reducing edge effects in TF analysis with padding

Pieper, Sarah Morgan pieper4 at purdue.edu
Wed Feb 19 23:21:57 CET 2025


Dear Fieldtrippers,

My name is Sarah Pieper and I'm a graduate student at a neurophysiology lab at Purdue University. I'm currently working on a project where I'm performing time-frequency analysis with Morlet wavelets. I've run the TF analysis in Fieldtrip and am receiving the typical U-shaped power spectrum with NaNs around the edges. I'm hoping to reduce these edge effects at least somewhat with padding, since they are currently contaminating my baseline period, but have not been successful with this.

I'm reading in already preprocessed data from BrainVision Analyzer. I've created segments that correspond to the entire duration of each trial, from -500 ms to 4400 ms, and am interested in analyzing most of it (ideally from -300 ms to around 4000 ms). I'd like to use a baseline of -300 to -100 ms. The sampling rate is 250 Hz.

I've been trying to reduce the edge effects with zero or mirror-padding but find that the results visually look the same with or without padding, with the same edge effects. When looking at the actual power spectrum results, the number of NaNs is also identical with or without padding. Essentially, I'm not recovering any additional power spectrum values with padding and I wanted to ask if I'm performing the padding correctly or if I just shouldn't expect to reduce edge effects with padding.

Here is my zero-padding code:
cfg = [];
cfg.channel = 'EEG';
cfg.method = 'wavelet';
cfg.width = linspace(3, 15, length(3:1:50));
cfg.output = 'pow';
cfg.foi = 3:1:50;
cfg.toi = -0.5:0.048:4.4;
cfg.pad = 4.9;
cfg.padtype = 'zero';
TFRwave = ft_freqanalysis(cfg, eeg_data)
Here is my mirror-padding code. I add the mirror-padding in during the ft_preprocessing step as instructed in the tutorials, then follow up with the TF analysis using ft_freqanalysis like the code above:
cfg = [];
cfg.dataset = 'path to file.dat';
cfg.trialdef.eventtype = 'Stimulus';
cfg.trialdef.eventvalue = 'S 0';
cfg.trialdef.prestim = 0.5;
cfg.trialdef.poststim = 4.4;
[cfg] = ft_definetrial(cfg);
cfg.padding = 0.5;
cfg.padtype = 'mirror';
[eeg_data_padded] = ft_preprocessing(cfg);
Thank you in advance for your help!

Best,
Sarah

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250219/5692eadc/attachment.htm>


More information about the fieldtrip mailing list