Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Function Connectivity Matrix Calculation with Odd-Numbered Time Series #1706

Open
c-yuwei opened this issue Apr 29, 2024 · 0 comments
Labels
bug Something isn't working and need to be fixed right away enhancement New feature or request

Comments

@c-yuwei
Copy link
Collaborator

c-yuwei commented Apr 29, 2024

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

image

To Reproduce
Steps to reproduce the behavior:

  1. Provide functional data containing odd-numbered time series.
  2. 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.

@c-yuwei c-yuwei added bug Something isn't working and need to be fixed right away enhancement New feature or request labels Apr 29, 2024
@c-yuwei c-yuwei changed the title Incorrect function connectivity matrix due to odd-numbered time series length Incorrectly calculated function connectivity matrix due to odd-numbered time series length Apr 29, 2024
@c-yuwei c-yuwei changed the title Incorrectly calculated function connectivity matrix due to odd-numbered time series length Incorrect Function Connectivity Matrix Calculation with Odd-Numbered Time Series Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working and need to be fixed right away enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant