afni_proc command for native AND standard space preprocessing

Hello AFNI gurus!
What is the best way to preprocess data such that I have slice-time corrected, aligned, motion corrected, scaled, and blurred EPIs in both the subject’s native space as well as standard space? I need to run 3dDeconvolve in native space (to extract Betas for a Representational Similarity Analysis) and standard space (to do whole-brain group-level contrasts).

Using the following afni_proc command doesn’t save the preprocessed data in native space.


afni_proc.py -subj_id $sid -script proc.$sid -scr_overwrite        \
      -blocks tshift align tlrc volreg mask blur scale regress     \
      -copy_anat $anat_ss                                          \
      -anat_has_skull no                                           \
      -anat_follower anat_w_skull anat $anat_orig                  \
      -dsets $EPI_files                                            \
      -tcat_remove_first_trs 0                                     \
      -tshift_opts_ts -tpattern alt+z2                             \
      -radial_correlate yes                                        \
      -align_opts_aea -giant_move -cost lpc+ZZ -check_flip         \
      -tlrc_base MNI152_2009_template_SSW.nii.gz                   \
      -tlrc_NL_warp                                                \
      -tlrc_NL_warped_dsets $anat_std $anat_warp_aff $anat_warp_nl \
      -volreg_align_to MIN_OUTLIER                                 \
      -volreg_align_e2a                                            \
      -volreg_tlrc_warp                                            \
      -mask_epi_anat yes                                           \
      -blur_size 6                                                 \
      -blur_in_mask yes  

But if I change the order of the block (like in the following command), it doesn’t run the tlrc block at all.


afni_proc.py -subj_id $sid -script proc.$sid -scr_overwrite        \
      -blocks tshift volreg align  blur mask scale tlrc			   \
      -copy_anat $anat_ss                                          \
      -anat_has_skull no                                           \
      -anat_follower anat_w_skull anat $anat_orig                  \
      -dsets $EPI_files                                            \
      -tcat_remove_first_trs $dummy_scans                          \
      -tshift_opts_ts -tpattern $stc_pattern                       \
      -radial_correlate yes                                        \
      -align_opts_aea -giant_move -cost lpc+ZZ -check_flip         \
      -tlrc_base MNI152_2009_template_SSW.nii.gz                   \
      -tlrc_NL_warp                                                \
      -tlrc_NL_warped_dsets $anat_std $anat_warp_aff $anat_warp_nl \
      -volreg_align_to MIN_OUTLIER                                 \
      -volreg_align_e2a                                            \
      -volreg_tlrc_warp                                            \
      -mask_epi_anat yes                                           \
      -blur_size $blur_size                                        \
      -blur_in_mask yes                                            \

Should I just run Option 1 once with, and once without the tlrc block?
Thank you,
Mrinmayi

Hi Mrinmayi,

There isn’t really a good way to do this. On top of the fact that afni_proc.py has no options make such a thing convenient, separating the warp to standard space would cause an extra blur to be applied to that data due to the extra resampling.

It probably would be best to just run this both with and without the tlrc block (and corresponding options).

  • rick

Alright, makes sense. Thanks a lot!
Mrinmayi

Hi again!
I have a (not-so) follow-up question regarding the same afni_proc command above. I added the “-html_review_style pythonic” flag to the command, but it isn’t generating any QC scripts (except for @epi_review.$subj) or the QC_$subj folder. I tried running the following command given here:


apqc_make_tcsh.py -review_style pythonic -subj_dir . \
    -uvar_json out.ss_review_uvars.json

but that gives me the error: “IOError: [Errno 2] No such file or directory: ‘out.ss_review_uvars.json’” (I’m not sure what the -uvar_json flag is looking for? The apqc_make_tcsh.py help page is ominously empty!)

Is afni_proc just not generating the QC scripts because I don’t have a regress block in there?
Thanks again!
Mrinmayi

PS: This is the afni -version_check output:
Precompiled binary linux_openmp_64: Jul 3 2019 (Version AFNI_19.2.01 ‘Claudius’)

Would you clarify your afni_proc.py command? The review vars are (currently) dependent on the regress block, since they figure many things out from that. Did you run it?

If you have, do you have the out.proc* text file, showing all of the text output from running the proc script? If so, would you mail that to me (I think you can click on my name)?

  • rick

Hi-

Something to note, in addition to Rick’s advice-- this command:


apqc_make_tcsh.py -review_style pythonic -subj_dir . \
    -uvar_json out.ss_review_uvars.json

needs to be run in the “results” directory produced by afni_proc.py. Is that where you ran it from?

-pt

… and a follow-up point: do you have Python’s “matplotlib” module installed on your computer? That should be the only extra dependency for the “pythonic” QC stuff. (This relates to your first question about the QC here: having that module should mean that including “-html_review_style pythonic” in your afni_proc.py command will produce the QC.)

–pt

Thanks for your responses, Rick and Paul!

I am running the apqc_make_tcsh.py command from the $subj.results folder that is generated by the following afni_proc command:


afni_proc.py -subj_id $sid -script proc.$sid -scr_overwrite        \
      -blocks tshift align volreg mask scale                                   \
      -copy_anat $anat_ss                                                            \
      -anat_has_skull no                                                               \
      -anat_follower anat_w_skull anat $anat_orig                       \
      -dsets $EPI_files                                                                  \
      -tcat_remove_first_trs $dummy_scans                                \
      -tshift_opts_ts -tpattern $stc_pattern                                   \
      -radial_correlate yes                                                            \
      -align_opts_aea -giant_move -cost lpc+ZZ -check_flip       \
      -volreg_align_to MIN_OUTLIER                                          \
      -volreg_align_e2a                                                                \
      -mask_epi_anat yes                                                            \
      -html_review_style pythonic


I’m not running a regress block as part of afni_proc.py, since I’m planning to do a representational similarity analysis where I need to make 1 regression model per trial in my experiment. So my plan was to do that separately after all the runs were uniformly preprocessed by afni_proc.py. That’s probably why the QC isn’t run!

A couple of follow-ups, then:
[ol]
[li] The QC stuff I saw at the AFNI bootcamp was super useful! So I’d really like to figure out a way to get it working, at least to look at alignment, motion, outliers, censored TRs etc. Is the out.ss_review_uvars.json file something that afni_proc.py generates? If so, would that mean that I won’t be able to run apqc_make_tcsh.py if I ran 3dDeconvolve separately from the afni_proc command?
[/li][li] I’m running this analysis on the campus computing cluster, and it seems that matplotlib 1.5.1 is available. But in case I run into trouble with afni finding it, can I use the -html_review_style basic? Or does that need matplotlib too?
[/li][li] Finally, will this require netpbm? I’ve been having trouble with the netpbm11 library while running @SSwarper.
[/li][/ol]

Sorry about the laundry list of questions!
Mrinmayi

Note that you could just add a regress block to this, which would project motion and such assuming a resting state analysis, which would end with the QC output.

The ‘basic’ version does not require matplotlib.

But it might require netpbm, I am not positive. Paul will know. Maybe give it a quick try to see.

  • rick

Ahhhh yes! Sorry, I should’ve thought of that option!

I’ll give it a shot.
Thanks a lot for your help!
Mrinmayi