Index exceeds matrix dimensions error during sourceanalysis

Inge Westmijse I.Westmijse at NICI.RU.NL
Wed Apr 18 16:16:18 CEST 2007

Hi Robert (and everyone else)

You solution unfortunately did not work. I have looked into the problem in
more detail and it seems the problem lies in a miscommunication between
timelockanalysis and sourceanalysis. I have created a dataset consisting of
one trial, based on two markers (Start and Stop). As far as I can see,
Timelockanalysis creates a covariance matrix with the dimensions:
[1,151,151]. I could not see any squeezing happening before the cov becomes
part of the results of timelockanalysis. Then these results are used in
sourceanalysis, but this code expects for nTrials = 1, a covariance matrix
in the shape of [151,151]. So, when he tries to read data.cov(2,1) it's

Do I see this correctly and if so how can it be solved? Of course,
otherwise, what is the problem then?

Best, Inge

-----Original Message-----
From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf
Of Robert Oostenveld
Sent: woensdag 11 april 2007 21:20
Subject: Re: [FIELDTRIP] Index exceeds matrix dimensions error during

On 11 Apr 2007, at 10:09, Inge Westmijse wrote:

> % Source analysis with this broadband data
> cfg = [];
> cfg.method = 'lcmv';
> cfg.vol = ft_headshape;
> cfg.grid = Grid;
> cfg.rawtrial = 'no';
> cfg.keepfilter = 'yes';
> SourceBP = sourceanalysis(cfg,TLDataBandPassed);
> Everything goes fine until this last line, then I get the following
> error:
> ??? Index exceeds matrix dimensions.
> Error in ==> sourceanalysis at 944
>       data.cov = data.cov(seldata,seldata);
> Error in ==> SAMimitation_v110407 at 64
> SourceBP = sourceanalysis(cfg,TLDataBandPassed);
> I hope someone can help me, thanks in advance! Inge Westmijse

Hi Inge

There is a problem with selecting the data belonging to the desired
channels in the covariance matrix. Your timelock data contains only
151 MEG channels, and I suspect that you try to beam using both the
151 regular MEG channels but also the 23 or so reference MEG
channels. You should make sure that you select exactly the same
channels when preparing the leadfield, and when computing the LCMV
filter that you want to use in the subsequent broad-band beaming.
Please add"MEG' to each of the prepare_leadfield and
sourceanalysis steps.


More information about the fieldtrip mailing list