afni_proc script help with contrasts

Hello,

I’m fairly new to imaging analysis and I am trying to develop a new proc script from this one I was given. Right now, this script has 6 contrasts for a reward task, 2 of which are:

wins($1 and $5) vs. no wins ($0)
losses ($1 and $5) vs no losses ($0)

I’d like to separate out each of the magnitudes so there are:
wins ($1) vs no wins
wins ($5) vs no wins
Losses ($1) vs no losses
Losses ($5) vs no losses

What should be changed/added here?

    -regress_stim_times                                                   \
        $stim_dir/loss_0_ant.txt                                          \
        $stim_dir/loss_ant.txt                                            \
        $stim_dir/win_0_ant.txt                                           \
        $stim_dir/win_ant.txt                                             \
        $stim_dir/fix.txt                                                 \
    $stim_dir/win_fb_hit.txt					      \
    $stim_dir/win_fb_nhit.txt                                         \
    $stim_dir/loss_fb_hit.txt                                         \
    $stim_dir/loss_fb_nhit.txt                                        \
    -regress_stim_labels                                                  \
        L0ANT                                                             \
        LANT                                                              \
        W0ANT                                                             \
        WANT                                                              \
        FIX                                                               \
    WFB_HIT                                                           \
    WFB_NHIT                                                          \
    LFB_HIT                                                           \
    LFB_NHIT                                                          \
    -regress_basis_multi                                                  \
        'GAM'                                                             \
        'GAM'                                                             \
        'GAM'                                                             \
        'GAM'                                                             \
        'GAM'                                                             \
    'GAM'                                                             \
    'GAM'                                                             \
        'GAM'                                                             \
    'GAM'                                                             \
    -regress_stim_types                                                   \
        times                                                             \
        times                                                             \
        times                                                             \
        times                                                             \
        times                                                             \
        times                                                             \
        times                                                             \
    times                                                             \
    times                                                             \
    -regress_censor_motion 0.3                                            \
    -regress_apply_mot_types demean deriv                                 \
    -regress_motion_per_run                                               \
    [b]-regress_opts_3dD                                                     \
        -num_glt 6                                                        \
        -gltsym 'SYM: 1.0*WANT -1.0*W0ANT' -glt_label 1 ANT_WIN_VS_NOWIN  \
        -gltsym 'SYM: 1.0*LANT -1.0*L0ANT' -glt_label 2 ANT_LOSS_VS_NOLOSS\
    -gltsym 'SYM: 1.0*WANT -1.0*LANT'  -glt_label 3 ANT_WIN_VS_LOSS   \
    -gltsym 'SYM: 0.5*WANT 0.5*LANT -0.5*W0ANT -0.5*L0ANT' -glt_label 4 ANT_W15L15_VS_W0L0  \
    -gltsym 'SYM: WFB_HIT -WFB_NHIT' -glt_label 5 WINHIT_VS_MISS      \
    -gltsym 'SYM: LFB_HIT -LFB_NHIT' -glt_label 6 LOSSHIT_VS_MISS     \[/b]
-regress_anaticor_fast                                                \
-regress_reml_exec                                                    \
    -regress_make_ideal_sum sum_ideal.1D                                  \
    -regress_est_blur_epits                                               \
    -regress_est_blur_errts                                               \
    -regress_run_clustsim no

Hello,

It looks like 5 of the 6 extra symbolic contrasts (SYM) are simple pairs as you describe, with only contrast 4 being a difference in means.
But to be sure, would you please specify the exact labels that correspond to wins($1) and wins($5), and similarly for loss?
It is hard to tell with any degree of certainty.

Thanks,

  • rick

Srry I should have mentioned in the original post that ANT_WIN_VS_NOWIN and ANT_LOSS_VS_NOLOSS correspond to Win ($1 and $5) vs No Win ($0) and Loss ($1 and $5) vs No Loss ($0), respectively. Each magnitude separated is not listed here. I’d have to include those to the script. In fact, I tried that using the following script, and did not get the same output. Thoughts on how to fix this? Thanks.

run afni_proc.py to create a single subject processing script

afni_proc.py -subj_id $subj
-script proc.$subj -scr_overwrite
-blocks despike tshift align tlrc volreg blur mask scale regress
-copy_anat $anat_dir/anatSS.${subj}.nii
-anat_has_skull no
-tcat_remove_first_trs 0
-tshift_opts_ts -tpattern seqplus
-dsets
$epi_dir/${subj}.MID.epi+orig.
-volreg_align_to MIN_OUTLIER
-tlrc_base $top_dir/nlWarp/MNI152_2009_template_SSW.nii.gz
-volreg_align_e2a
-volreg_tlrc_warp
-tlrc_NL_warp
-tlrc_NL_warped_dsets
$anat_dir/anatQQ.${subj}.nii
$anat_dir/anatQQ.${subj}.aff12.1D
$anat_dir/anatQQ.${subj}_WARP.nii
-blur_size 5.0
-mask_epi_anat yes
-regress_stim_times
$stim_dir/loss_0_ant.txt
$stim_dir/loss_1_ant.txt
$stim_dir/loss_5_ant.txt
$stim_dir/loss_ant.txt
$stim_dir/win_0_ant.txt
$stim_dir/win_1_ant.txt
$stim_dir/win_5_ant.txt
$stim_dir/win_ant.txt
$stim_dir/fix.txt
$stim_dir/win_fb_hit.txt
$stim_dir/win_fb_nhit.txt
$stim_dir/loss_fb_hit.txt
$stim_dir/loss_fb_nhit.txt
-regress_stim_labels
L0ANT
L1ANT
L5ANT
LANT
W0ANT
W1ANT
W5ANT
WANT
FIX
WFB_HIT
WFB_NHIT
LFB_HIT
LFB_NHIT
-regress_basis_multi
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
‘GAM’
-regress_stim_types
times
times
times
times
times
times
times
times
times
times
times
times
times
-regress_censor_motion 0.3
-regress_apply_mot_types demean deriv
-regress_motion_per_run
-regress_opts_3dD
-num_glt 10
-gltsym ‘SYM: 1.0WANT -1.0W0ANT’ -glt_label 1 ANT_WIN_VS_NOWIN
-gltsym ‘SYM: 1.0LANT -1.0L0ANT’ -glt_label 2 ANT_LOSS_VS_NOLOSS
-gltsym ‘SYM: 1.0WANT -1.0LANT’ -glt_label 3 ANT_WIN_VS_LOSS
-gltsym ‘SYM: 0.5WANT 0.5LANT -0.5W0ANT -0.5L0ANT’ -glt_label 4 ANT_W15L15_VS_W0L0
-gltsym ‘SYM: WFB_HIT -WFB_NHIT’ -glt_label 5 WINHIT_VS_MISS
-gltsym ‘SYM: LFB_HIT -LFB_NHIT’ -glt_label 6 LOSSHIT_VS_MISS
-gltsym ‘SYM: 1.0W1ANT -1.0W0ANT’ -glt_label 7 ANT_WIN1_VS_NOWIN
-gltsym ‘SYM: 1.0W5ANT -1.0W0ANT’ -glt_label 8 ANT_WIN5_VS_NOWIN
-gltsym ‘SYM: 1.0L1ANT -1.0L0ANT’ -glt_label 9 ANT_LOSS1_VS_NOLOSS
-gltsym ‘SYM: 1.0L5ANT -1.0L0ANT’ -glt_label 10 ANT_LOSS5_VS_NOLOSS
-regress_anaticor_fast
-regress_reml_exec
-regress_make_ideal_sum sum_ideal.1D
-regress_est_blur_epits
-regress_est_blur_errts
-regress_run_clustsim no

Hi-

I would just like to reformat the afni_proc.py command a bit to help for readability (and ease for adding/editing options). This might help viewing a bit:


afni_proc.py                                                                 \
    -subj_id                  $subj                                          \
    -script                   proc.$subj                                     \
    -scr_overwrite                                                           \
    -blocks                   despike tshift align tlrc volreg blur mask     \
                              scale regress                                  \
    -copy_anat                $anat_dir/anatSS.${subj}.nii                   \
    -anat_has_skull           no                                             \
    -tcat_remove_first_trs    0                                              \
    -tshift_opts_ts           -tpattern seqplus                              \
    -dsets                    $epi_dir/${subj}.MID.epi+orig.                 \
    -volreg_align_to          MIN_OUTLIER                                    \
    -tlrc_base                $top_dir/nlWarp/MNI152_2009_template_SSW.nii.gz \
    -volreg_align_e2a                                                        \
    -volreg_tlrc_warp                                                        \
    -tlrc_NL_warp                                                            \
    -tlrc_NL_warped_dsets     $anat_dir/anatQQ.${subj}.nii                   \
                              $anat_dir/anatQQ.${subj}.aff12.1D              \
                              $anat_dir/anatQQ.${subj}_WARP.nii              \
    -blur_size                5.0                                            \
    -mask_epi_anat            yes                                            \
    -regress_stim_times       $stim_dir/loss_0_ant.txt                       \
                              $stim_dir/loss_1_ant.txt                       \
                              $stim_dir/loss_5_ant.txt                       \
                              $stim_dir/loss_ant.txt $stim_dir/win_0_ant.txt \
                              $stim_dir/win_1_ant.txt                        \
                              $stim_dir/win_5_ant.txt $stim_dir/win_ant.txt  \
                              $stim_dir/fix.txt $stim_dir/win_fb_hit.txt     \
                              $stim_dir/win_fb_nhit.txt                      \
                              $stim_dir/loss_fb_hit.txt                      \
                              $stim_dir/loss_fb_nhit.txt                     \
    -regress_stim_labels      L0ANT L1ANT L5ANT LANT W0ANT W1ANT W5ANT WANT  \
                              FIX WFB_HIT WFB_NHIT LFB_HIT LFB_NHIT          \
    -regress_basis_multi      'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM'      \
                              'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM'            \
    -regress_stim_types       times times times times times times times      \
                              times times times times times times            \
    -regress_censor_motion    0.3                                            \
    -regress_apply_mot_types  demean deriv                                   \
    -regress_motion_per_run                                                  \
    -regress_opts_3dD         -num_glt 10                                    \
                              -gltsym 'SYM: 1.0*WANT -1.0*W0ANT'             \
                              -glt_label 1 ANT_WIN_VS_NOWIN                  \
                              -gltsym 'SYM: 1.0*LANT -1.0*L0ANT'             \
                              -glt_label 2 ANT_LOSS_VS_NOLOSS-gltsym         \
                              'SYM: 1.0*WANT -1.0*LANT'                      \
                              -glt_label 3 ANT_WIN_VS_LOSS                   \
                              -gltsym                                        \
                              'SYM: 0.5*WANT 0.5*LANT -0.5*W0ANT -0.5*L0ANT' \
                              -glt_label 4 ANT_W15L15_VS_W0L0                \
                              -gltsym 'SYM: WFB_HIT -WFB_NHIT'               \
                              -glt_label 5 WINHIT_VS_MISS                    \
                              -gltsym 'SYM: LFB_HIT -LFB_NHIT'               \
                              -glt_label 6 LOSSHIT_VS_MISS                   \
                              -gltsym 'SYM: 1.0*W1ANT -1.0*W0ANT'            \
                              -glt_label 7 ANT_WIN1_VS_NOWIN                 \
                              -gltsym 'SYM: 1.0*W5ANT -1.0*W0ANT'            \
                              -glt_label 8 ANT_WIN5_VS_NOWIN                 \
                              -gltsym 'SYM: 1.0*L1ANT -1.0*L0ANT'            \
                              -glt_label 9 ANT_LOSS1_VS_NOLOSS               \
                              -gltsym 'SYM: 1.0*L5ANT -1.0*L0ANT'            \
                              -glt_label 10 ANT_LOSS5_VS_NOLOSS              \
    -regress_anaticor_fast                                                   \
    -regress_reml_exec                                                       \
    -regress_make_ideal_sum   sum_ideal.1D                                   \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts                                                  \
    -regress_run_clustsim     no                                             

With that being done, I might suggest:

  • reordering slightly so all sub-options are grouped a bit (for ease of reading)
  • adding some “-align_* …” options, to help EPI-anatomical alignment and QC

-align_opts_aea           -cost lpc+ZZ                                   \
                              -giant_move                                    \
                              -check_flip                                    \

  • add in some more options for QC viewing, including TSNR estimation after volreg and the radcor block:

-volreg_compute_tsnr      yes                                            \
   -radial_correlate_blocks  tcat volreg                                    \

  • add in Python QC HTML creation (which is now the default, but I am not sure what version of AFNI you have):
    -html_review_style pythonic
    … after which, this is the command:

afni_proc.py                                                                 \
    -subj_id                  $subj                                          \
    -script                   proc.$subj                                     \
    -scr_overwrite                                                           \
    -blocks                   despike tshift align tlrc volreg blur mask     \
                              scale regress                                  \
    -copy_anat                $anat_dir/anatSS.${subj}.nii                   \
    -anat_has_skull           no                                             \
    -dsets                    $epi_dir/${subj}.MID.epi+orig.                 \
    -tcat_remove_first_trs    0                                              \
    -tshift_opts_ts           -tpattern seqplus                              \
    -radial_correlate_blocks  tcat volreg                                    \
    -align_opts_aea           -cost lpc+ZZ                                   \
                              -giant_move                                    \
                              -check_flip                                    \
    -volreg_align_to          MIN_OUTLIER                                    \
    -volreg_align_e2a                                                        \
    -volreg_tlrc_warp                                                        \
    -volreg_compute_tsnr      yes                                            \
    -tlrc_NL_warp                                                            \
    -tlrc_base                $top_dir/nlWarp/MNI152_2009_template_SSW.nii.gz \
    -tlrc_NL_warped_dsets     $anat_dir/anatQQ.${subj}.nii                   \
                              $anat_dir/anatQQ.${subj}.aff12.1D              \
                              $anat_dir/anatQQ.${subj}_WARP.nii              \
    -blur_size                5.0                                            \
    -mask_epi_anat            yes                                            \
    -regress_stim_times       $stim_dir/loss_0_ant.txt                       \
                              $stim_dir/loss_1_ant.txt                       \
                              $stim_dir/loss_5_ant.txt                       \
                              $stim_dir/loss_ant.txt $stim_dir/win_0_ant.txt \
                              $stim_dir/win_1_ant.txt                        \
                              $stim_dir/win_5_ant.txt $stim_dir/win_ant.txt  \
                              $stim_dir/fix.txt $stim_dir/win_fb_hit.txt     \
                              $stim_dir/win_fb_nhit.txt                      \
                              $stim_dir/loss_fb_hit.txt                      \
                              $stim_dir/loss_fb_nhit.txt                     \
    -regress_stim_labels      L0ANT L1ANT L5ANT LANT W0ANT W1ANT W5ANT WANT  \
                              FIX WFB_HIT WFB_NHIT LFB_HIT LFB_NHIT          \
    -regress_basis_multi      'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM'      \
                              'GAM' 'GAM' 'GAM' 'GAM' 'GAM' 'GAM'            \
    -regress_stim_types       times times times times times times times      \
                              times times times times times times            \
    -regress_censor_motion    0.3                                            \
    -regress_apply_mot_types  demean deriv                                   \
    -regress_motion_per_run                                                  \
    -regress_opts_3dD         -num_glt 10                                    \
                              -gltsym 'SYM: 1.0*WANT -1.0*W0ANT'             \
                              -glt_label 1 ANT_WIN_VS_NOWIN                  \
                              -gltsym 'SYM: 1.0*LANT -1.0*L0ANT'             \
                              -glt_label 2 ANT_LOSS_VS_NOLOSS-gltsym         \
                              'SYM: 1.0*WANT -1.0*LANT'                      \
                              -glt_label 3 ANT_WIN_VS_LOSS                   \
                              -gltsym                                        \
                              'SYM: 0.5*WANT 0.5*LANT -0.5*W0ANT -0.5*L0ANT' \
                              -glt_label 4 ANT_W15L15_VS_W0L0                \
                              -gltsym 'SYM: WFB_HIT -WFB_NHIT'               \
                              -glt_label 5 WINHIT_VS_MISS                    \
                              -gltsym 'SYM: LFB_HIT -LFB_NHIT'               \
                              -glt_label 6 LOSSHIT_VS_MISS                   \
                              -gltsym 'SYM: 1.0*W1ANT -1.0*W0ANT'            \
                              -glt_label 7 ANT_WIN1_VS_NOWIN                 \
                              -gltsym 'SYM: 1.0*W5ANT -1.0*W0ANT'            \
                              -glt_label 8 ANT_WIN5_VS_NOWIN                 \
                              -gltsym 'SYM: 1.0*L1ANT -1.0*L0ANT'            \
                              -glt_label 9 ANT_LOSS1_VS_NOLOSS               \
                              -gltsym 'SYM: 1.0*L5ANT -1.0*L0ANT'            \
                              -glt_label 10 ANT_LOSS5_VS_NOLOSS              \
    -regress_anaticor_fast                                                   \
    -regress_reml_exec                                                       \
    -regress_make_ideal_sum   sum_ideal.1D                                   \
    -regress_est_blur_epits                                                  \
    -regress_est_blur_errts                                                  \
    -regress_run_clustsim     no                                             \
    -html_review_style        pythonic                                       

There may be other suggestions for task modeling and things, too.

–pt

Oh, and maybe add in one more censoring criterion:


-regress_censor_outliers 0.05 \

… which would censor EPI volumes that have more than 5% of the brainmask filled with outlier values at a given time point?

–pt

Hello,

Sorry, but I am still a bit confused.

You say that the ANT_WIN_VS_NOWIN contrast corresponds to Win ($1 and $5) vs No Win ($0). However ANT_WIN_VS_NOWIN seems to be defined as a simple contrast of ‘WANT -W0ANT’, suggesting WANT is itself Win ($1 and $5), and No Win $0 is -W0ANT (that part seems reasonble).

Would you be able to clarify ‘Win’ more? Exactly what is Win $1? What is Win $5?

Thanks,

  • rick