Back to the main page.

Bug 2743 - error when calling ft_mvaranalysis (for granger connectivity computation)

Reported 2014-10-22 11:29:00 +0200
Modified 2015-01-12 09:19:42 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
Depends on:
See also:

Stan van Pelt - 2014-10-22 11:29:50 +0200

ft_mvaranalysis throws the error below when called. There seems to be an (unclear) error in the time axes perhaps? Example dataset is attached. cfg = []; cfg.order = 5; cfg.toolbox = 'bsmart'; mdata = ft_mvaranalysis(cfg, dataBOWact); ??? Index exceeds matrix dimensions. Error in ==> ft_mvaranalysis at 326 tmpcfg.toilim = [timeaxis(sample-floor(tfwin/2)) timeaxis(sample+ceil(tfwin/2)-1)];

Jan-Mathijs Schoffelen - 2014-11-13 09:46:49 +0100

Stan, if this is still an issue for you, please upload some testdata somewhere (e.g. /home/common) and let us know it's there before it's erased again. If it's not an issue anymore, please close

Stan van Pelt - 2014-11-13 10:02:50 +0100

example data is now on temporary

Jan-Mathijs Schoffelen - 2014-11-13 10:07:39 +0100


Jan-Mathijs Schoffelen - 2014-11-13 10:11:43 +0100

OK, I copied the data over the /home/common/matlab/fieldtrip/data/test/bug_2743.mat

Jan-Mathijs Schoffelen - 2014-11-13 10:41:29 +0100

bash-4.1$ svn diff ft_mvaranalysis.m Index: ft_mvaranalysis.m =================================================================== --- ft_mvaranalysis.m (revision 9961) +++ ft_mvaranalysis.m (working copy) @@ -323,7 +323,7 @@ cfg.toi(j) = timeaxis(sample); tmpcfg = []; - tmpcfg.toilim = [timeaxis(sample-floor(tfwin/2)) timeaxis(sample+ceil(tfwin/2)-1)]; + tmpcfg.toilim = [timeaxis(sample-ceil(tfwin/2)) timeaxis(sample+floor(tfwin/2)-1)]; = 'no'; tmpcfg.minlength= 'maxperlen'; tmpdata = ft_redefinetrial(tmpcfg, data); bash-4.1$ svn add test/test_bug2743.m A test/test_bug2743.m bash-4.1$ svn commit -m "bugfix - solved rounding issue with odd-samplenumber tfwins" ft_mvaranalysis.m test/test_bug2743.m Sending ft_mvaranalysis.m Adding test/test_bug2743.m Transmitting file data .. Committed revision 9962.

Stan van Pelt - 2014-11-13 10:46:52 +0100

Great, looks perfect. Is not immediately implemented, or is it?

Jan-Mathijs Schoffelen - 2014-11-13 10:58:24 +0100

should be available soon on /home/common (in approx.20min)

Tyler - 2014-11-18 08:08:28 +0100

Im having the same issue, however it was after the bug fix. tmpcfg.toilim = [timeaxis(sample-ceil(tfwin/2)) timeaxis(sample+floor(tfwin/2)-1)]; When I run: sample-ceil(tfwin/2), I get 0, as both sample and ceil(tfwin/2) equal 1501 So when you index into timeaxis, it crashes with the same error.

Jan-Mathijs Schoffelen - 2014-11-18 09:10:08 +0100

Tyler, The numbers you mention don't have any meaning for us, unless we have some specific data to test. Did it work for you on the exact same data before the fix? What's the number of elements in the timeaxis, and what is the value for tfwin?

Tyler - 2014-11-18 14:48:45 +0100

Hello! Sorry about the out-of-context numbers, they were meant to just be an example. Before the bug fix, I would get an error on the second part of the code. Whole line of code: tmpcfg.toilim = [timeaxis(sample-ceil(tfwin/2)) timeaxis(sample+floor(tfwin/2)-1)]; Previously would crash on: timeaxis(sample+floor(tfwin/2)-1) It would give the same error, however it would be trying to get an index greater than what timeaxis has in it. numel( timeaxis) = 3002 tfwin = 3001 sample = 1501 Are you wanting my data to play with? It seems to work if the line is: tmpcfg.toilim = [timeaxis(sample-floor(tfwin/2)) timeaxis(sample+floor(tfwin/2)-1)];