-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Describe the bug
The function connectivity matrix is calculated wrongly when the time series is odd-numbered length.
The bug occurs within the following code snippet in AnalyzeEnsemble_FUN_WU:
data = sub.getr('FUN');
fs = 1 / T;
if fmax > fmin && T > 0
NFFT = 2 * ceil(size(data, 1) / 2);
ft = fft(data, NFFT); % Fourier transform
f = fftshift(fs * abs(-NFFT / 2:NFFT / 2 - 1) / NFFT); % absolute frequency
ft(f < fmin | f > fmax, :) = 0;
data = ifft(ft, NFFT);
end
The issue arises when the input data contains odd-numbered time series, such as 83x150 (indicating 150 time series with 83 time points). In this case, the variable NFFT attempts to add zeros to the end of each time series, leading to unexpected highly correlated function connectivity matrices.
The following is an example of the wrongly calculated functional connectivity matrices due to the odd-numbered time series in certain subjects
To Reproduce
Steps to reproduce the behavior:
- Provide functional data containing odd-numbered time series.
- Execute the code and observe the constructed functional connectivity
Expected behavior
The Fourier transform operation should be executed correctly, producing accurate results regardless of the number of time points in the input data.