# AFNI Message Board

|
 May 28, 2022 11:03AM Registered: 1 year ago Posts: 88
Paul, thanks.

Let me ask you a further question to maybe solve this and provide you with more details.

Some facts first.
- The preprocessed time-series (the .errts file) is given to 3dPeriodogram.
- 3dPeriodogram creates the power spectrum (no tapering, nfft=1024, time-series has 5xx sampling points).
- 3dTcat then cuts the output by 3dPeriodogram to my desired frequency range, i.e., it deletes all frequency bins below 0.01 and above 0.25 Hz.

How do I know which bins of the frequency-domain (the 3dPeriodogram output) I have to delete? To answer this question, I created my own ideal-frequency .txt file. To create this file, I use the following formula: 1/(nfft*TR). Hence, in my case, 1/(1024*2) = 0.00048828125.

Now, I add this number (0.00048828125) up in a .txt file starting with row 1, where each next row corresponds to this number times 2, times 3, times 4... until my Nyquist frequency is reached. Since AFNI starts counting with 0 (instead of with 1, like many programming languages) I can count the number of rows that correspond to my desired frequency range. This range is given as input for 3dTcat, so that 3dTcat can cut out only the desired frequency range of the power spectrum in AFNI.

Would you agree that nothing is wrong with this approach so far?

In Python I likewise cut the range, but I start with 21 instead of 20, since Python included zero (0) as the first value. This is what you already stated, and one can easily check the frequency range created by sp.Periodogram() by simply printing the results/computations via "print(....)". One then sees that it really starts with 0.

Therefore, the required frequency range is [21:512] for the sps.periodogram() result (instead of [20:511] as in AFNI).
It would look like this:

Frequency, Power = sp.signal.periodogram(Data, fs=0.5, window=None, nfft=1024, detrend="linear", scaling="density")

Frequency = Frequency[21:512]
Power = Power[21:512]

The images below show you the results for one subject, one image with 3dPeriodogram, the second image with sp.signal.periodogram. How are such differences possible? Am I doing a mistake somewhere?

Edited 2 time(s). Last edit at 05/28/2022 11:31AM by Philipp.

Subject Author Posted

#### 3dPeriodogram and 1dFFT - How exactly is the power computed?

Philipp May 27, 2022 10:36AM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

ptaylor May 27, 2022 03:28PM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

Philipp May 27, 2022 03:58PM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

ptaylor May 27, 2022 08:52PM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

Philipp May 28, 2022 03:36AM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

ptaylor May 28, 2022 07:11AM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

Philipp May 28, 2022 11:03AM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

ptaylor May 31, 2022 05:41PM

#### Re: 3dPeriodogram and 1dFFT - How exactly is the power computed?

Philipp June 01, 2022 12:24AM

Sorry, only registered users may post in this forum.