[pymvpa] Concatenate datasets

Yaroslav Halchenko debian at onerussian.com
Wed Jul 4 03:24:10 UTC 2012

Hi Chris,

On Tue, 03 Jul 2012, Chris Johnson wrote:
> I have multiple nifti files I want to combine into one dataset. I
> think I have figured out how to do this, and I just want to verify:

> e.g. If I want to drop the first two volumes in images 5-12, but
> concatenate the remainder of the volumes, I would do:

> dss = [fmri_dataset('%03d/fmc.nii.gz' % i) for i in range(5,13)]
> ds = dss[0][2:]

> for ds_ in dss[1:]:
>     ds.append(ds_[2:])

I guess that should work.
Also, if you are using freshly released 2.1.0, apparently (since we
forgot to add that to Changelog for the release) you can load multiple
4D volumes, at once, e.g.

ds = fmri_dataset(['%03d/fmc.nii.gz' % i) for i in range(5,13)])

then, if they were all of the same length X, you could select those
volumes which are not the first 2, e.g.

ds = ds[ds.sa.time_indices % X >= 2]

but I guess ideally we should have also added additional samples
attribute with the indices corresponding to the ones in original
4d volumes -- then it would make desired operation easy on 4d volumes of
varying length...   if you think it is worthwhile adding -- please file
a bug report on https://github.com/PyMVPA/PyMVPA/issues and recommend
some good name for it ;-)

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        

More information about the Pkg-ExpPsy-PyMVPA mailing list