Open NicolasClairis opened 4 years ago
Hi.
I just re-experienced this bug when using data that was not smoothed.
In summary, what happens is that if too neighbour values of X
are the same, RFT_localmax
(line 151) does not extract them which then causes a mismatch between the elements in peaks.ind
and those extracted by RFT_clusters
(line 164) in clusters.ind
. Because of this, when the script extracts the peaks (line 220) with ismember(peaks.ind, clusters.imax)
which are then extracted in the variable is
(line 221), there is a mismatch between the number of clusters identified in the variable nc
and those present in is
which makes the script crash.
I would recommend to add a checkup before the for loop to warn the user from this bug as it took me a lot of time to figure. Something simple could be:
if nc > length(is) error('Mismatch between number of clusters and number of peaks. Please verify that you smoothed the data in X and try again.'); end
Indeed, in my case, smoothing the data solved the problem, but maybe it would be good to add a more generic way to solve this.
In some cases the amount of clusters identified by RFT_main.m (nc line 165) and the number of peaks identified (is line 221) does not match. (If no local maxima could be found in particular because there is no peak in the cluster). Then RFT_main.m and hence also RFT_GLM_contrast.m crashes. Could this case be handled somehow, just by reporting there was no peak eventhough the cluster as a full is significant for example?