Saturday, January 5, 2013

AFNI Command of the Week: 3dcopy

Nothing earth-shattering here: Just a straightforward conversion command to let AFNI import data from different file types, such as .nii or .img/.hdr extensions. However, when I first started out doing FMRI analysis it took me quite a while to realize that this command was out there; so if you're in the same boat, here it is.

For conversion to AFNI's BRIK/HEAD format, simply type in the name of the dataset to be converted, followed by an output name, e.g.:

3dcopy r01.nii r01
----> r01+orig.HEAD r01+orig.BRIK

Datasets can also be converted the other way around, using something like 3dAFNItoNIFTI, 3dAFNItoANALYZE, etc. Using 3dcopy on a dataset already in .BRIK/.HEAD format will simply rename the dataset without affecting the extension, similar to 3drename.

Note that virtually all of AFNI's commands will output data in BRIK/HEAD format no matter what the input dataset, so you probably will not use this command that often. However, if you absolutely, positively, need to have a dataset in AFNI format - and you need it NOW - then 3dcopy is your new best friend. Move over, thirty pack of Keystone Light!



7 comments:

  1. Thank you! I've been looking for something like this for some time.
    M.

    ReplyDelete
  2. hi andy,

    i'm trying to convert raw .nii files to afni format using 3dcopy. when i type the command 3dcopy (filename).nii (filename), however, afni adds the suffix "tlrc" to the converted files (tlrc refers to an image in talairach space, i believe?) -- should it not be adding the suffix "orig" to my files (since i haven't performed any atlas warping on the .nii files yet)? any ideas on why this is happening?

    ReplyDelete
    Replies
    1. Hi there,

      That does sound strange; just to make sure that the .nii files actually aren't in a standardized space, try loading them as is (without converting to AFNI format) and also loading a standardized template in the AFNI directory. If they seem to overlap, then those files may already have been normalized at some point.

      If not, however, you can use 3dcopy and also specify the view (e.g., 3dcopy sampleDataset.nii sampleDataset+orig), or apply 3drefit to change the view (e.g., 3drefit -view orig sampleDataset+tlrc).

      Best,

      -Andy

      Delete
    2. specifying the view in the output filename seems to have worked perfectly ! thanks again.

      Delete
  3. Hi Andy- I am trying to use AFNI 3dDespike on my time series .nii data. I converted the data into 4D images using fslmerge and then successfully ran 3dDespike. But when I want to convert the afni file (HEAD/BRICK which there is only one and I wonder if it is infact the despiked 4D images), it'll crash. Do you have any pointers on how to use AFNI's 3dDespike on my time series .nii data.

    Thanks,
    SK

    ReplyDelete
    Replies
    1. Hey Sabin,

      When you use fslmerge to convert the files to .nii, how many time points are there? There should be multiple volumes, and it seems as though something is getting thrown off at that stage. Also let me know the complete command you're using to convert it.

      Best,
      -Andy

      Delete