Wednesday, September 19, 2012

AFNI Tutorial: to3d

In the beginning, a young man is placed upon the scanning table as if in sacrifice. He is afraid; there are loud noises; he performs endless repetitions of a task incomprehensible. He thinks only of the coercively high amount of money he is promised in exchange for an hour of meaningless existence.

The scanner sits in silent judgment and marks off the time. The sap of life rushes to the brain, the gradients flip with terrible precision, and all is seen and all is recorded.

Such is the prologue for data collection. Sent straight into the logs of the server: Every slice, every volume, every run. All this should be marked well, as these native elements shall evolve into something far greater.

You will require three ingredients for converting raw scanner data into a basic AFNI dataset. First, the number of slices: Each volume comprises several slices, each of which measures a separate plane. Second, the number of volumes: Each run of data comprises several volumes, each of which measures a separate timepoint. Third, the repetition time: Each volume is acquired after a certain amount of time has elapsed.

Once you have assembled your materials, use to3d to convert the raw data into a BRIK/HEAD dataset. A sample command:
to3d -prefix r01 -time:zt 50 206 3000 alt+z *000006_*.dcm
This command means: "AFNI, I implore you: Label my output dataset r01; there are 50 slices per volume, 206 volumes per run, and each volume is acquired every 3000 milliseconds; slices are acquired interleaved in the z-direction; and harvest all volumes which contain the pattern 000006_ and end in dcm. Alert me when the evolution is complete."

More details and an interactive example can be found in the following video.


7 comments:

  1. Hi Andy, if the dicom files from the scanner are out of order, as often is the case, does the AFNI command to3d sequence the images based on the image index number? Or do you have to manually sequence the files before running the to3d command?

    Thank you,

    Colleen

    ReplyDelete
    Replies
    1. Hi Colleen,

      When you say out of order, do you mean acquiring in a non-sequential order (such as interleaved)? If so, there are options in to3d for that. However, if you mean images that are in no particular order, I haven't come across a situation like that. My guess is that to3d will recognize the index of each image, but without having encountered a situation like that, I can't say for sure.

      Let me know what you find!

      -Andy

      Delete
  2. Hi Andy, Thank you so much for your response. I meant to say that the file names in the directory are out of order. So, I am wondering if 'to3d' command simply inputs the files in the order/sequence in which they appear in the directory, or if the command actually parses through the metadata/header info that's imbedded within each file (and thus would have the image number/index information). This has nothing to do with the way in which the images are acquired, but in my case it is interleaved acquisition. The AFNI documentation does not mention whether the file input order makes a difference.

    update: I tried running 'to3d' on the directory containing out-of-order file names, and confirmed that the command takes the input files the order in which they appear in the directory. The generated 3D image is completely out of whack. I am a bit baffled that the file names have to be manually sequenced by the user.

    Thank you so much!

    -Colleen

    ReplyDelete
    Replies
    1. Hi Colleen,

      Unfortunately I haven't come across something like that, and it would be difficult to simulate from my end; in this case, I would recommend contacting the AFNI developers directly through their message board to see what they have to say about it.


      Good luck!

      -Andy

      Delete
  3. Sorry to dig up old news but I'm sure you have already found the answer already...

    If not, here's how to resequence your dicom files to a sequential order:

    http://fmri.ucsd.edu/Howto/3T/reorder.html

    Thought for people seeing your blog and looking for answers, may find it handy.

    Cheers,
    Norm

    ReplyDelete
    Replies
    1. Hi Norm,

      Thanks for posting the link; that's very helpful! And although I can't speak for Colleen, at least I hadn't figured it out yet - I'm much lazier than you think.


      Best,

      -Andy

      Delete
  4. Hi Andy,
    Thanks for your explanations about Afni and Neuroimage programs. Now I have a question to you. I know that it's a basical question but I'm a very beginner and I don't find a real answer to my question. The question is:
    I have a resting state raw data adquired by a Phillips 3T and I don't know how to introduce this data in AFNI to preprocess it.
    I try to introduce the to_3d command and dimon command but nothing has happened. Maybe I have stayed introduccing a wrong command. Could you help me? Sorry for my english level...

    ReplyDelete