Monday, May 20, 2013

Combining ROIs

Once you've used a tool like fslmaths, 3dcalc, or Marsbar to create a single ROI, you can combine several of these ROIs using the same tools. This might be useful, for example, when creating a larger-scale masks encompassing several different areas.

In each case, combining ROIs is simply a matter of creating new images using a calculator-like tool; think of your TI-83 from the good old days, minus those frustrating yet addictive games such as FallDown. (Personal record: 1083.) With fslmaths, use the -add flag to concatenate several different ROIs together, e.g.:

fslmaths roi1 -add roi2 -add roi3 outputfile

With AFNI:

3dcalc -a roi1 -b roi2 -c roi3 -expr '(a+b+c)' -prefix outputfile

With Marsbar is a bit more involved, but also easier since you can do it from the GUI, as shown in the following video.




Many thanks to alert reader Anonymous, who is both too cool to register a username and once scored a 1362 on FallDown. Now all you gotta do is lay back and wait for the babe stampede!

14 comments:

  1. Andy! You rule! Thanks for responding to my comment (yes I'm the original Anon) and providing this great info. By the way my real name is V.S. Ramachandran. Just kidding.

    ReplyDelete
  2. Hello Andrew,

    I was hoping would you be able to help me out with some issues I have been having with importing FreeSurfer ROIs (labels) into SPM8. Do you think you would have the time?

    Thanks,
    Monica

    ReplyDelete
    Replies
    1. Hi Monica,

      I do not have any experience with getting Freesurfer to interface with SPM, but as far as I can tell, the most you can do with them is display SPM results on a Freesurfer surface. I would be willing to help, but it may take a lot of time.

      -Andy

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

      Delete
  3. Andrew,

    May I get your feedback as to what approach (ie: software and tools) you would take for our project?

    We are looking to do an an analysis of the entorhinal cortex on a number of subjects. We are familiar with the use of FreeSurfer to extract ROIs using the color lookup table. However, my PI wants to take a similar approach with SPM (and Marsbar, if it applies). We co-registered our subjects initial PET scan to their vMRI within SPM8. And because we aren't familiar with the technique used to create ROIs in SPM, we thought maybe it would be possible to extract the ROI in FreeSurfer and just import it into SPM. Unfortunately, no success. Our group would prefer to stay away from hand drawing the ROI, if possible.

    If using SPM, what approach would you take? Or rather, what would be the best way to set this up for proper analysis?

    Thank you,
    Monica

    ReplyDelete
    Replies
    1. Hi Monica,

      What kind of analysis are you trying to do? Is this a voxel-based morphometry analysis, or are you extracting statistics from an ROI?

      It may be easier to do this through email; I can be reached through ajahn (at) indiana.edu

      -Andy

      Delete
  4. Hey, is there a way to combine more than 25 rois because alphabet has only 25 letters :/

    ReplyDelete
    Replies
    1. Hey Duodenum,

      In that case you may have to use 3dcalc multiple times, and combine the outputs from each execution.

      -Andy

      Delete
  5. Hi Andy,

    Do you know how to use Marsbar to get the overall global value, rather than single ROIs or combination of ROIS?

    Thank you!

    ReplyDelete
  6. Hello Andrew,

    Thank you for demonstrating how to combine ROIs using MarsBar. I would like to combine two ROIs into a single one (rather than having a separate image for left and right hemisphere, I'd like a single ROI to capture both left and right sides). I see in your video that you used the (+) function (r1 + r2) to combine your ROIs, but saw somewhere else that the function r1 | r2 should be used instead. This is leaving me a bit confused. Would you be able to clarify how they differ?

    Many thanks,
    Val

    ReplyDelete
    Replies
    1. Hi Val,

      The function I used (r1 + r2) will work if the ROIs don't overlap; if there is overlap, then the voxels in that overlapping region will have a value of 2 instead of 1. If you simply want a mask that is a union of the two masks (i.e., the overlapping region will also have a value of 1), then the expression of (r1 || r2) will do that.


      Best,

      -Andy

      Delete
  7. Hi Andy,

    Is there a way to create a mask of just the overlapping voxels between two masks? Thanks for all your helpful posts!

    Best,
    Miranda

    ReplyDelete
  8. Hi Andy - how do I use fslmaths to combine ROIs, so that each one has a different intensity (e.g., 10 ROIs, with intensities 1-10)? Thanks!

    ReplyDelete