BOLD resolution for afni_proc.py

Hello AFNI experts!

I have two basic and quick questions,
I am not used to working with human datasets and I am surprised with the processing time with afni_proc.py
I have human BOLD images at a resolution of 2.8 and afni_proc.py takes more than 5h per subject and my computer has good characteristics.
Is that normal?


afni_proc.py -subj_id imapt1s080 -script Imapt1s080/proc.imapt1s080 -scr_overwrite -out_dir imapt1s080.results -blocks despike tshift align tlrc volreg blur mask regress -dsets Rest_BOLD.nii.gz -copy_anat anatSS.imapt1s080.nii -anat_has_skull no -tcat_remove_first_trs 5 -regress_RSFC -volreg_align_to first -volreg_align_e2a -volreg_tlrc_warp -align_opts_aea -epi_strip 3dAutomask -cost lpc+zz -giant_move -check_flip -tlrc_base MNI152_2009_template_SSW.nii.gz -tlrc_NL_warp -tlrc_NL_warped_dsets anatQQ.imapt1s080.nii anatQQ.imapt1s080.aff12.1D anatQQ.imapt1s080_WARP.nii -regress_motion_per_run -regress_bandpass 0.01 0.1 -blur_size 4 -regress_est_blur_detrend yes -regress_run_clustsim no -execute

Should I decrease the resolution of the BOLD prior to afni_proc to speed up the process? Losing spatial resolution is not a big deal in my study.

Also, to calculate mALFF, the result is strongly dependent on the mask used. Is there a way with afni_proc to add this mask in -regress_RSFC?
Thank you!
Clément

Problem solved,
the program died with


3dDeconvolve -input pb05.imapt1s080.r01.scale+orig.HEAD -mask full_mask.imapt1s080+orig -ortvec motion_demean.1D mot_demean -ortvec motion_deriv.1D mot_deriv -polort 4399 -float -num_stimts 0 -fout -tout -x1D X.xmat.1D -xjpeg X.jpg -fitts fitts.imapt1s080 -errts errts.imapt1s080 -x1D_stop -bucket stats.imapt1s080
++ 3dDeconvolve extending num_stimts from 0 to 12 due to -ortvec
++ 3dDeconvolve: AFNI version=AFNI_20.2.15 (Aug 28 2020) [64-bit]
++ Authored by: B. Douglas Ward, et al.
++ Skipping check for initial transients
++ Input polort=4399; Longest run=659814.0 s; Recommended minimum polort=4399 ++ OK ++
++ Number of time points: 277 (no censoring)
 + Number of parameters:  4412 [4412 baseline ; 0 signal]
e[7m** ERROR:e[0m Regression model has too many parameters for dataset length :(
e[7m** FATAL ERROR:e[0m 3dDeconvolve dies: Insufficient data (277) for estimating 4412 parameters
** Program compile date = Aug 28 2020

It seems that the TR was in ms instate of s…
for future people that might have the same problem:


3drefit -TR 2.382 dset_func

I just have my last question left concerning mALFF,
thank you!

Clément

Hi, Clément–

Welcome to the other side of the primate tracks…

Firstly, for ease of readability, I put end of line characters in your AP command to space it vertically a bit:


afni_proc.py \
    -subj_id imapt1s080 \
    -script Imapt1s080/proc.imapt1s080 \
    -scr_overwrite \
    -out_dir imapt1s080.results \
    -blocks despike tshift align tlrc volreg blur mask regress \
    -dsets Rest_BOLD.nii.gz \
    -copy_anat anatSS.imapt1s080.nii \
    -anat_has_skull no \
    -tcat_remove_first_trs 5 \
    -regress_RSFC \
    -volreg_align_to first \
    -volreg_align_e2a \
    -volreg_tlrc_warp \
    -align_opts_aea \
         -epi_strip 3dAutomask -cost lpc+zz -giant_move -check_flip \
    -tlrc_base MNI152_2009_template_SSW.nii.gz \
    -tlrc_NL_warp \
    -tlrc_NL_warped_dsets \
        anatQQ.imapt1s080.nii \
        anatQQ.imapt1s080.aff12.1D \
        anatQQ.imapt1s080_WARP.nii \
    -regress_motion_per_run \
    -regress_bandpass 0.01 0.1 \
    -blur_size 4 \
    -regress_est_blur_detrend yes \
    -regress_run_clustsim no \
    -execute

Short answer about your run time: yes, I’m surprised it is that long.

The necessary longer answer (plus questions for you):

  1. You should not need to pre-resample your BOLD data (2.8mm isotropic is a pretty standard FMRI voxel size, certainly not “high-res”).

  2. Just to be clear about the spatial resolution and number of time points in your EPI, as well as of your anatomical, what is the output of:


3dinfo -ad3 -n4 -prefix Rest_BOLD.nii.gz anatSS.imapt1s080.nii

?

  1. Do you have multiple cores on your computer? Are you leveraging the OpenMP capabilities of the AFNI alignment programs by using multiple threads? What is the output of:

afni_check_omp

… which tells the setting of the OMP_NUM_THREADS env variable (on my laptop with 8 CPUs, it is 6, for example).

  1. mALFF should be a voxelwise value… so I don’t understand this statement:
    “Also, to calculate mALFF, the result is strongly dependent on the mask used. Is there a way with afni_proc to add this mask in -regress_RSFC?”

  2. Taking a step back: if you don’t censor your data, using “-regress_RSFC” is OK… However, in most cases with resting state analyses, you will likely want to censor your data to reduce effects of subject motion as much as possible. This is done by estimating locations of big motion through the volume-to-volume motion parameters (which are collapsed into a single number, the Euclidean norm or “enorm”) and outlier spikes; to provide censoring thresholds for each to afni_proc.py, as here:


   -regress_censor_motion 0.3                               \
   -regress_censor_outliers 0.05                            \

Once you are censoring time points, you should not use “-regress_RSFC”, which depends on having uniformly sampled (=non-censored) time series. The way to appropriate estimate RSFC parameters when you have censored data is use 3dLombScargle (yeeees, really its name) and 3dAmpToRSFC. This is a more appropriate framework in this case.

Please see this discussion thread for more about this discussion:
https://afni.nimh.nih.gov/afni/community/board/read.php?1,161671,161676

4b) Do you need to bandpass?

  1. I notice in your AP command, you use:

-volreg_align_to first \

… which would mean that the first datapoint in your FMRI time series is always used for registration, eeeeeven if motion/badness occurred there. Probably it would be preferable to select a “most appropriate” one in each case, by having AFNI determine which volume has fewest outliers; so, replace that line with:


-volreg_align_to MIN_OUTLIER                             \

  1. Please use the python HMTL review for nicer QC output. Add this option:

-html_review_style pythonic				 \

  1. Given your input EPI voxel size (if it is 2.8mm isotropic), blurring with 4mm radius will be pretty small. You might want something more in the range of 5-6 mm if you are doing voxelwise analysis later (if you are doing ROI-based analysis later, you would not want to blur spatially).

  2. For estimating a useful mask for combining results at the group level/etc., you likely would want to include this opt:


-mask_epi_anat yes                                       \

Hi, Clément–

Please see my other post about several possible things…

But how were these datasets converted from DICOMs, if the TR was stored in incorrect units? Yikes!

–pt

Thank you for your answer!

  1. It was 100% linked to the resolution, now it is more about 20min/run…

  2. 2.800003 2.799999 2.799998 80 80 42 280 Rest_BOLD.nii.gz

  3. It is 24 for me

  4. mALFF should be a voxelwise value… so I don’t understand this statement:
    “Also, to calculate mALFF, the result is strongly dependent on the mask used. Is there a way with afni_proc to add this mask in -regress_RSFC?”

If I understand correctly, mALLF is the ALFF (calculated voxelwise) divided by the average fluctuation of the brain. If you use a brain mask, it should scale differently the results, right?

  1. thank you! I was not aware of that! I will try that.

4b) It seems that bandpass improve the results in monkey and since I want to compare my results to them I think I should do it. I know that there is a lot of debates around that in humans. If you have a good paper to suggest around that matter, I will be really interested in reading it. > Just find the papers in the discussion on 3dAmpToRSFC =)

5, 6, 7, 8) thank you for this advice! I will change that!

Hi, Clément

Re. your #1: Ummmm, what was the the thing that helped with runtime? In my “#1”, I just said you should not need to resample the data… I didn’t actually suggest anything there. (Was it checking about OMP_NUM_THREADS, which I mentioned below?)

Re. your #2: OK, great, you should definitely be able to take advantage of that number of CPUs here for the application of the NL warps.

Re. your #3: Oooooh, right, yes… wow, sorry. Indeed, mALFF is scaled by the whole brain total. To be honest, I don’t know that mALFF would be the first thing I would pick for comparisons. I think I put it there because someone asked me about it, but is there any reason that is particularly meaningful to scale like that? I would have thought fALFF might be the most useful. Note that perhaps you could include the “scale” block in your afni_proc.py processing, so that the time series are scaled to have the interpretation of “local % BOLD change” by voxelwise scaling. This is typically recommended/used in task studies for benefitting comparisons and interpretation (see here: https://pubmed.ncbi.nlm.nih.gov/27729277/), but I think it could also be useful in RS-FMRI studies helpfully, too.
Note that the “-mask_epi_anat yes” option should help make a more reasonable mask. Though, if your datasets have varied coverage across your group (some not whole brain, or some missing subcortex, for example, then you might get inherent variability with mALFF, anyways).

Re. your #4b: OK, as long as you have a good reason for it. Because bandpassing really uses up a lot of degrees of freedom in the data.
Re. more about the degree of freedom usage and papers about perhaps not needing it, see this section of the AP help:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/afni_proc.py_sphx.html#resting-state-note

–pt

Hi pt,

#1 no worries, in my second message I found that the TR (for an unknown reason, this dataset comes from another lab) was detected in a millisecond instate of a second. Fixing that TR in the header did actually solve my problem.

#3 for mALFF, I am not sure why, but the reproducibility in my lemurs gave me good and meaningful results that allowed me to characterize some interesting changes while aging. Since it is difficult to believe and because mALFF is not very popular, I wanted to see if I can reproduce these results in humans. Do you think that we can interpret that as high mALFF in a voxel is ALLF that is higher than in the rest of the brain, so having more neuronal activity during the acquisition?

Thanks a lot,
It is always a pleasure speaking with you!
Clément

Hi, Clément-

Re. #1: Oh, right. If I could keep my attention span longer than 5s (or 5ms?), I would have remembered tha-- oh, look, a squirrel!

Re. #3: Hmm, that is interesting about your mALFF experience. I wonder if using “scale” during the lemur processing would have done something similar there, so that something like ALFF might have been more meaningful? I am not certain.
I don’t know that you there is necessarily a connection between high mALFF and higher neuronal activity. Since the BOLD signal is a secondary response to neuronal activity, as well as being heavily composed of other factors such as vasculature and blood flow – with a potential sprinkling of artificial stuff like subject motion, EPI distortion and scanner artifacts – I think it would be hard to assume that kind of relationship between the two things. That would require some detailed study on its own.

–pt

Hi pt,
I followed your advice,
I tested my human dataset with ‘scale’ and without and I not obtain the same results, especially for the comparison of aged versus young.
With ‘scale’, the difference of ALLF in the DMN seems to not be less important.
Since I am not sure how scale would affect the results, do you think that scaling is recommended for comparison between groups? does it remove part of the information that might be useful to calculate ALLF?
thank you very much!
Clément

Hi, Clément-

FMRI (= EPI) datasets don’t have physical units when they are plopped out of the scanner; they are relative to that scan. You could scan me today and tomorrow on the same machine, and the baseline value of BOLD signal could be very different-- this means that any comparison of something that depends on the units of BOLD can’t be done directly.

Scaling the BOLD time series produces a dataset that has a meaningful set of units: local (=per voxel) BOLD percent signal change. This is something that could reasonably be compared across people at different times (assuming no other large/significant change in the scanner settings/behavior).

When people acquire resting state data and calculate correlation coefficients, the scaling doesn’t matter; you can take 2 time series, and either multiply each one by a constant or add a constant (or both)-- it won’t affect the correlation values. Therefore, people don’t necessarily scale RS-FMRI data.

However, ALFF carries units from the original time series: it is a sum of amplitudes, and those have physical units. So, if you wanted to compare such values across subjects, I don’t see how you couldn’t not scale. Note that as a sum of amplitudes, the length of time series will in general also matter for fair comparisons. So, if the two groups you are comparing have different lengths of time series, that wouldn’t be a fair comparison. Also, you are (hopefully) censoring your data, which would effectively alter the length of your time series; however, assuming you are using the recommened 3dLombScargle+3dAmpToRSFC with your censored time series to estimate the ALFF and other such parameters, then actually the amplitudes should be reasonably scaled so that the overall spectrum has similar magnitude-- but if there is a lot of censoring, say more than 20% of time points censored, then that comparability breaks down a bit.

fALFF is a dimensionless ratio, so it should be fairly agnostic to scaling/units. Note that again, if you have a lot of censoring, your spectral estimates underlying ALFF and fALFF estimates will start getting biased.

I don’t know how often people worry about these things in applications in the literature, but they should…

Can I ask what is your typical range of censored time point fractions?

–pt

Hello pt,

Thank you for these clear explanations!
Typically, the range of censored time point fractions is around 5 on 275-time points. One subject is around 34 but it never goes up to 20%.
I am a little bit concern by the raw ALFF and fALFF images produced with this analysis, to my knowledge, high ALFF values are essentially around the DMN. However, I do not observe that here.

assuming you are using the recommended 3dLombScargle+3dAmpToRSFC with your censored time series
==> yes I do,
However, I bandpassed my BOLD images during afni_proc.py, does it affect the results to re-bandpass with 3dAmpToRSFC?
Just to be extra sure, the file from afni_proc.py to input into 3dLombScargle is: censor_subj_combined_2.1D?

Thanks a lot!