ALFF,fALFF calculate manually with python3

Hi.

I’d like to calculate ALFF for each voxels for my data(.nii.gz)

The reason for doing so is that I want to apply various atlas mask.such as shen,Yeon and so on.

I tried various software like C-PAC, AFNI,Nilearn…

But I still haven’t got a clue to satisfy my demand.

In summary, I’m looking for python codes calculating ALFF for each voxel like AFNI’s 3dReHo

Any suggestion would be really appreciated.

Best,
Junyong Oh

Hi, Junyong-

I know you ask for this to be done in python3, but I will mention that AFNI has 3dRSFC for calculating RSFC parameters such as ALFF, fALFF, sigma_RSFC, etc. I has a -mask .. option to allow you to apply a mask.

Note that if you have applied censoring/scrubbing in your dataset, then you have to use a program that can handle having non-regular time points. This is an issue because ALFF is defined typically using the frequency spectrum, which is generally calculated via the Fourier Transform, which in turn assumes that the input time series have exactly uniform sampling. FMRI datasets have constant TR, but censoring/scrubbing effectively makes temporal sampling irregular meaning that you can no longer apply the FT.

So, in AFNI we have the following pair of programs that can still be used in tandem to estimate RSFC parameters in this case: 3dLombScargle and 3dAmpToRSFC. (The Lomb-Scargle transform is effectively a generalization of the Fourier Transform, applicable with non-systematically-missing data—thanks, astrophysicists!).

Further related to processing, you might be fine estimating ALFF if you have bandpassed your data to low frequency fluctuations (LFFs) in a common range of approx. 0.01-0.1 Hz. Actually, the standard deviation of your time series will closely relate to ALFF then because you should only have power in those frequencies, as long as you did simultaneous bandpassing and regressing. However, to estimate fALFF, you must not have included bandpassing in your time series analysis.

So, this is probably a longer email than you wanted, and it still isn’t providing a python3-based program as you had asked—my apologies!

-pt

2 Likes

Thank you for your kind reply ptayloy.

Im studying RSFC as u mentioned above.

My final goal is apply shen atlas(and other atlas also as well) to my ALFF data(which each voxel has its own ALFF value).

So, final data’s shape would be (1,268) if I’m right.

could you recommend any solutions for this request?

Again, Thank you for your reply

Best,
Junyong Oh

Hi, Junyong-

I think you might want to calculate ALFF in each voxel, and then take the average across the ROI? To do so,

  • You will want to have both your final, processed FMRI data and the Shen atlas in the same space and on the same grid (check/verify with 3dinfo -same_all_grid -prefix DSET_FMRI DSET_SHEN)
  • Then, depending on how you processed your FMRI data (e.g. including censoring or not), you would calculated ALFF per voxel:
    • with 3dRSFC, if no censoring was used
    • with 3dLombScarge+3dAmpToRSFC, if censoring was used.
  • Then you could used 3dROIstats to get the average ALFF value within each ROI.

–pt