Hi, I'm working with a large data set of voxel information from MRI scans of multiple subjects, and as part of the analysis I use FFT. Prior to this, the data already goes through some modifications, removing specific values deemed too low (insignificant data) and replacing it with NaN values. After checking the results I realized there is an issue with FFT and NaN values. Is there some solution or workaround that someone perhaps knows that might help resolve this issue?

 採用された回答

Star Strider
Star Strider 2020 年 7 月 25 日

2 投票

If you have R2016b or later, the fillmissing function is an option.

8 件のコメント

noam edelshtein
noam edelshtein 2020 年 7 月 26 日
Unfortunately unless I decide to replace nan with 0's or a different constant, it wont help. The nan replaced a prior existing value that was deemed insignificant, which I needed to ignore for the analysis, so replacing it or interpolating would not serve the purpose.
What I'd hoped for is something similar to nanmean, which allows the function to work without taking into consideration the nan values.
Star Strider
Star Strider 2020 年 7 月 26 日
Noiithing similar to nanmean is appropriate for the fft function, since it destroys the required regularity of the sampling points and data (with regularly-sampled data and constant sampling frequency).
It may be possible to eliminate the NaN values and still get the Fourier transform using the nufft function (R2020a and later). I have no experience with it (I have not yet used it) so my ability to help you with it is limited. It would be necessary to eliminate the corresponding points from both the signal vector and time (or other independent variable) vector.
Another option is to eliminate the NaN values and then use the resample function to resample them to a new time vector, then use fft. (This effectively interpolates, so that may not be an option for you.)
.
noam edelshtein
noam edelshtein 2020 年 7 月 27 日
Thats what I thought, but hoped to maybe be wrong. I'll look into the nufft function, it may help.
Thank you for the help, in this thread and many other answers you've given in other threads that have helped me!
Star Strider
Star Strider 2020 年 7 月 27 日
As always, my pleasure (here, and for the others as well)!
Jon
Jon 2022 年 2 月 8 日
Excellent I just ran into similar issue with NaN's. Using nufft worked perfectly for my problem. Thanks so much for making me aware of this new function, and pointing out how it could be applied in the case of having bad (NaN) data points.
Star Strider
Star Strider 2022 年 2 月 8 日
@Jon Thank you!
My pleasure!
A Vote would be appreciated!
Jon
Jon 2022 年 2 月 9 日
Done, thanks for the reminder, I had forgotten about the upvoting feature.
Star Strider
Star Strider 2022 年 2 月 9 日
Thank you!

サインインしてコメントする。

その他の回答 (1 件)

Sugar Daddy
Sugar Daddy 2020 年 7 月 25 日

0 投票

what if you remove NaNs from dataset
Suppose
X = [1 2 3 NaN 3 2 1];
X(isnan(X)) = []
X =
1 2 3 3 2 1

2 件のコメント

noam edelshtein
noam edelshtein 2020 年 7 月 25 日
That would cause a change in dimensions of the matrix, and there is more analysis to come after this stage, so I would need to know precisely where the nan values were to reinsert them in the right places following the fft analysis.
I considered replacing with 0 but I think that will cause some form of change in the results of the analysis.
Maya Eyal
Maya Eyal 2021 年 2 月 22 日
I think this solution is not good, since it destroys the pattern in the data, and the whole reason we use the fft is to find the pattern.
I'm not an expert, just another one with the same NaN problem.
Unfortunatly, I use matlab 2019 so I don't have nufft function.
I'm not sure that interpulating the missing data will give me the pattern I want to find, but it seems I have no choice.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by