Back to the main page.

Bug 2754 - selectdata does not avgovertime

Status CLOSED FIXED
Reported 2014-11-05 10:21:00 +0100
Modified 2015-02-11 10:40:34 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: Other
Operating System: Linux
Importance: P5 critical
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Stephen Whitmarsh - 2014-11-05 10:21:42 +0100

Hi, It seems selectdata does not actually average over time when cfg.avgovertime = 'yes' or ...'avgovertime','yes'... (old). 'Latency' and 'toilim', respectively do work. Can anyone replicate this? Cheers, Stephen


Stephen Whitmarsh - 2014-11-05 10:32:30 +0100

Created attachment 673 ERF test dataset


Stephen Whitmarsh - 2014-11-05 10:34:53 +0100

That is, for timelocked data. See attachment. The following does not result in a datastructure averaged over time: testERF_avgtime = ft_selectdata(testERF,'avgovertime','yes'); Now I am thinking, perhaps it is not compatible with FT to have an ERF with a single datapoint... Hmm... ok, my bad. I guess I'll use ft_math for this. Only suggestion is to throw an error but I'll close it.


Robert Oostenveld - 2014-11-05 10:40:28 +0100

Please use the new implementation of ft_selectdata, i.e. the one that takes a cfg as first input. That is also how it is documented in the help. The support for key-value pairs is only there for backward compatibility, and we will not maintain that in the future. The ft_selectdata bugs in general are/were addressed in bug #1021. --- Note to future self: this works just fine timelock.avg = [1 2 3]; timelock.time = [1 2 3]; timelock.label = {'chan1'} timelock.dimord = 'chan_time' cfg.avgovertime = 'yes' cfg.latency = 'all' ft_selectdata(cfg, timelock) ans = avg: 2 time: 2 label: {'chan1'} dimord: 'chan_time' cfg: [1x1 struct]


Robert Oostenveld - 2014-11-05 10:41:38 +0100

(In reply to Robert Oostenveld from comment #3) If I repeat the previous code with a single latency as time point, it also works fine, >> timelock.time = 1; >> timelock.avg = 1; >> ft_selectdata(cfg, timelock) the call to "ft_selectdata" took 0 seconds and required the additional allocation of an estimated 1 MB ans = avg: 1 time: 1 label: {'chan1'} dimord: 'chan_time' cfg: [1x1 struct]


Stephen Whitmarsh - 2014-11-05 11:05:40 +0100

I tried both the new and then the old implementation. It did not work for me on either. Could you try with the dataset I uploaded please?


Robert Oostenveld - 2014-11-05 11:35:54 +0100

(In reply to Stephen Whitmarsh from comment #5) bug confirmed. It fails due to the data being raw. The error is in cellmatmean around line 1221, where it takes the average over dim-1. This appears to be due to the dimord of the trial field being incorrect, which is interpreted as 'chan_time', but should be '{rpt}_chan_time}'.


Robert Oostenveld - 2014-11-05 11:39:16 +0100

(In reply to Robert Oostenveld from comment #6) sorry, it goes wrong on the data.time cell-array, not on the data.trial cell-array. the dimord of data.time should be {rpt}_1_time?


Robert Oostenveld - 2014-11-05 14:52:36 +0100

mac011> svn commit test/test_bug2754.m utilities/ft_selectdata.m Adding test/test_bug2754.m Sending utilities/ft_selectdata.m Transmitting file data .. Committed revision 9938.


Robert Oostenveld - 2015-02-11 10:40:34 +0100

Closed several bugs that were recently resolved. Please reopen if you are not happy with the resolution.