[pymvpa] 3D images with NiftiDataset?

Dylan David Wagner dylan.d.wagner at Dartmouth.EDU
Thu Sep 18 18:03:36 UTC 2008


Michael and Yaroslav,

   Cheers for the help guys, works great (both methods). Spent some time 
with the PyNifti docstring, finally get what a NiftiImage object is. 
Anyhow, to sum up:

Michael suggested:
dataset = NiftiDataset(samples=NiftiImage(N.array( [ 
NiftiImage(i).asarray() for i in subjects] ),
                                          NiftiImage(subjects[1]).header),
                       labels=attr.labels,
                       chunks=attr.chunks,
                       mask=MaskFile)

where subjects contains a list of filenames... Worked great, mask 
applies no problems.

Yaroslav suggest something like this (apologize if my python is the 
suck. only been using it for a day):
image = N.array( NiftiImage(subjects[1]).asarray())
image = image[N.newaxis, :]
dataset = 
NiftiDataset(samples=NiftiImage(image,NiftiImage(subjects[1]).header), 
labels=whatever, mask=MaskFile)

Then I can just loop through all subjects and build up a dataset 
(dataset = dataset + NiftiDataset(blah blah blah)
<cheers to James Hughes for showing me how to do that!>.

Tried it out and the dataset is the same as Michael's method. Though a 
bit longer to code. Cheers for the help! Forced me to spend more time 
learning basic python just to understand what it was exactly you guys 
had suggested.


Also:
> Anything that the manual refers to is part of the source tarball (look
> into data/). The manual and the examples are part of the test battery of
> PyMVPA, ie. they are checked if they still do what they should, whenever
> PyMVPA itself is tested. The whole testsuite is self-contained (tests +
> data) and is part of the source tarball.
>
>   
Ahh I see, I was looking for the Data and Doc directories in the binary 
release. Grabbing the source now. Thanks.





More information about the Pkg-ExpPsy-PyMVPA mailing list