[FieldTrip] Different way of calculating the covariance for LCM

jan-mathijs schoffelen jan.schoffelen at donders.ru.nl
Thu Mar 24 14:01:33 CET 2011

Dear JM et al,

> see for example in version 20110222 ft_sourceanalysis from line 783
>  elseif Ntrials>1
>    % average the single-trial covariance matrices
>    Cy  = reshape(mean(data.cov,1), [Nchans Nchans]);
>    % select the average ERF
>    avg = data.avg;
>    Nrepetitions = 1;
> of course developers of fieldtrip would be the experts to comment on  
> this.

I am not sure what kind of comment you are looking for here. I think  
the previous discussion with much appreciated contributions by Yuval  
and Michael was quite conclusive.

The difference between keeptrials='yes' and keeptrials='no' is that  
the single replicates are kept in memory when keeptrials='yes' whereas  
the covariance will be averaged (across the single trial covariances)  
if you specify keeptrials='no'. The default behaviour of  
sourceanalysis is to average across single replicate covariances  
before computing the spatial filters. This is done to ensure a  
relatively robust estimate of the covariance matrix. In general,  
covariances estimated from single trials are just very noisy and don't  
lead to good quality source reconstructions. In other words, if you  
would want to have a single trial estimate of the reconstructed source  
time series, you still need to compute the spatial filters based on a  
covariance averaged across multiple trials. Once you have the spatial  
filter, you can project the single trial sensor-level data through them.

I believe this is most easily achieved by a 2-step procedure.

tlck = ft_timelockanalysis(cfg, data); (with keeptrials = 'no')

tlck2 = ft_timelockanalysis(cfg, data); (with keeptrials = 'yes')

cfg = [];
source = ft_sourceanalysis(cfg, tlck); (with keepfilters = 'yes')

cfg.grid.filter = source.avg.filter;
cfg.rawtrial = 'yes';
source = ft_sourceanalysis(cfg, tlck2);

This should (I think) give you the single trial time courses.

But perhaps I am totally missing the point and this is not the  
information you were looking for.



Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3614793

More information about the fieldtrip mailing list