Beamforming across trials not time

Marie Smith marie at PSY.GLA.AC.UK
Tue Feb 27 17:07:51 CET 2007


Hi Robert,

> The timelockanalysis function computes covariances (and also
> averages, but the averaging is more or less independent from the
> covariance computation. Timelockanalysis does the following:
>
> a- it filters the data in each trial (optional, see private/
> preproc), one of the options is also to apply a boxcar smoothing
> kernel
> b- it selects the timewindow for averaging the ERF and computing
> the single sample variance over trials
> c- it selects the timewindow for covariance computation
> d- for each trial, it selects the avg-timewindow and sums the data
> e- for each trial, it selects the cov-timewindow and computes the
> covariance within that timewindow
> f- in case of keeptrials=yes, the single trial covariance (and the
> data trials) are returned
> g- in case of keeptrials=no, the covariance matrices are averaged
> over trials
> When beaming the data in sourceanalysis, the single trial
> covariance matrices are averaged over trials. This is a bit messy
> in the documentation but also in the code (e.g. the sourceanalysis
> options keepfilters, rawtrial and singletrial interact with each
> other)

Just to be clear, the covariance is always computed for single trials
and then either averaged across trials (keeptrials = 'no') or kept
separate (keeptrials = 'yes') to be averaged in the beamforming step?
At no time is the data averaged and then the covariance computed on
this one average trial?

> Regarding your 2 -> that can be done with step "a". The smoothing
> can be done with a boxcar, and the selection of samples of interest
> is done in our step "e".

I'm not sure that this is the same thing. I am smoothing the data
across trials at each time point, where i think time lock analysis is
smoothing the data in each trial across time points.

> However, I now realise what the main difference appears to be
> between your approach and the obvious use of the existing code: it
> relates to baseline correction. Covariance in general is computed
> like this
>   a = randn(151, 1000);
>   for i=1:151
>     a(i,:) = a(i,:) - mean(a(i,:));  % ensure zero mean
>   end
>   c = a * a';     % compute covariance
>   c = c ./ 1000;  % divide by number of samples
> That means that in the current implementation, the data within each
> trial is baseline subtracted (over the whole timewindow) prior to
> computing the covariance within that trial.

So, if I were to look at only one time point across trials,
implementing things in fieldtrip would always result in a zero value
(as the mean == the data value here)?

> It is possible to specify in timelockanalysis removemean=no, but
> that does not achieve exactly the same as your implementation,
> since your implementation removes the mean OVER trials and then
> computes the covariance by multiplying the matrix with its transpose.

Yes, I agree that this is what I am doing - and i think is the "more
correct" thing to do here.

> So part of your method should already be possible with the existing
> code (although admittedly not well documented). But your different
> approach in baseline correcting is not possible with existing code.
> Please have a look at the timelockanalysis code together with the
> suggestions above and let me know whether you concur. Of course we
> could extend timelockanalysis with your approach.

Yes I concur with your comments (though please see the points above).



More information about the fieldtrip mailing list