Extracting the time series

Dear all,
I would like to extract the time series from the ROI mask for different trail conditions. The script I used was as follows:

3dROIstats - mask /media/yanglab/fMRI/WLW/insula_mask+tlrc
/media/yanglab/fMRI/WLW/rawdata/SS29.results/iresp_FT_CCC0d.SS29+tlrc > ss29.insula.CCC0d.1D

I would like to confirm whether this script is correct. If not, how should I write the correct script?
Thanks very much!


Hi, Wang-

3dROIstats is indeed useful for this. (If you only had one ROI, you could use 3dmaskave.) To get purely the numbers dumped into the ss29.insula.CCC0d.1D output file, I would add -quiet to that. The output should have C columns, where C is the number of ROIs in your -mask .. dset, and then R rows, where R is the number of time points in the input time series.

There also might be some useful tips for this functionality in this AFNI Academy video on ROI Tools.


Thank you very much !
Further, please help me to confirm whether this function file (iresp_condition+tlrc) is the one that can extract time series for different trial conditions, and what is the relationship between the extracted time series values and the estimated 𝛽 value in the same trail condition, as the mean of the time series values is not equal to the estimated 𝛽 value,

Thank you very much again !


Hi, Wang-

I am not sure what iresp_condition+tlrc contains, but if it is output from an AFNI stats program (like 3dDeconvolve), you could check the subbrick labels with:

3dinfo -verb iresp_condition+tlrc

.... and see what subbricks are there and with what beta values.

We also have the AFNI Academy: Time Series playlist


Thank for your suggestion.
The EPI file (iresp_condition_k+tlrc) is the output from 3dDeconvolve (i.e., -iresp k iresp_condition_k). I will check the subbrick labels.

Thanks very much again.


The iresp_condition dataset should have the estimated response for the given 'condition', generally from use of TENT as a basis. So if you were to be using TENT(0,14,8), say, the iresp dataset would contain those 8 betas, as a time series of the average estimated response to the stimulus.

And it seems like 3dmaskave might indeed be easier, but either should be good.

  • rick

Thank you for your instruction.
The model function I used in 3dDeconvolve is GAM, since the durations of different trials were different (e.g., for the subject No.2, the average stimulus duration of CCC, ICC, IIC, and III trials was 4.05s, 4.57s, 6.83s, and 8.15s). I am not sure if the TENT model is suitable for these trial analyses. But I will re-analyze it later with the TENT model.

Thanks a lot !

Note that if the basis function is simply GAM, then creating iresp datasets will not really be useful. In that case, the iresp shape at every voxel will be identical, it will be the GAM shape. Only the magnitude will vary. But the magnitudes will be simply the beta weights. So the average beta weight for an ROI (into a single number) will be the same information as the average GAM in the iresp. Essentially, it is not worth using -iresp for fixed shape models.

But in this case the stimulus durations vary from 4-8 s, even just the means. That is not good for TENTs, but it is also not good for GAM. This should probably be modeled with duration modulation, attaching each duration to its stimulus onset time, and using -stim_stimes_AM1 'dmUBLOCK(-6)' for example, scaling results based on an average duration of 6 s (6 vs something else is not very important there, but makes the numbers somewhat representative of the events).

  • rick

Thanks for your instruction again !
I will re-analyze the 3dDeconvolve later with the dmUBLOCK model.

Thank you very much !