Sunday, September 23, 2012

AFNI Tutorial: 3dTcat

AFNI's 3dTcat is used to concatenate datasets. For example, after performing first- and second-level analyses, you may want to join several datasets together in order to extract beta weights or parameter estimates across a range of subjects. Conversely, you may want to create a dataset that contains only a subset of the sub-briks of another dataset. This function is covered in the following AFNI video tutorial.

(N.B.: In AFNI Land, a sub-brik represents an element of an array. With runs of fMRI data, this usually means that each sub-brik is a timepoint; that is, an individual volume. When 3dTcat is used to concatenate sub-briks from multiple datasets containing beta weights, the resulting dataset is a combination of parameter estimates from different subjects, and it falls to you to keep track of which beta weight belongs to which subject. More on this at a later time.)

3dTcat is straightforward to use: Simply supply a prefix for your output dataset, as well as the range of sub-briks you wish to output. A typical 3dTcat command looks like this:
3dTcat -prefix r01_cat r01+orig'[2..$]'
This command will create a new dataset called "r01_cat", consisting of every sub-brik in r01+orig except for sub-briks 0 and 1 (recall that most AFNI commands associate 0 with the first element in an array). The '..' means "every sub-brik between these two endpoints", and the '$' sign represents the last element in the array (in this example, 205, as there are 206 timepoints; recall again that since 0 is regarded as a timepoint, we subtract 1 from the total number of timepoints to get the last element of the array).

Other patterns can be used as well, such as selecting only certain sub-briks or selecting every other sub-brik. These examples are taken from the help of 3dTcat:
  fred+orig[5]                     ==> use only sub-brick #5
  fred+orig[5,9,17]                ==> use #5, #9, and #17
  fred+orig[5..8]     or [5-8]     ==> use #5, #6, #7, and #8
  fred+orig[5..13(2)] or [5-13(2)] ==> use #5, #7, #9, #11, and #13

As emphasized in previous posts, you should check your data after running a command. In the video tutorial, we ran 3dTcat on a dataset which had 206 volumes; the resulting dataset chopped off the first two volumes, reducing the volumes in the output dataset to 204. You can quickly check this using 3dinfo with the -nt command, e.g.:
3dinfo -nt r01_cat+orig
This command will return the number of timepoints (or sub-briks, or elements) in the dataset. This can be a useful tool when you wish to execute conditional statements based on the number of sub-briks in a dataset.



More information on the evils of pre-steady-state volumes can be found here.

No comments:

Post a Comment