Back to the main page.
Bug 3278 - Bug in ft_networkanalysis with parameter 'assortativity'
Status | CLOSED WORKSFORME |
Reported | 2017-03-31 13:18:00 +0200 |
Modified | 2019-08-10 12:40:54 +0200 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P5 normal |
Assigned to: | Ivan |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Ivan - 2017-03-31 13:18:32 +0200
Here is the code where data_connectivity comes from the ft_connectivityanalysis: ---code--- cfg = []; cfg.method = 'assortativity'; cfg.parameter = 'cohspctrm' cfg.threshold = 0.2; data_graph = ft_networkanalysis(cfg, data_connectivity); ---/code--- And here is the bug description: ---code--- Undefined function or variable 'degi'. Error in assortativity (line 45) r = (sum(degi.*degj)/K - (sum(0.5*(degi+degj))/K)^2)/(sum(0.5*(degi.^2+degj.^2))/K - (sum(0.5*(degi+degj))/K)^2); Error in ft_networkanalysis (line 203) output(k,m) = assortativity(input(:,:,k,m), 1); ---/code---
Jan-Mathijs Schoffelen - 2017-03-31 17:09:18 +0200
I downgraded the 'importance' of this bug, because I would say that the classification 'blocker' implies that nothing works anymore. Could you please try and debug a bit more yourself and provide a solution. It seems from the assortativity code that some conditional section is bypassed, which I don't understand. Flag should be either 0 or 1. If not, it's a bug in ft_networkanalysis, otherwise the problem lies in assortativity, which is not FieldTrip's responsibility, but bct's
Ivan - 2017-03-31 18:29:01 +0200
Hi, the bct function (assortativity.m) is working fine on its own, and flag (0 or 1) is definitely reaches it. I was unable to trace the issue. I have a feeling that some mistake is in the way how connectivity matrix is handled and all values there are replaced with 0 or NaN at some point.
Jan-Mathijs Schoffelen - 2017-03-31 18:45:29 +0200
x=randn(4,10); data.cohspctrm=x*x'; data.dimord='chan_chan_freq'; data.freq=1; data.label={'1';'2';'3';'4'} cfg=[]; cfg.method='assortativity'; cfg.parameter='cohspctrm'; n1=ft_networkanalysis(cfg,data);%works, i.e. does not crash; data2=data; data2.cohspctrm(2,1)=nan;data2.cohspctrm(1,2)=nan; n2=ft_networksanalysis(cfg,data2);%works, i.e. does not crash;
Robert Oostenveld - 2019-08-10 12:34:44 +0200
This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on https://github.com/fieldtrip/fieldtrip/issues.