Customized stimulus regressors using `-regress_stim_files`

Hello AFNI experts,

I would like to construct task-stimulus related regressors in the GLM design matrix and input them via -regress_stim_files. Specifically, I aim to convolve an HRF with the task events to allow flexibility in HRF selection and in the way of normalizing the regressor (mimicing dmUBLOCK). I have read the documentation and could you please help me to understand better the following questions:

The manual says the following, does this mean that one has to include -regress_use_stim_files whenever -regress_stim_files is given? What if I only give -regress_stim_files and no -regress_stim_times, do I still need to include -regress_use_stim_files ?

Without the -regress_use_stim_files option, 3dDeconvolve will be run using '-stim_times', not '-stim_file'. The user can still specify the 3dDeconvolve -stim_file files here, but they would then be converted to -stim_times files using the script, make_stim_times.py .

I have multiple runs and multiple events. Do you think the following steps are correct to prepare the stim_file, or do you have better suggestions?

  1. For each event per run, prepare the regressor (convolve HRF with event), ensuring it is synced to each data point in each run. Make sure the data points in each run is same as the regressor, especially if triming the n first TRs are applied.
  2. Concatenate the regressors of all runs following the run order to form a single long column for each event and save it as event*.1D.
  3. Repeat the process for other events.
  4. Provide the list of event*.1D files to -regress_stim_files and set the corresponding event name list using -regress_stim_labels

I assume I do not need -regress_stim_types in this case, right?

Can I still do per run nuisance regressors such as motion, PCs of WM and CSF, etc?

The above process estimates the fixed effect of each event type across runs. Is there a way to implement a mixed-effects model that accounts for both within-run and between-run variability? If so, how can I inform AFNI which data corresponds to which run within the long regressor column? It seems that afni_proc.py does not support mixed-effects modeling. Would the correct approach be to first conduct a run-wise GLM and then use 3dLME for the second-level analysis?

Thank you very much.

Hello,

Those options ( -regress_stim_files and with _use) were added for convenience in converting binary, tr-locked event files to timing files. It probably would have been better not to even allow that ability in afni_proc.py.

Anyway, I suggest *always* using -regress_stim_times. But given some files that are not timing but direct regressors, include -regress_stim_types and the types. For example, if you have 3 files, one of which is a timing file, and 2 of which are precomputed regressors, then consider something like:

-regress_stim_times times.txt reg1.1D reg2.1D \
-regress_stim_types time file file \
-regress_stim_labels cheese_times bad_cheese_1 bad_cheese_2 \

Note that if these regressors are NOT of interest, and you just want them part of the baseline model, they could be passed with -regress_exra_ortvec.

In any case, yes, reg1.1D and reg2.1D should span all runs (after any pre-SS time point removal). If you want them to be processed as a single regressor per run, consider 1d_tool.py -pad_into_many_runs to break 1 regressor into 1 per run, and padded with zero outside that run.

-rick

Thanks a lot @rickr, this is very clear. Just one more question, should this 1D regressor file a column or row vector?

Regressor files (for 3dDeconvolve) should have a vertical time axes, one regressor per column. When they are regressors of interest, there should be only a single column per file. An ortvec file can have many columns.

1 Like