Back to the main page.

Bug 3355 - ft_timelockanalysis redfines begsampl and endsampl

Status UNCONFIRMED
Reported 2017-09-25 08:41:00 +0200
Modified 2017-11-09 17:15:12 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to:
URL:
Tags:
Depends on:
Blocks:
See also:

Tyler - 2017-09-25 08:41:25 +0200

Dear fieldtrip, I am getting the following error: Index exceeds matrix dimensions. Error in ft_timelockanalysis (line 280) s (:,windowsel) = s (:,windowsel) + dat; % compute the sum The error seems to occur because windowsel is 1x70942, whereas s is 124x70941. This may be because when s is defined, the begsampl and endsampl variables (which are used to calculate maxwin then s) are being calculated based off of abstimvec (line 223 and 224). Whereas on line 266 and line 267, begsampl and ensampl are calculated again (to calculate numsamples, dat, and windowsel) but this time it uses data.time. If you comment out line 266 and line 267, it seems to fix the issue. The output data is 124x70941. The question is that if you comment these lines of code, you would also need to comment out line 288 and 289 when calculating the covariance. I apologise if I am completely off the mark and theres a simpler solution. Regards, Tyler


Tyler - 2017-09-25 09:36:39 +0200

Sorry, my suggested correction did not take multiple trials into consideration. It should be noted that my trials are of a varied length.


Tyler - 2017-09-25 10:38:42 +0200

I loaded up data that has 40 trials. At line 224: endsampl = nearest(abstimvec, latency(2)); I worked out the problem was that the 'nearest' value to latency(2) is both abstimvec( end) and abstimvec( end-1), so it choses abstimvec( end-1). The resulting data are then smaller than it should be. A dirty hack is: At line 224: endsampl = begsampl+size(abstimvec, 2)-1;


Jan-Mathijs Schoffelen - 2017-11-09 17:15:12 +0100

It is not clear whether this is a very specific case where it goes wrong, or whether the suggested solution is a general one.