[pymvpa] Loading multiple ROIs with fmri_dataset
Yaroslav O Halchenko
yoh at onerussian.com
Tue Aug 13 20:59:53 BST 2019
On Tue, 13 Aug 2019, Lyam Bailey wrote:
> Dear users,
> I am trying to manually load in the PyMVPA tutorial data, instead of using
> the load_tutorial_data convenience function (as shown here, for example:
> http://www.pymvpa.org/examples/rsa_fmri.html). I have downloaded the
> tutorial data and replaced the following lines of code from the example
> script:
> from mvpa2.datasets.sources.native import load_tutorial_data
> datapath = pjoin(cfg.get('location', 'tutorial data'), 'haxby2001')
> ds = load_tutorial_data(roi=(15, 16, 23, 24, 36, 38, 39, 40, 48))
> with the following loop:
> data_path = pjoin('haxby2001', 'sub001')
> runs = [1,2]
> run_datasets = []
> targets = SampleAttributes(pjoin(data_path, 'BOLD','task001_run001',
> 'attributes.txt'))['targets']
> for i in runs:
> bold_fname = pjoin(data_path, 'BOLD', 'task001_run00' + str(i),
> 'bold.nii.gz')
> temp_ds = fmri_dataset(bold_fname, mask=None, targets = targets,
> chunks = i-1)
> run_datasets.append(temp_ds)
> ds = vstack(run_datasets, a=0)
> The one thing I'm missing is how to load in multiple ROIs, as in ds =
> load_tutorial_data(roi=(15, 16, 23, 24, 36, 38, 39, 40, 48)). Is
> there a way to achieve this with fmri_dataset? Or is there a more
fmri_dataset has an argument:
add_fa : dict or None
Optional dictionary with additional volumetric data that shall be stored
as feature attributes in the dataset. The dictionary key serves as the
feature attribute name. Each value might be of any type supported by the
'mask' argument of this function
so you could point to any ROI masks/index volumes and get them assigned to a .fa
$> python -c 'import mvpa2.suite as mv ; print(mv.fmri_dataset("mvpa2/data/haxby2001/sub001/BOLD/task001_run001/bold_25mm.nii.gz", add_fa={a: "mvpa2/data/haxby2001/sub001/masks/25mm/%s.nii.gz" % a for a in ["brain", "gray", "vt"]}))'
<Dataset: 121x600 at int16, <sa: time_coords,time_indices>, <fa: brain,gray,voxel_indices,vt>, <a: imgaffine,imghdr,imgtype,mapper,voxel_dim,voxel_eldim>>
--
Yaroslav O. Halchenko
Center for Open Neuroscience http://centerforopenneuroscience.org
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