Tuesday, May 7, 2013

Creating Spherical ROIs in AFNI Using 3dUndump

Regions of interest; everybody wants them, but nobody knows how to get them. However, as Megatron once said, power flows to the one who knows how; desire alone is not enough.

Aware of this, I have created a script which will disenthrall you from the pit of ignorance and give you the power to create ROIs just about anywhere you please. The script uses AFNI's 3dUndump, which creates a spherical ROI of a given radius from which parameter values can be extracted using a tool like 3dmaskdump. The rationale is similar to creating ROIs using fslmaths or SPM's marsbar; and if you understand those, using 3dUndump is essentially the same thing.

The only caveat is that you must know the orientation of your dataset before using 3dUndump. AFNI defaults to RAI orientation, in which numbers increase from right to left, anterior to posterior, and inferior to superior; in other words, coordinates to the right of the origin will be negative (since numbers decrease going from left to right), and coordinates anterior to the origin will be negative (since numbers again decrease going from posterior to anterior). Always make sure to check the orientation using a command like 3dinfo -orient before creating your ROI, or open up your anatomical dataset in the AFNI viewer and navigate to the location that you want (e.g., right nucleus accumbens) and then write down the coordinates displayed in the upper left corner of the viewer. You can also use the option -orient LPI, if you're using coordinates from a paper.

This Python script that will let you input the coordinates, and then output a dataset ROI that can be overlaid on your anatomical image. The script can be found here.


Tutorial on 3dUndump:



Tutorial on MakeSpheres.py



9 comments:

  1. erikkastman at g mailJuly 23, 2013 at 11:23 PM

    Hi Andy,
    Nice helper, and tutorial. The script as posted from the link above needs a slash to make an absolute path in the hash bang, like:

    #!/usr/bin/env python (instead of)
    #!usr/bin/env python

    Otherwise, very useful. Thanks!

    ReplyDelete
    Replies
    1. Hi Erik,

      Thanks for pointing that out! It has been fixed.

      -Andy

      Delete
  2. Thanks! While, what's the anat_MNI+tlrc ?? There is an "FATAL ERROR:-master:con't open dataset" , when I do like yours.

    ReplyDelete
    Replies
    1. Hi there,

      That refers to an anatomical dataset that has been warped to MNI space; make sure that you have normalized your anatomical dataset, and that the name matches, before running the command.


      Best,

      -Andy

      Delete
    2. Thanks !
      So this sphere ROI is individual and in MNI space.
      With my understanding, for one group subjects, only one or one series of ROIs should be defined in MNI T1. Then after all native anatomical data have been warped to MNI space, the pre-defined ROI can extract the time cources.

      Best
      -Bain

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hello,
    Thank you for this tutorial.
    I want to create multiple ROIs from coordinates. I used the 3dUndump command and it created multiple spheres but they are all labeled as the same ROI. I know you suggest combining datasets with 3dcalc, but I'll have over 30 ROIs. Do you know of a more efficient way to do this?

    ReplyDelete
    Replies
    1. Hi Dustin,

      I've been having the same challenge, have you found any efficient solutions to deal with this problem?

      best,
      Levi

      Delete