14.2.8. Chen et al. (2022). Hyperbolic trade-off: The importance of balancing trial …

Introduction

Here we present commands used in the following paper:

  • Chen G, Pine DS, Brotman MA, Smith AR, Cox RW, Taylor PA, Haller SP (2022). Hyperbolic trade-off: The importance of balancing trial and subject sample sizes in neuroimaging. Neuroimage 247:118786.

Abstract:

Here we investigate the crucial role of trials in task-based neuroimaging from the perspectives of statistical efficiency and condition-level generalizability. Big data initiatives have gained popularity for leveraging a large sample of subjects to study a wide range of effect magnitudes in the brain. On the other hand, most task-based FMRI designs feature a relatively small number of subjects, so that resulting parameter estimates may be associated with compromised precision. Nevertheless, little attention has been given to another important dimension of experimental design, which can equally boost a study’s statistical efficiency: the trial sample size. The common practice of condition-level modeling implicitly assumes no cross-trial variability. Here, we systematically explore the different factors that impact effect uncertainty, drawing on evidence from hierarchical modeling, simulations and an FMRI dataset of 42 subjects who completed a large number of trials of cognitive control task. We find that, due to an approximately symmetric hyperbola-relationship between trial and subject sample sizes in the presence of relatively large cross-trial variability, 1) trial sample size has nearly the same impact as subject sample size on statistical efficiency; 2) increasing both the number of trials and subjects improves statistical efficiency more effectively than focusing on subjects alone; 3) trial sample size can be leveraged alongside subject sample size to improve the cost-effectiveness of an experimental design; 4) for small trial sample sizes, trial-level modeling, rather than condition-level modeling through summary statistics, may be necessary to accurately assess the standard error of an effect estimate. We close by making practical suggestions for improving experimental designs across neuroimaging and behavioral studies.

Study keywords:

task-block, EPI, MPRAGE, Eriksen flanker task (congruent, incongruent), trial-level modeling, trial sample size, subject sample size, statistical efficiency, generalizability, replicability

Main programs: afni_proc.py, 3dDeconvolve (and 3dREMLfit)

Download scripts

To download, either:

  • ... click the link(s) in the following table (perhaps Rightclick -> “Save Link As…”):

    s1.2022_ChenEtal.ap.tcsh

    run afni_proc.py for task analysis on FMRI data

    s2.2022_ChenEtal.AM_decon_reml.tcsh

    run 3dDeconvolve (which also creates a 3dREMLfit script)

    s3.2022_ChenEtal.AMerr_decon_reml.tcsh

    run 3dDeconvolve (which also creates a 3dREMLfit script)

    s4.2022_ChenEtal.IM_decon_reml.tcsh

    run 3dDeconvolve (which also creates a 3dREMLfit script)

    s5.2022_ChenEtal.IMerr_decon_reml.tcsh

    run 3dDeconvolve (which also creates a 3dREMLfit script)

  • ... or copy+paste into a terminal:

    curl -O https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/fmri/media/2022_ChenEtal/s1.2022_ChenEtal.ap.tcsh
    curl -O https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/fmri/media/2022_ChenEtal/s2.2022_ChenEtal.AM_decon_reml.tcsh
    curl -O https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/fmri/media/2022_ChenEtal/s3.2022_ChenEtal.AMerr_decon_reml.tcsh
    curl -O https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/fmri/media/2022_ChenEtal/s4.2022_ChenEtal.IM_decon_reml.tcsh
    curl -O https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/codex/fmri/media/2022_ChenEtal/s5.2022_ChenEtal.IMerr_decon_reml.tcsh
    

View scripts

s1.2022_ChenEtal.ap.tcsh

  1#!/bin/tcsh
  2
  3set subj    = ${1}
  4set session = ${2}
  5set cohort  = ${3}
  6
  7set stimdir =          # location of subj timing files
  8set epidir  =          # location of subj EPI volumes
  9set anatdir =          # location of subj anatomical volumes
 10set outdir  =          # directory for output
 11set motion_max =       # motion censoring limit
 12
 13# ----------------------------------------------------------------------------
 14setenv MPLBACKEND agg
 15
 16mkdir ${outdir}
 17
 18# ----------------------------------------------------------------------------
 19
 20# Comment: this AP command didn't use @SSwarper for nonlinear
 21# alignment (it uses 3dQwarp still, just through auto_warper.py), but
 22# that could directly be swapped in.
 23
 24afni_proc.py                                                                 \
 25    -subj_id                  ${subj}                                        \
 26    -script                   $outdir/proc.script.${subj}                    \
 27    -out_dir                  $outdir/${subj}.results                        \
 28    -scr_overwrite                                                           \
 29    -copy_anat                $anatdir/${subj}_anat${session}+orig.HEAD      \
 30    -dsets                    $epidir/OutBrick_visit${session}_r?+orig.HEAD  \
 31    -blocks                   despike tshift align tlrc volreg mask blur     \
 32                              scale regress                                  \
 33    -radial_correlate_blocks  tcat volreg                                    \
 34    -tcat_remove_first_trs    4                                              \
 35    -align_opts_aea           -check_flip -cost lpc+ZZ                       \
 36                              -giant_move                                    \
 37                              -AddEdge                                       \
 38    -tlrc_base                MNI152_2009_template_SSW.nii.gz                \
 39    -tlrc_NL_warp                                                            \
 40    -volreg_align_to          MIN_OUTLIER                                    \
 41    -volreg_align_e2a                                                        \
 42    -volreg_tlrc_warp                                                        \
 43    -mask_epi_anat            yes                                            \
 44    -blur_size                6.5                                            \
 45    -blur_to_fwhm                                                            \
 46    -regress_stim_times       $stimdir/Con_corr_${subj}-${session}.1D        \
 47                              $stimdir/Con_com_${subj}-${session}.1D         \
 48                              $stimdir/Con_omission_${subj}-${session}.1D    \
 49                              $stimdir/Incon_corr_${subj}-${session}.1D      \
 50                              $stimdir/Incon_com_${subj}-${session}.1D       \
 51                              $stimdir/Incon_omission_${subj}-${session}.1D  \
 52    -regress_stim_labels      Cong_cor Cong_com Cong_omi Incong_cor          \
 53                              Incong_com Incong_omi                          \
 54    -regress_basis            GAM                                            \
 55    -regress_local_times                                                     \
 56    -regress_motion_per_run                                                  \
 57    -regress_censor_motion    ${motion_max}                                  \
 58    -regress_censor_outliers  0.1                                            \
 59    -regress_compute_fitts                                                   \
 60    -regress_make_ideal_sum   sum_ideal.1D                                   \
 61    -regress_est_blur_epits                                                  \
 62    -regress_est_blur_errts                                                  \
 63    -regress_reml_exec                                                       \
 64    -regress_opts_reml        -GOFORIT 99                                    \
 65    -regress_compute_fitts                                                   \
 66    -regress_opts_3dD         -bout -jobs 6                                  \
 67                              -allzero_OK                                    \
 68                              -GOFORIT 99                                    \
 69                              -num_glt 13                                    \
 70                              -gltsym                                        \
 71                              'SYM: +Incong_com +Incong_omi +Incong_cor'     \
 72                              -glt_label 1 Incong__all                       \
 73                              -gltsym 'SYM: +Cong_com +Cong_omi +Cong_cor'   \
 74                              -glt_label 2 Cong__all                         \
 75                              -gltsym 'SYM: +0.5*Incong_com +0.5*Incong_omi' \
 76                              -glt_label 3 Incong_Error                      \
 77                              -gltsym 'SYM: +0.5*Cong_com +0.5*Cong_omi'     \
 78                              -glt_label 4 Cong_Error                        \
 79                              -gltsym                                        \
 80                              'SYM: +0.25*Cong_com +0.25*Cong_omi +0.25*Incong_com +0.25*Incong_omi' \
 81                              -glt_label 5 TOTAL_Error                       \
 82                              -gltsym 'SYM: +Incong_cor -Cong_cor'           \
 83                              -glt_label 6 Incong_cor_VS_Cong_cor            \
 84                              -gltsym 'SYM: +0.5*Cong_cor +0.5*Incong_cor'   \
 85                              -glt_label 7 TOTAL_Correct                     \
 86                              -gltsym                                        \
 87                              'SYM: +0.5*Incong_com +0.5*Incong_omi -1.0*Incong_cor' \
 88                              -glt_label 8 Incong_err_VS_Incong_cor          \
 89                              -gltsym                                        \
 90                              'SYM: +0.5*Cong_com +0.5*Cong_omi -1.0*Cong_cor' \
 91                              -glt_label 9 Cong_err_VS_Cong_cor              \
 92                              -gltsym 'SYM: +Incong_com -Incong_cor'         \
 93                              -glt_label 10 Incong_com_VS_Incong_cor         \
 94                              -gltsym 'SYM: +Incong_com -Cong_com'           \
 95                              -glt_label 11 Incong_com_VS_Cong_com           \
 96                              -gltsym                                        \
 97                              'SYM: +0.5*Incong_com +0.5*Incong_omi -0.5*Cong_com -0.5*Cong_omi' \
 98                              -glt_label 12 Incong_err_VS_Cong_err           \
 99                              -gltsym                                        \
100                              'SYM: +Incong_com +Incong_omi +Incong_cor +Cong_com +Cong_omi +Cong_cor' \
101                              -glt_label 13 Task_VS_Fixation                 \
102    -html_review_style        pythonic                                       \
103    -execute

s2.2022_ChenEtal.AM_decon_reml.tcsh

  1#!/bin/tcsh
  2
  3set subj    = ${1}
  4set session = ${2}
  5set stimdir = ${3}          # timing file dir
  6set prefix  = AMmodel
  7
  8# ---------------------------------------------------------------------------
  9# run the regression analysis
 10
 113dDeconvolve                                                                 \
 12    -input           pb05.${subj}.r0*.scale+tlrc.HEAD                        \
 13    -polort          A                                                       \
 14    -local_times                                                             \
 15    -censor          censor_${subj}_combined_2.1D                            \
 16    -num_stimts      12                                                      \
 17    -stim_times_AM2  1 ${stimdir}/Con_corr_${subj}-${session}AM.1D 'GAM'     \
 18    -stim_label      1 Cong_cor                                              \
 19    -stim_times      2 ${stimdir}/Con_com_${subj}-${session}.1D 'GAM'        \
 20    -stim_label      2 Cong_com                                              \
 21    -stim_times_AM2  3 ${stimdir}/Incon_corr_${subj}-${session}AM.1D 'GAM'   \
 22    -stim_label      3 Incong_cor                                            \
 23    -stim_times      4 ${stimdir}/Incon_com_${subj}-${session}.1D 'GAM'      \
 24    -stim_label      4 Incong_com                                            \
 25    -stim_times      5 ${stimdir}/Con_omission_${subj}-${session}.1D 'GAM'   \
 26    -stim_label      5 Cong_omi                                              \
 27    -stim_times      6 ${stimdir}/Incon_omission_${subj}-${session}.1D 'GAM' \
 28    -stim_label      6 Incong_omi                                            \
 29    -stim_file       7 motion_demean.1D'[0]'                                 \
 30    -stim_base       7                                                       \
 31    -stim_label      7 roll                                                  \
 32    -stim_file       8 motion_demean.1D'[1]'                                 \
 33    -stim_base       8                                                       \
 34    -stim_label      8 pitch                                                 \
 35    -stim_file       9 motion_demean.1D'[2]'                                 \
 36    -stim_base       9                                                       \
 37    -stim_label      9 yaw                                                   \
 38    -stim_file       10 motion_demean.1D'[3]'                                \
 39    -stim_base       10                                                      \
 40    -stim_label      10 dS                                                   \
 41    -stim_file       11 motion_demean.1D'[4]'                                \
 42    -stim_base       11                                                      \
 43    -stim_label      11 dL                                                   \
 44    -stim_file       12 motion_demean.1D'[5]'                                \
 45    -stim_base       12                                                      \
 46    -stim_label      12 dP                                                   \
 47    -fout                                                                    \
 48    -tout                                                                    \
 49    -GOFORIT         99                                                      \
 50    -allzero_OK                                                              \
 51    -num_glt         4                                                       \
 52    -gltsym          'SYM: +Incong_cor[0] -Cong_cor[0]'                      \
 53    -glt_label       1 Incong_cor_VS_Cong_cor0                               \
 54    -gltsym          'SYM: +0.5*Cong_cor[0] +0.5*Incong_cor[0]'              \
 55    -glt_label       2 TOTAL_Correct0 #-gltsym                               \
 56                     'SYM: +Incong_com[0] -Incong_cor[0]'                    \
 57    -glt_label       3 Incong_com_VS_Incong_cor0 #-gltsym                    \
 58                     'SYM: +Incong_com[0] -Cong_com[0]'                      \
 59    -glt_label       4 Incong_com_VS_Cong_com0 #-gltsym                      \
 60                     'SYM: +Incong_com[0] +Incong_cor[0] +Cong_com[0] +Cong_cor[0]' \
 61    -glt_label       5 Task_VS_Fixation_no_omissions0                        \
 62    -gltsym          'SYM: +Incong_cor[1] -Cong_cor[1]'                      \
 63    -glt_label       3 Incong_cor_VS_Cong_cor1                               \
 64    -gltsym          'SYM: +0.5*Cong_cor[1] +0.5*Incong_cor[1]'              \
 65    -glt_label       4 TOTAL_Correct1 #-gltsym                               \
 66                     'SYM: +Incong_com[1] -Incong_cor[1]'                    \
 67    -glt_label       8 Incong_com_VS_Incong_cor1 #-gltsym                    \
 68                     'SYM: +Incong_com[1] -Cong_com[1]'                      \
 69    -glt_label       9 Incong_com_VS_Cong_com1 #-gltsym                      \
 70                     'SYM: +Incong_com[1] +Incong_cor[1] +Cong_com[1] +Cong_cor[1]' \
 71    -glt_label       10 Task_VS_Fixation_no_omissions1                       \
 72    -cbucket         $prefix.cbucket.stats.${subj}                           \
 73    -xsave                                                                   \
 74    -jobs            6                                                       \
 75    -fout                                                                    \
 76    -tout                                                                    \
 77    -x1D             $prefix.X.xmat.1D                                       \
 78    -xjpeg           $prefix.X.jpg                                           \
 79    -fitts           $prefix.fitts.${subj}                                   \
 80    -errts           $prefix.errts.${subj}                                   \
 81    -bucket          $prefix.stats.${subj}
 82
 83# if 3dDeconvolve fails, terminate the script
 84if ( $status != 0 ) then
 85    echo "------------------------------------------------"
 86    echo "** 3dDeconvolve error (for $prefix), failing..."
 87    echo "   subj = ${subj}, session = ${session}"
 88    echo "   (consider the file 3dDeconvolve.err)"
 89    exit 1
 90endif
 91
 92# ---------------------------------------------------------------------------
 93
 94# display any large pairwise correlations from the X-matrix
 951d_tool.py -show_cormat_warnings -infile X.xmat.1D                           \
 96    |& tee out.cormat_warn.${prefix}.txt
 97
 98# display degrees of freedom info from X-matrix
 991d_tool.py -show_df_info -infile X.xmat.1D                                   \
100    |& tee out.df_info.${prefix}.txt
101
102# -- execute the 3dREMLfit script, written by 3dDeconvolve --
103tcsh -x $prefix.REML_cmd -GOFORIT 99
104
105# if 3dREMLfit fails, terminate the script
106if ( $status != 0 ) then
107    echo "------------------------------------------------"
108    echo "** 3dREMLfit error (for $prefix), failing..."
109    echo "   subj = ${subj}, session = ${session}"
110    exit 
111endif
112
113exit 0

s3.2022_ChenEtal.AMerr_decon_reml.tcsh

 1#!/bin/tcsh
 2
 3set subj    = ${1}
 4set session = ${2}
 5set stimdir = ${3}          # timing file dir
 6set prefix  = errorAMmodel
 7
 8# ---------------------------------------------------------------------------
 9# run the regression analysis
10
113dDeconvolve                                                                 \
12    -input           pb05.${subj}.r0*.scale+tlrc.HEAD                        \
13    -polort          A                                                       \
14    -local_times                                                             \
15    -censor          censor_${subj}_combined_2.1D                            \
16    -num_stimts      12                                                      \
17    -stim_times      1 ${stimdir}/Con_corr_${subj}-${session}.1D 'GAM'       \
18    -stim_label      1 Cong_cor                                              \
19    -stim_times      2 ${stimdir}/Con_com_${subj}-${session}.1D 'GAM'        \
20    -stim_label      2 Cong_com                                              \
21    -stim_times_AM2  3 ${stimdir}/Incon_corr_${subj}-${session}AM.1D 'GAM'   \
22    -stim_label      3 Incong_cor                                            \
23    -stim_times_AM2  4 ${stimdir}/Incon_com_${subj}-${session}AM.1D 'GAM'    \
24    -stim_label      4 Incong_com                                            \
25    -stim_times      5 ${stimdir}/Con_omission_${subj}-${session}.1D 'GAM'   \
26    -stim_label      5 Cong_omi                                              \
27    -stim_times      6 ${stimdir}/Incon_omission_${subj}-${session}.1D 'GAM' \
28    -stim_label      6 Incong_omi                                            \
29    -stim_file       7 motion_demean.1D'[0]'                                 \
30    -stim_base       7                                                       \
31    -stim_label      7 roll                                                  \
32    -stim_file       8 motion_demean.1D'[1]'                                 \
33    -stim_base       8                                                       \
34    -stim_label      8 pitch                                                 \
35    -stim_file       9 motion_demean.1D'[2]'                                 \
36    -stim_base       9                                                       \
37    -stim_label      9 yaw                                                   \
38    -stim_file       10 motion_demean.1D'[3]'                                \
39    -stim_base       10                                                      \
40    -stim_label      10 dS                                                   \
41    -stim_file       11 motion_demean.1D'[4]'                                \
42    -stim_base       11                                                      \
43    -stim_label      11 dL                                                   \
44    -stim_file       12 motion_demean.1D'[5]'                                \
45    -stim_base       12                                                      \
46    -stim_label      12 dP                                                   \
47    -fout                                                                    \
48    -tout                                                                    \
49    -GOFORIT         99                                                      \
50    -allzero_OK                                                              \
51    -num_glt         2                                                       \
52    -gltsym          'SYM: +Incong_com[0] -Incong_cor[0]'                    \
53    -glt_label       1 Incong_com_VS_Incong_cor0                             \
54    -gltsym          'SYM: +Incong_com[1] -Incong_cor[1]'                    \
55    -glt_label       2 Incong_com_VS_Incong_cor1                             \
56    -cbucket         $prefix.cbucket.stats.${subj}                           \
57    -xsave                                                                   \
58    -jobs            6                                                       \
59    -fout                                                                    \
60    -tout                                                                    \
61    -x1D             $prefix.X.xmat.1D                                       \
62    -xjpeg           $prefix.X.jpg                                           \
63    -fitts           $prefix.fitts.${subj}                                   \
64    -errts           $prefix.errts.${subj}                                   \
65    -bucket          $prefix.stats.${subj}
66
67# if 3dDeconvolve fails, terminate the script
68if ( $status != 0 ) then
69    echo "------------------------------------------------"
70    echo "** 3dDeconvolve error (for $prefix), failing..."
71    echo "   subj = ${subj}, session = ${session}"
72    echo "   (consider the file 3dDeconvolve.err)"
73    exit 1
74endif
75
76# ---------------------------------------------------------------------------
77
78# display any large pairwise correlations from the X-matrix
791d_tool.py -show_cormat_warnings -infile X.xmat.1D                           \
80    |& tee out.cormat_warn.${prefix}.txt
81
82# display degrees of freedom info from X-matrix
831d_tool.py -show_df_info -infile X.xmat.1D                                   \
84    |& tee out.df_info.${prefix}.txt
85
86# -- execute the 3dREMLfit script, written by 3dDeconvolve --
87tcsh -x $prefix.REML_cmd -GOFORIT 99
88
89# if 3dREMLfit fails, terminate the script
90if ( $status != 0 ) then
91    echo "------------------------------------------------"
92    echo "** 3dREMLfit error (for $prefix), failing..."
93    echo "   subj = ${subj}, session = ${session}"
94    exit 1
95endif
96
97exit 0

s4.2022_ChenEtal.IM_decon_reml.tcsh

 1#!/bin/tcsh
 2
 3set subj    = ${1}
 4set session = ${2}
 5set stimdir = ${3}          # timing file dir
 6set prefix  = IMmodel
 7
 8# ---------------------------------------------------------------------------
 9# run the regression analysis
10
113dDeconvolve                                                                 \
12    -input          pb05.${subj}.r0*.scale+tlrc.HEAD                         \
13    -polort         A                                                        \
14    -local_times                                                             \
15    -censor         censor_${subj}_combined_2.1D                             \
16    -num_stimts     12                                                       \
17    -stim_times_IM  1 ${stimdir}/Con_corr_${subj}-${session}.1D 'GAM'        \
18    -stim_label     1 Cong_cor                                               \
19    -stim_times_IM  2 ${stimdir}/Incon_corr_${subj}-${session}.1D 'GAM'      \
20    -stim_label     2 Incong_cor                                             \
21    -stim_times     3 ${stimdir}/Con_com_${subj}-${session}.1D 'GAM'         \
22    -stim_label     3 Cong_com                                               \
23    -stim_times     4 ${stimdir}/Incon_com_${subj}-${session}.1D 'GAM'       \
24    -stim_label     4 Incong_com                                             \
25    -stim_times     5 ${stimdir}/Con_omission_${subj}-${session}.1D 'GAM'    \
26    -stim_label     5 Cong_omi                                               \
27    -stim_times     6 ${stimdir}/Incon_omission_${subj}-${session}.1D 'GAM'  \
28    -stim_label     6 Incong_omi                                             \
29    -stim_file      7 motion_demean.1D'[0]'                                  \
30    -stim_base      7                                                        \
31    -stim_label     7 roll                                                   \
32    -stim_file      8 motion_demean.1D'[1]'                                  \
33    -stim_base      8                                                        \
34    -stim_label     8 pitch                                                  \
35    -stim_file      9 motion_demean.1D'[2]'                                  \
36    -stim_base      9                                                        \
37    -stim_label     9 yaw                                                    \
38    -stim_file      10 motion_demean.1D'[3]'                                 \
39    -stim_base      10                                                       \
40    -stim_label     10 dS                                                    \
41    -stim_file      11 motion_demean.1D'[4]'                                 \
42    -stim_base      11                                                       \
43    -stim_label     11 dL                                                    \
44    -stim_file      12 motion_demean.1D'[5]'                                 \
45    -stim_base      12                                                       \
46    -stim_label     12 dP                                                    \
47    -fout                                                                    \
48    -tout                                                                    \
49    -GOFORIT        99                                                       \
50    -allzero_OK                                                              \
51    -cbucket        $prefix.cbucket.stats.${subj}                            \
52    -xsave                                                                   \
53    -jobs           6                                                        \
54    -fout                                                                    \
55    -tout                                                                    \
56    -x1D            $prefix.X.xmat.1D                                        \
57    -xjpeg          $prefix.X.jpg                                            \
58    -fitts          $prefix.fitts.${subj}                                    \
59    -errts          $prefix.errts.${subj}                                    \
60    -bucket         $prefix.stats.${subj}
61	
62# if 3dDeconvolve fails, terminate the script
63if ( $status != 0 ) then
64    echo "------------------------------------------------"
65    echo "** 3dDeconvolve error (for $prefix), failing..."
66    echo "   subj = ${subj}, session = ${session}"
67    echo "   (consider the file 3dDeconvolve.err)"
68    exit 1
69endif
70
71# ---------------------------------------------------------------------------
72
73# display any large pairwise correlations from the X-matrix
741d_tool.py -show_cormat_warnings -infile X.xmat.1D                           \
75    |& tee out.cormat_warn.${prefix}.txt
76
77# display degrees of freedom info from X-matrix
781d_tool.py -show_df_info -infile X.xmat.1D                                   \
79    |& tee out.df_info.${prefix}.txt
80
81# -- execute the 3dREMLfit script, written by 3dDeconvolve --
82tcsh -x $prefix.REML_cmd -GOFORIT 99
83
84# if 3dREMLfit fails, terminate the script
85if ( $status != 0 ) then
86    echo "------------------------------------------------"
87    echo "** 3dREMLfit error (for $prefix), failing..."
88    echo "   subj = ${subj}, session = ${session}"
89    exit 1
90endif
91
92exit 0

s5.2022_ChenEtal.IMerr_decon_reml.tcsh

 1#!/bin/tcsh
 2
 3set subj    = ${1}
 4set session = ${2}
 5set stimdir = ${3}          # timing file dir
 6set prefix  = errorIMmodel
 7
 8# ---------------------------------------------------------------------------
 9# run the regression analysis
10
113dDeconvolve                                                                 \
12    -input          pb05.${subj}.r0*.scale+tlrc.HEAD                         \
13    -polort         A                                                        \
14    -local_times                                                             \
15    -censor         censor_${subj}_combined_2.1D                             \
16    -num_stimts     12                                                       \
17    -stim_times_IM  1 ${stimdir}/Incon_corr_${subj}-${session}.1D 'GAM'      \
18    -stim_label     1 Incong_cor                                             \
19    -stim_times_IM  2 ${stimdir}/Incon_com_${subj}-${session}.1D 'GAM'       \
20    -stim_label     2 Incong_com                                             \
21    -stim_times     3 ${stimdir}/Con_corr_${subj}-${session}.1D 'GAM'        \
22    -stim_label     3 Cong_cor                                               \
23    -stim_times     4 ${stimdir}/Con_com_${subj}-${session}.1D 'GAM'         \
24    -stim_label     4 Cong_com                                               \
25    -stim_times     5 ${stimdir}/Con_omission_${subj}-${session}.1D 'GAM'    \
26    -stim_label     5 Cong_omi                                               \
27    -stim_times     6 ${stimdir}/Incon_omission_${subj}-${session}.1D 'GAM'  \
28    -stim_label     6 Incong_omi                                             \
29    -stim_file      7 motion_demean.1D'[0]'                                  \
30    -stim_base      7                                                        \
31    -stim_label     7 roll                                                   \
32    -stim_file      8 motion_demean.1D'[1]'                                  \
33    -stim_base      8                                                        \
34    -stim_label     8 pitch                                                  \
35    -stim_file      9 motion_demean.1D'[2]'                                  \
36    -stim_base      9                                                        \
37    -stim_label     9 yaw                                                    \
38    -stim_file      10 motion_demean.1D'[3]'                                 \
39    -stim_base      10                                                       \
40    -stim_label     10 dS                                                    \
41    -stim_file      11 motion_demean.1D'[4]'                                 \
42    -stim_base      11                                                       \
43    -stim_label     11 dL                                                    \
44    -stim_file      12 motion_demean.1D'[5]'                                 \
45    -stim_base      12                                                       \
46    -stim_label     12 dP                                                    \
47    -fout                                                                    \
48    -tout                                                                    \
49    -GOFORIT        99                                                       \
50    -allzero_OK                                                              \
51    -cbucket        $prefix.cbucket.stats.${subj}                            \
52    -xsave                                                                   \
53    -jobs           6                                                        \
54    -fout                                                                    \
55    -tout                                                                    \
56    -x1D            $prefix.X.xmat.1D                                        \
57    -xjpeg          $prefix.X.jpg                                            \
58    -fitts          $prefix.fitts.${subj}                                    \
59    -errts          $prefix.errts.${subj}                                    \
60    -bucket         $prefix.stats.${subj}
61
62# if 3dDeconvolve fails, terminate the script
63if ( $status != 0 ) then
64    echo "------------------------------------------------"
65    echo "** 3dDeconvolve error (for $prefix), failing..."
66    echo "   subj = ${subj}, session = ${session}"
67    echo "   (consider the file 3dDeconvolve.err)"
68    exit 1
69endif
70
71# ---------------------------------------------------------------------------
72
73# display any large pairwise correlations from the X-matrix
741d_tool.py -show_cormat_warnings -infile X.xmat.1D                           \
75    |& tee out.cormat_warn.${prefix}.txt
76
77# display degrees of freedom info from X-matrix
781d_tool.py -show_df_info -infile X.xmat.1D                                   \
79    |& tee out.df_info.${prefix}.txt
80
81# -- execute the 3dREMLfit script, written by 3dDeconvolve --
82tcsh -x $prefix.REML_cmd -GOFORIT 99
83
84# if 3dREMLfit fails, terminate the script
85if ( $status != 0 ) then
86    echo "------------------------------------------------"
87    echo "** 3dREMLfit error (for $prefix), failing..."
88    echo "   subj = ${subj}, session = ${session}"
89    exit 1
90endif
91
92exit 0