creating stim files for when the duration is non-integer (in seconds) and TR is


I am a statistician and AFNI still continues to be new to me, after 4-5 years of using it intermittently (sorry if the answers are obvious).

So I am trying to redo the results on the datset in:

The authors used AFNI but are cut off from their code (at work) because of the pandemic so can not send me their AFNI code/scripts. But these are general questions (I think) and I think that I would benefit from learning the general case.

So, this experiment has a TR of 3s, but my question is on setting up the simulus files.

Here is the task file for one run of the experiment for a subject:

So, we have tones for 33s followed by response for 3s followed by positive musical stimulus for 31.5s followed by response of 3s followed by tones of 33s followed by response of 3s followed by negative musical stimulus for 31.5s followed by 3s of response and then the cycle repeats.

So, it seems to me that we should have 6 tasks (and no baseline). The 6 tasks are:

  1. tones
  2. response to tones
  3. positive musical stimulus
  4. response to positive musical stimulus
  5. negative musical stimulus
  6. response to negative musical stimulus

So, what I would like clarification on is: does it matter that the two musical stimulus conditions are for non-integer durations of 31.5s and I can simply specify BLOCK(31.5) for those two files? Each of the subjects had multiple runs and I understand that for that we simply put in one line.

Do the different stimulus timing files have to be named in a particular way?

I am not sure that this question in what follows can be easily answered but I thought that someone here might have suggestions:

There are 105 time points with a TR of 3s. That gives me a total time duration of 315s. However, the task files above seems to account for 309+3 = 312s. How will AFNI handle this? Drop the last one? (Or the first one?)

According to the paper at, there is a total time of 5 minutes 24 seconds (that is, 324 seconds) but 105 datapoints (first para of Section on Procedures (under fMRI methods). Under Section on Analysis (para on fMRI preprocessing, penultimate sentence), they do write that “motion of greater than 1 mm between successive TRs resulted in the censoring of that TR and the two adjacent TRs.” However, their Figure 1 does not accurately match the 31.5 s duration of the musical stimuli so some of the writing may not be completely accurate (unfortunately but understandable when you are trying to get things out the door).

Many thanks again, for clarifying the stimulus timing questions, and for your thoughts on the second part, and my best wishes,

Hi Ranjan,

Yes, you can specify BLOCK(31.5) or BLOCK(31.5,1) for the basis function. The duration does not need to be a multiple of the TR. Event onsets do not need to be TR-locked, either.

I do not think there is any restriction on the naming of the timing files, though there are some special characters that could be problematic, were they use in the file names (that does not seem to be your question).

If the run duration is 315s and take makes up 312s of it, that would like 3s of baseline/non-task time. AFNI does not expect all time to be modeled. In fact, it can be problematic if all time is modeled. But there is also the possibility that there were 3 time points dropped as pre-magnetization steady state time. It is not clear.

Note that there will (presumably) still be a baseline modeled on top of this. But because there is essentially no baseline time, only contrasts will be useful. So ‘tones’ will not be useful on its own, but ‘tones’ - ‘response_to_tones’ might be.

  • rick