Back to the main page.
Bug 2061 - ft_timelockanalysis: variance not computed if any period with dof=1
Status | CLOSED FIXED |
Reported | 2013-03-17 13:08:00 +0100 |
Modified | 2015-02-11 10:39:59 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Linux |
Importance: | P3 normal |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Joscha Schmiedt - 2013-03-17 13:08:38 +0100
The if clause in line 340 if (dof > 1) var = (ss - (s.^2)./dof) ./ (dof-1); else var = zeros(size(avg)); end results in zero variance across the whole trial if there is any timepoint with only 2 trials, e.g. at the end. The average is computed though, which is inconsistent behavior. A test like if any(dof(:) > 1) would make more sense in my opinion.
Robert Oostenveld - 2013-03-17 14:16:27 +0100
agreed. And if the variance is not computed, it should not be returned as zeros.
Robert Oostenveld - 2013-03-17 14:33:17 +0100
I implemented your suggestion, and made a test script. http://code.google.com/p/fieldtrip/source/detail?r=7682 thx, R
Robert Oostenveld - 2013-04-23 12:05:52 +0200
closed various bugs
Robert Oostenveld - 2013-04-23 12:06:29 +0200
closed various bugs
Joscha Schmiedt - 2014-12-16 12:39:13 +0100
The current solution doesn't fix the problem if there's more than one channel: if any(dof > 1) var = (ss - (s.^2)./dof) ./ (dof-1); else var = nan(size(avg)); end For more than one channel any(dof > 1) returns a vector, which is not handled properly by IF. It should be: any(dof(:) > 1) Example: nTrial = 50; data = []; data.label = {'chan1', 'chan2'}; data.fsample = 1000; for iTrial = 1:50 data.trial{iTrial} = rand(2, 1000); data.time{iTrial} = (0:999)/data.fsample; end data.trial{nTrial+1} = rand(2, 1001); data.time{nTrial+1} = (0:1000)/data.fsample; tlCfg = []; tlCfg.vartrllength = 2; tl = ft_timelockanalysis(tlCfg, data); all(isnan(tl.var(:)))
Robert Oostenveld - 2014-12-16 12:55:28 +0100
(In reply to Joscha Schmiedt from comment #5) dof's remain a puzzle throughout FT. Sometimes it can be a single scalar, sometimes it is a ntime vector, sometimes a nchan, etc... This implements your suggestion. mac011> svn commit ft_timelockanalysis.m Sending ft_timelockanalysis.m Transmitting file data . Committed revision 10051. mac011> svn commit test/ Sending test/test_bug2061.m Transmitting file data . Committed revision 10052.