[FieldTrip] Spike-field analysis (combine freq and spike ; using ft_spiketriggeredspectrum)

vincent.fontanier at inserm.fr vincent.fontanier at inserm.fr
Wed Nov 7 13:53:52 CET 2018

Hi everybody!

I want to do some spike-field analysis on my dataset and have some 
questions regarding how fieldtrip handle such data and about the use of 
some of the functions related to this topic.

1. I have not found a fieldtrip way to combine freq structure (typically 
output from ft_freqanalysis) and spike structures. If I got it right, 
the fieldtrip pipeline to do spike-field is as follow:

  assuming filt_trials is the epoched LFP and spike is a fieldtrip spike 

·         EPOCH the spike data like the LFP

% spike to trials based on the epoched raw signal

cfg           = [];

cfg.hdr       = filt_trials.hdr; % contains information for conversion 
of samples to timestamps

cfg.trlunit   = 'samples';

cfg.trl       = filt_trials.cfg.trl; % now in samples

spikeTrials   = ft_spike_maketrials(cfg,spike);

·         Compute the spike triggered spectrum

cfg           = [];

cfg.method    = 'mtmfft'; %'mtmconvol' is more powerful with many 
neurons and great firing rate

cfg.foilim       = [0 40]; % cfg.timwin determines spacing

cfg.taper     = 'hanning';

cfg.timwin       = [-0.1 0.1]; %time around each spike

stsConvol   = ft_spiketriggeredspectrum(cfg, filt_trials, spikeTrials);

·           Make some analysis on the spike triggered spectrum

cfg               = [];

cfg.method        = 'ppc0'; % compute the Pairwise Phase Consistency

cfg.avgoverchan   = 'unweighted'; % weight spike-LFP phases irrespective 
of LFP power

cfg.timwin        = 'all'; % compute over all available spikes in the 

cfg.latency       = [-1 3];

statSts           = ft_spiketriggeredspectrum_stat(cfg, stsConvol   );

However having already performed time-frequency decomposition of all my 
LFP data I find this inefficient having to compute them again. 
Furthermore the methods of TF decomposition implemented in 
ft_spiketriggeredspectrum are much more limited than the one in 

So is there a way to combine the two together?

A workaround is to realign the two together taking the sample of each 
spike in spikeTrials.timestamp{1}; and the start and end sample of each 
trial from the freq structure (freq.cfg.previous.trl. But this does not 
keep the fieldtrip way of formatting the data. Moreover this would 
require adjustments for further fieldtrip computations such as 
pairwise-phase consistency analysis using 

2. (Useless if there is a solution to 1.) In ft_spiketriggeredspectrum 
you can provide a time window around each spike in the input to compute 
the spectrum. However the output spectrum is not time-resolved. 
Basically the output is just the average spectrum during the provided 
time window. Thus it is impossible to reconstruct the spike triggered 
time-frequency representation of the data. It is possible to run many 
iteration of ft_spiketriggeredspectrum for each timebin and store the 
output in a {chan}_spike_lfpchan_freq_time cell but it sounds like a 
very inefficient way to go. Therefore I am wondering if there is one way 
to do that more efficiently, for example an option that I missed in 

Additionally could this time-resolved spiketriggeredspectrum output be 
used as an input to ft_spiketriggeredspectrum_stat in order to have a 
time-resolved output of the analysis?

Many thanks!

Vincent Fontanier

Inserm U1208 (ex-U846) Stem Cell and Brain Research Institute
Team Neurobiology of Executive Functions
18 av Du Doyen Lepine
69675 Bron CEDEX, (Lyon) FRANCE

More information about the fieldtrip mailing list