split half-ing with timing_tool?

Hello AFNI friends!

We are interested in testing the internal consistency of some of our tasks and would like to do split half analyses (i.e., compare odd trials with even trials for each of our event types). I’ve searched through the timing_tool help page, but can’t seem to find a function that will allow me to split each of my current timing files into two separate files based on whether the trials are odd or even. Given all of the magic that timing_tool is capable of, I feel like one of the existing functions could allow me to do what I’d like to do, but I’m just not able to extrapolate from the examples provided to figure out the best way to go about it.

Any thoughts or suggestions would be greatly appreciated!


A possible solution is the Unix command line utility ‘cut’. For example, if file fred.txt is

1 2 3 4 5 6 7
1 2 3
1 2 3 4 5

Then the command

cut -f 1,3,5,7,9 -d ' ' fred.txt

produces (to stdout) the results

1 3 5 7
1 3
1 3 5

That’s the odd numbered columns, separated by the space ’ ’ character (up to column #9). By putting in at least as many column indexes after the ‘-f’ option as there are actual columns, you can pick out what you want. You can use the AFNI ‘count’ utility for this purpose, as in

cut -d ' ' -f `count -dig 1 -comma 1 99 2` fred.txt

Here, the backquote operator count ... means “run the command inside the backquotes, capture the stdout and put it on the command line here”. If you try the given count command by itself, you get

count -dig 1 -comma 1 99 2

For the even columns, use ‘count -dig 1 -comma 2 100 2’ instead. Note that the option -d ’ ’ is needed since the default separator for ‘cut’ is the tab character, so if you used spaces, then each line is considered to be one big column and you won’t like the results. Obviously, you need to test the results to make sure they work with your files!

Hi Johanna,

Bob gives a very nice solution.

timing_tool.py does do things like that, but it is very
specific and would require a new option (though simple).

If the timing files all have the same number of events,
you could also create a partition file that looks like:


(or 1 2 1 2 … or whatever), and then use ‘Example 5’
to partition all of the stim files based on those labels.
They are required to match the events, exactly.

Are the numbers of events consistent?

  • rick

Sorry for the radio silence. Thanks for the speedy response! I’ll give this a try and let you know how it goes. Much appreciated!


Hi Rick,

Thanks for this suggestion. We DO have the same number of trials! There are a different number of across events, but the same within. I’ll give this a try too and see how it goes. Much appreciated!