Back to the main page.

Bug 2961 - ft_selectdata: unexpected behavior of ft_selectdata when selecting across time

Reported 2015-09-11 09:46:00 +0200
Modified 2018-11-12 13:52:05 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
Depends on:
See also:

Jan-Mathijs Schoffelen - 2015-09-11 09:46:41 +0200

I encountered this when working on 2959: load(fullfile(dccnpath('/home/common/matlab/fieldtrip/data/test/')),'bug2959.mat'); out=ft_selectdata(cfg, freq); according to the specified cfg.latency = [0.45 0.55], and cfg.avgovertime = 'yes', I would expect to find a selection of timeslice 0.5 (the time axis in the input data is sampled in multiples of 100 ms. However, line 923 in ft_selectdata (a call to nearest: nearest(alltimevec, cfg.latency(1), false, false) yields the inclusion of time slice 0.4 in the selection, which is clearly unexpected. On closer inspection, it turns out that it is a numerical issue. If I do: cfg.latency = [-1 1].*mean(diff(freq. time))./2+0.5; and then call ft_selectdata, it works. Should we consider adding an option in nearest so that (if the requested value is human readably half way between the values in the array) up to a certain tolerance the nearest index to the left or to the right is selected? For now, with respect to #2959 I continue, because this seems somewhat obliquely related to that issue.

Jan-Mathijs Schoffelen - 2018-11-12 13:51:56 +0100

no priority