Back to the main page.
Bug 2158 - strange behaviour of ft_math
Status | CLOSED FIXED |
Reported | 2013-05-07 15:11:00 +0200 |
Modified | 2014-01-29 13:28:38 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Eelke Spaak |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
- 2013-05-07 15:11:25 +0200
Hi guys, I think something is wrong with ft_math. It does things that I'm sure are quite wrong with elementary operations. Have a look at the toy example below... (running DCCN version of ft from /home/common from a torque interactive session) @@@BEGIN@@@ % make a couple of fake ft structures test1=[]; test1.label={'chan1';'chan2';'chan3'}; test1.freq=1:4; test1.time=1:2; test1.dimord='chan_freq_time'; test1.powspctrm=ones(length(test1.label),length(test1.freq),length(test1.time)); test1.cfg.randomfieldname='something has to go here otherwise the provenance fails'; test2=test1; test2.powspctrm=3*test1.powspctrm; %powspctrm of test1 is all 1s, test2 is all 3s test1.powspctrm test2.powspctrm %do some math on them cfg=[]; cfg.operation='add'; cfg.parameter='powspctrm'; test3=ft_math(cfg,test2,test1); %this should repeatedly add 1 and 3, producing 4s test3.powspctrm %I get 6s cfg.operation='subtract'; test4=ft_math(cfg,test2,test1); %this should subtract 1 from 3, producing 2s test4.powspctrm %I get 0s cfg.operation='add'; test5=ft_math(cfg,test1,test2); %if this doesn't produce 4s, at least maybe it'll produce the same output as test3 test5.powspctrm %nope! @@@END@@@ What's going on here? Am I using the function completely wrongly?
Eelke Spaak - 2013-05-07 15:27:11 +0200
confirmed here, definitely a bug
Eelke Spaak - 2013-05-07 15:35:31 +0200
line 48 read: varargin{i} = ft_checkdata(varargin{1}, 'datatype', type); where of course the varargin{1} should have been varargin{i}. Fixed now in rev 8108, should be available in the /home/common/ release in a few minutes.
Johanna - 2013-05-07 15:59:04 +0200
Good spot Eelke! beat me to it. # But I also found the bug in the 'add' and 'multiply' sections, that also should loop over 'i' but instead use varargin{2} I'll fix that....
Johanna - 2013-05-07 16:10:08 +0200
fixed, svn r8109. I also noticed the 'nth' subfunction does not work for 21, 22 , 23... but then can't just do rem(n,10) as it won't work for 11, 12, 13... Surely this problem has been solved before elsehwere?
Johanna - 2013-05-07 16:19:33 +0200
'nth' subfunction enhanced now. svn 8110.