How to obtain the FFT of a 4D image

Hi,
I have a 4D image [x,y,z,t] and I would like to plot the FFT of the signal of a region of interest.
I load my image and I store the signal of the region of interest in a vector y. I used the fft function
X=fft(y(:))
I wanted to see the spectrum plot of the signal and I tried the following but I am getting an error "Error using plot
Not enough input arguments."
plot, X
From what I've read I need to define the frequency domain but I don't know how. From the example I've seen online (https://uk.mathworks.com/help/matlab/ref/fft.html) the frequency domain has been cacluated using the sampling frequncy and length of the signal. But these two have been defined manually. In my case where my input signal comes from an image how can I define the frequency domain?

Answers (1)

plot(X)

6 Comments

It doesn't give a meanigful plot. I should define the frequency domain as well. Any idea how to define the frequncy domain of an image?
See the first example in the documentation for fft()
Are you trying to take the fft of a 1d vector extracted from the 4d image? Is this a 3d solid plus a time dimension and you want to take the Fourier along the time dimension? Is your roi irregular such as if you had selected particular voxels within a FMRI image?
It doesn't give a meanigful plot. I should define the frequency domain as well. Any idea how to define the frequncy domain of an image?
That won't change the shape of the plot, only the units of its x-axis.
@Walter Roberson I have a 4D image and a 2D mask. After applying the mask on the image I stored the signal of the region of interest which correspond to the pixels of the mask. I have plotted the signal intensity with respect to time. I want to look at the frequency domain to identify the peak frequencies in order to remove them. I applied FFT as I mentioned above X=fft(y(:)). But when I plot the plot(X) the plot doesn't make sense. If you try the first example from fft ( https://uk.mathworks.com/help/matlab/ref/fft.html ) after applying FFT i.e. Y = fft(X); if you do plot(Y) you will see that the plot doesn't make sense either. After defining the frequency domain i.e.
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
%Define the frequency domain f and plot the single-sided amplitude spectrum P1.
f = Fs*(0:(L/2))/L;
plot(f,P1)
Then the plot above makes sense. So I am trying to define the frequency domain of my data in order to plot the frequency plot but I don't know how...
Again, I don't think the creation of f has anything to do with it. Try this, and see if there's a substantial difference.
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(P1)
You have a 2D ROI. Which of the 4 planes is the ROI against? Or to phrase it another way, which dimensions are having their values constrained, and which dimensions are "all entries"?
Then, which dimension do you want the fft to be taken over?
Imagine that you had a 48 x 64 x 32 x 100 image, then if your ROI was against the first two dimensions, then each element of the ROI filters to a 1 x 1 x 32 x 100 image. If your time were the last dimension, then you would want to be doing 32 different fft's for each entry selected by the ROI. How would you then want the 32 different plots to be presented? https://www.mathworks.com/help/matlab/ref/stackedplot.html perhaps? But that would be (in this example) one group of plots for each element of your ROI, and your ROI probably has multiple entries.
X=fft(y(:))
Don't do that. You have extracted 2 dimensions for each ROI member, and your ROI adds at least one more dimension, so you are grouping 3 dimensions of data into a single vector and expecting the FFT to be meaningful.

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Asked:

DM
on 1 Mar 2022

Commented:

on 1 Mar 2022

Community Treasure Hunt

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

Start Hunting!