errors running afni_proc.py

Dear AFNI experts,

I developed an afni_proc.py script for my project and tested it on my first subject, but am receiving errors. I am also receiving the same errors when testing the script on another subject. Please note, to get the different files needed as input into my afni_proc.py script, I first completed the following: I used dcm2niix to convert both the structural file and the functional file of my subject from .dcm to .nii.gz format. Then, I ran @Align_Centers to align the structural file’s center to the center of MNI152_2009_template_SSW.nii.gz, and next, I ran @Align_Centers to align the functional file’s center to the center of MNI152_2009_template_SSW.nii.gz. Finally, I ran @SSWarper, with the input being the aligned/“shifted” structural file (which was the output from running @Align_Centers on the structural file), and the base being MNI152_2009_template_SSW.nii.gz. All the files used as input into my afni_proc.py script do exist in the paths indicated by my afni_proc.py script.

Could you please see the below script and error outputs and suggest how I might be able to get afni_proc.py to work?

My afni_proc.py script:
afni_proc.py
-subj_id AES101_Exercise
-copy_anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatSS.AES101.nii
-anat_has_skull no
-anat_follower anat_w_skull anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXanat_shft.nii.gz
-dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz
-blocks tshift align tlrc volreg blur mask scale regress
-radial_correlate_blocks tcat volreg
-tcat_remove_first_trs 2
-align_opts_aea -cost lpc+ZZ -giant_move -check_flip
-tlrc_base MNI152_2009_template_SSW.nii.gz
-tlrc_NL_warp
-tlrc_NL_warped_dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.nii
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.aff12.1D
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101_WARP.nii
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a
-volreg_tlrc_warp
-mask_epi_anat yes
-blur_size 4.0
-regress_stim_times Volumes/E4BHData/stimtimes/neutral.1D Volumes/E4BHData/stimtimes/pleasant.1D Volumes/E4BHData/stimtimes/unpleasant.1D
-regress_stim_labels neutral pleasant unpleasant
-regress_basis ‘BLOCK(20,1)’
-regress_opts_3dD
-jobs 4
-gltsym ‘SYM: pleasant -neutral’
-glt_label 1 P-N \
-gltsym ‘SYM: unpleasant -neutral’ \
-glt_label 2 U-N \
-regress_motion_per_run
-regress_censor_motion 0.3
-regress_censor_outliers 0.05
-regress_3dD_stop
-regress_reml_exec
-regress_compute_fitts
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts
-regress_run_clustsim no
-html_review_style pythonic
-execute

The output of my afni_proc.py script with errors:
[Yashs-Air:~] yashkommula% afni_proc.py
-subj_id AES101_Exercise
-copy_anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatSS.AES101.nii
-anat_has_skull no
-anat_follower anat_w_skull anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXanat_shft.nii.gz
-dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz
-blocks tshift align tlrc volreg blur mask scale regress
-radial_correlate_blocks tcat volreg
-tcat_remove_first_trs 2
-align_opts_aea -cost lpc+ZZ -giant_move -check_flip
-tlrc_base MNI152_2009_template_SSW.nii.gz
-tlrc_NL_warp
-tlrc_NL_warped_dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.nii
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.aff12.1D
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101_WARP.nii
-volreg_align_to MIN_OUTLIER
-volreg_align_e2a
-volreg_tlrc_warp
-mask_epi_anat yes
? -subj_id AES101_Exercise
? -copy_anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatSS.AES101.nii
? -anat_has_skull no
? -anat_follower anat_w_skull anat Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXanat_shft.nii.gz
? -dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz
? -blocks tshift align tlrc volreg blur mask scale regress
? -radial_correlate_blocks tcat volreg
? -tcat_remove_first_trs 2
? -align_opts_aea -cost lpc+ZZ -giant_move -check_flip
? -tlrc_base MNI152_2009_template_SSW.nii.gz
? -tlrc_NL_warp
? -tlrc_NL_warped_dsets Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.nii
? Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.aff12.1D
? Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101_WARP.nii
? -volreg_align_to MIN_OUTLIER
? -volreg_align_e2a
? -volreg_tlrc_warp
? -mask_epi_anat yes
? -blur_size 4.0
-regress_stim_times Volumes/E4BHData/stimtimes/neutral.1D Volumes/E4BHData/stimtimes/pleasant.1D Volumes/E4BHData/stimtimes/unpleasant.1D
-regress_stim_labels neutral pleasant unpleasant
-regress_basis ‘BLOCK(20,1)’
-regress_opts_3dD
-jobs 4
-gltsym ‘SYM: pleasant -neutral’
-glt_label 1 P-N \
-gltsym ‘SYM: unpleasant -neutral’ \
-glt_label 2 U-N \
-regress_motion_per_run
-regress_censor_motion 0.3
-regress_censor_outliers 0.05
-regress_3dD_stop
-regress_reml_exec
-regress_compute_fitts
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts
-regress_run_clustsim no
-html_review_style pythonic
-execute? -regress_stim_times Volumes/E4BHData/stimtimes/neutral.1D Volumes/E4BHData/stimtimes/pleasant.1D Volumes/E4BHData/stimtimes/unpleasant.1D
? -regress_stim_labels neutral pleasant unpleasant
? -regress_basis ‘BLOCK(20,1)’
? -regress_opts_3dD
? -jobs 4
? -gltsym ‘SYM: pleasant -neutral’
? -glt_label 1 P-N \
** missing run 1 dataset: Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz

** failed command (create_blocks):

afni_proc.py -subj_id AES101_Exercise -copy_anat
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatSS.AES101.nii
-anat_has_skull no -anat_follower anat_w_skull anat
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXanat_shft.nii.gz
-dsets
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz
-blocks tshift align tlrc volreg blur mask scale regress
-radial_correlate_blocks tcat volreg -tcat_remove_first_trs 2
-align_opts_aea -cost lpc+ZZ -giant_move -check_flip -tlrc_base
MNI152_2009_template_SSW.nii.gz -tlrc_NL_warp -tlrc_NL_warped_dsets
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.nii
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101.aff12.1D
Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/anatQQ.AES101_WARP.nii
-volreg_align_to MIN_OUTLIER -volreg_align_e2a -volreg_tlrc_warp
-mask_epi_anat yes -blur_size 4.0 -regress_stim_times
Volumes/E4BHData/stimtimes/neutral.1D
Volumes/E4BHData/stimtimes/pleasant.1D
Volumes/E4BHData/stimtimes/unpleasant.1D -regress_stim_labels neutral
pleasant unpleasant -regress_basis ‘BLOCK(20,1)’ -regress_opts_3dD
-jobs 4 -gltsym ‘SYM: pleasant -neutral’ -glt_label 1 P-N ’ ’

[Yashs-Air:~] yashkommula% -gltsym ‘SYM: unpleasant -neutral’ \
-gltsym: Command not found.
[Yashs-Air:~] yashkommula% -glt_label 2 U-N \
-glt_label: Command not found.
[Yashs-Air:~] yashkommula% -regress_motion_per_run
? -regress_censor_motion 0.3
? -regress_censor_outliers 0.05
? -regress_3dD_stop
? -regress_reml_exec
? -regress_compute_fitts
? -regress_make_ideal_sum sum_ideal.1D
? -regress_est_blur_epits
? -regress_est_blur_errts
? -regress_run_clustsim no
? -html_review_style pythonic
? -execute
-regress_motion_per_run: Command not found.

Thank you,
Yash

Hi, Yash-

I suspect that there might be some spaces to the right of the continuation-of-line character "" in one or more lines. If that happens, the shell won’t keep on reading the next line as part of the current command, and then it will try to start reading the next line instead as a whole new command. That is why I think the following "Command not found"s occurred:


[Yashs-Air:~] yashkommula% -gltsym 'SYM: unpleasant -neutral' \
-gltsym: Command not found.
[Yashs-Air:~] yashkommula% -glt_label 2 U-N \
-glt_label: Command not found.
[Yashs-Air:~] yashkommula% -regress_motion_per_run \
? -regress_censor_motion 0.3 \
? -regress_censor_outliers 0.05 \
? -regress_3dD_stop \
? -regress_reml_exec \
? -regress_compute_fitts \
? -regress_make_ideal_sum sum_ideal.1D \
? -regress_est_blur_epits \
? -regress_est_blur_errts \
? -regress_run_clustsim no \
? -html_review_style pythonic \
? -execute
-regress_motion_per_run: Command not found.

You also have missing file errors:


** missing run 1 dataset: Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz

A lot of your input file paths are started with “Users” or “Volumes”—that looks like you are using a Mac, then. Typically, those are top level directories on a Mac, and those should each start with the following character to denote the start of an absolute path: “/”. So, the above file should actually be input as:


/Users/yashkommula/Desktop/E4BH/AES101/EXERCISE/AES101EXpicviewing_shft.nii.gz

Try fixing those things, and see how it goes. Note that while you are trying to sort these issues out, you might want to leave out the “-execute” option from your afni_proc.py script—At the moment, the scripts is failing, but then some things are still trying to run. Once these issues are sorted, you could stick that “-execute” back in.

On a more “style” note: usually “/Users/” starts a path on your OS, and “/Volume/” starts one on an externally attached hard drive. You might want to have all your data on your OS together, so if you want to re-run things, it is easier to find all the pieces. Or, if you accidentally bump the external drive connector, that won’t interrupt your processing. This isn’t necessary, but just something I would probably do. It would also make it easier for you to move all your data later if you decide to process on another system. And scriptily, things will have more similar paths, making typos or bugs with paths less likely.

–pt

Hi pt,

Given the below feedback from the script, would you suggest I adjust my timing files using timing_tool.py first, before running afni_proc.py? i.e. Since a TR=2.0s, would subtracting 4.0s from each stimulus time be the way to go?

** warning: removing first 2 TRs from beginning of each run
→ the stimulus timing files must reflect the removal of these TRs

And thank you for your advice with the afni_proc.py script - it appears that the script worked and generated a final QC html page!

Yash

Hi, Yash-

Glad that the first set of issues got sorted.

Re. you questions about removing TRs and the offset:

You included this option in the afni_proc.py command:


-tcat_remove_first_trs 2 

Therefore, the first 2 TRs from each time series will be removed at the very start of processing. This kind of step is often done to remove pre-steady state signal. If you don’t have pre-steady state signals in your EPIs, then you might not need to include this. However, if you do include this option, then yes, you must adjust your timing files (assuming that at present, they are counting t=0s from the start of your input EPIs).

And yes, your timing file information must be in units of seconds, so you have to adjust them by the amount of time that removing 2 TRs would be. If TR=2s, then removing 2 TRs would require you to adjust the timing values back by 4s.

And indeed, timing_tool.py should be able to help you, for example following this example (for your own time offset):


Example 2. subtract 12 seconds from each stimulus time ~2~

      For example, subtract 12 seconds to offset TRs dropped prior to
      the magnetization steady state.

         timing_tool.py -timing stimesB_01_houses.1D         \
                        -add_offset -12.0                    \
                        -write_timing stimesB1_offset12.1D

–pt

Thank you, pt, for your help!