• Blog
  • About
  • Publications
  • Videos
  • Workshops
  • CV
  • Contact Me
  • Hall of Fame
Menu

Andy's Brain Blog

Street Address
City, State, Zip
Phone Number
fMRI, Neuroimaging, and More

fmri, neuroimaging, and more

Andy's Brain Blog

  • Blog
  • About
  • Publications
  • Videos
  • Workshops
  • CV
  • Contact Me
  • Hall of Fame

Extracting Timecourses with 3dmaskdump

May 5, 2017 Andrew Jahn

ROI analysis often means averaging over all the voxels within a mask - either the average parameter, or the average timeseries. For most researchers this is all they need.

Whether or not that applies to you as well, I would like to talk about one more type of ROI analysis: extracting data from each voxel. Most researchers use this analysis to extract the timeseries for each voxel in the brain, although you can extract whatever data you like - parameter estimates, timeseries, and anything else contained in your voxels.

The best tool for this analysis is AFNI's 3dmaskdump. Using the command is simple: the only arguments it requires are an image containing the data you wish to extract, and a mask indicating which voxels to extract from. I prefer to use the options -noijk (to turn off reporting the ijk coordinates) and -xyz (to report the coordinates of each voxel in the image's space, whether it's still in its native space, or whether it has been normalized to Talairach or MNI).

Let's say that you have a mask, mask.nii, and an image, image.nii. Imagine that there are 3 voxels in your mask, and that your image has 5 volumes. If you use the command:

3dmaskdump -noijk -xyz -mask mask.nii image.nii > myFile.txt

You will get output that looks like this:

0 30 30 100.1 99.8 99.5 102.3 100.5

0 30 31 99.7 99.9 100.3 100.2 97.5

0 30 32 103.4 98.7 99.5 100.7 101.3

There are 3 rows, one for each voxel in your mask. Within each row, the first three numbers are the x-, y-, and z-coordinates of the voxel, and the next 5 numbers are the values within each volume of the image. If you would prefer not to have the coordinates for each voxel, remove the -xyz option.


I recommend using 3dmaskdump for this analysis regardless of which software you used to process your data. 3dmaskdump be used with any NIFTI image, and NIFTI images are output by the current versions of SPM and FSL. If you find yourself dealing with older data types, such as ANALYZE, it may work with that as well; be advised however that the orientation in ANALYZE files is different than NIFTI, and so the coordinates output by 3dmaskdump may be wrong.

No matter which software you use, you should begin to see how the concepts of masks and data extraction are the same across the packages. The more you practice using these tools, the more fluently you will be able to use them and talk about them - in sum, the easier it will be to do your research. And what are these tools for, if not to make our research easier?

← Reverse Normalization of fMRI DatafMRI Lab: ROI Analysis in FSL →
No results found
Archive
  • September 2024
  • June 2024
  • March 2024
  • January 2024
  • June 2023
  • May 2023
  • April 2023
  • February 2022
  • January 2022
  • January 2021
  • December 2020
  • April 2020
  • December 2018
  • April 2018
  • January 2018
  • December 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • January 2017
  • November 2016
  • August 2016
  • July 2016
  • February 2016
  • January 2016
  • September 2015
  • August 2015
  • July 2015
  • May 2015
  • April 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • April 2012
  • March 2012

What's on Andy's Brain this month?

Connect with Andy!

Summary Block
This block is invalid. Please check the block settings and try again.
Featured
Aenean eu leo Quam

Powered by Squarespace