[Nibabel] Get raw values for voxels?

43 views
Skip to first unread message

John Richey

unread,
Dec 4, 2012, 10:25:29 AM12/4/12
to nipy...@googlegroups.com
Hi everyone,

I have what is probably a straightforward question about Nibabel... this is my first time using this tool, so please forgive me if the answer is obvious! 

For a single 3D image, I wish to obtain a matrix of values corresponding to the raw voxel intensity of each voxel. In other words, is there a way to produce a [x1, ..., Xn; Y1, ..., Yn; Z1, ..., Zn] matrix that I can use to explore the data in its numerical form?

Thanks in advance!

Yaroslav Halchenko

unread,
Dec 4, 2012, 10:33:55 AM12/4/12
to nipy...@googlegroups.com
http://nipy.sourceforge.net/nibabel/gettingstarted.html

get_data would be your friend
--
Yaroslav O. Halchenko
Postdoctoral Fellow, Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419
WWW: http://www.linkedin.com/in/yarik

Ariel Rokem

unread,
Dec 4, 2012, 10:34:33 AM12/4/12
to nipy...@googlegroups.com
Hi John, 

For most cases I've seen, this should do it: 

import nibabel as ni
d = ni.load(file_name).get_data()

Where d is now the matrix you are interested in. 

Cheers, 

Ariel 




--
 
 
 

John Richey

unread,
Dec 4, 2012, 11:25:37 AM12/4/12
to nipy...@googlegroups.com
Exactly what was needed!  Many thanks!
Reply all
Reply to author
Forward
0 new messages