Arbitrary response model in 3dDeconvolve

Dear afni gurus,

Is it possible to pass a purely arbitrary HRF to 3dDeconvolve?

I'm imagining something like:

-stim_times 'CUSTOM(0,1,3,6,3,-3,-4,-4,-3,-2,-1,0)'
where the series of number is the hrf model


-stim_times 'CUSTOM(0:0,1:1,2:3,3:6,4:3,5:-3,6:-4,7:-4,8:-3,9:-2,10:-1,10:0)'
where comas separate the time:value pairs that defines the hrf on arbitrary times since stimulus onset.

Perhaps the 'EXPR(b,c) exp1 ... expn' model definition could be hacked with some clever syntax I don't know about?

Thanks a lot for all your help and
Have a great day!


-stim_times 'CUSTOM(0:0,1:1,2:3,3:6,4:3,5:-3,6:-4,7:-4,8:-3,9:-2,10:-1,10:0)'
where comas separate the time:value pairs that defines the hrf on arbitrary times since stimulus onset.

What kind of experimental design are you utilizing for your study? Could you elaborate on what the two numbers mean in each time:value pair of your specification? Additionally, what specific effect are you aiming to capture?

Gang Chen

Hello Gang,

I'm empirically estimating the HRF (in a FIR-style analysis) using the 'TENT' response model. I then for example average the HRFs across voxels, and would want to use the result as the 'CUSTOM' response model for other (response amplitude) analyses.


The time:value pair definition I suggest for the 'CUSTOM' response model is just to accommodate the situation where (in the first FIR-style analysis) the FIR is not estimated on the same time grid and would need interpolation to match the data of the second response amplitude analysis.

There sure are other ways to define times for this 'CUSTOM' response model--my suggestion is just the most flexible I could think of, one that could accommodate even the unlikely case of a non-regular time grid.


A further feature--very secondary in importance for me for now--that I can foresee as useful would be to use two (ore more) functions as the 'CUSTOM' response model. This would allow e.g. a 'SPMG2'-style response model where the "gamma variate + d/dt derivative" would be replaced by 2 user-defined functions. Back to my application described above, instead of averaging the empirically derived HRFs across voxels, I could extract the first 2 principal components and use those 2 HRFs for a custom bivariate response model in a second response amplitude analysis.

I hope this makes tings clearer!
Thanks a lot for your attention and
Have a great day!


In the specification you are proposing, does it mean that the same customized HRF is shared across the entire brain?


I do not recommend such an analysis. However, it can be done with the EXPR response model, as you guessed. Sample code below. You have to be be very careful in typing out the expression, with no internal blanks or line breaks allowed!

3dDeconvolve -nodata 200 1 \
  -num_stimts 1 -polort -1 \
 -stim_times 1 '1D:1 101'  \
  'EXPR(0,11) TENT(t-1)+3*TENT(t-2)+6*TENT(t-3)+3*TENT(t-4)-3*TENT(t-5)-4*TENT(t-6)-4*TENT(t-7)-3*TENT(t-8)-2*TENT(t-9)-TENT(t-10)' \
 -x1D_stop -x1D custom.xmat.1D 

1dplot -box -num 30 custom.xmat.1D

yes indeed

Awesome, thanks a lot @rwcox123!

Not sure if that is why you don't recommend the approach, but as a warning for others:
One should not use the same data to estimate the response model and detect activation.