[pymvpa] Pkg-ExpPsy-PyMVPA Digest, Vol 18, Issue 10
Johan Carlin
jdc55 at cam.ac.uk
Fri Aug 21 13:34:01 UTC 2009
Hi Yaro,
I should probably have provided more context. :) Sorry about that.
I have a number of coordinates of interest, where I want to plonk down
a spherical ROI. I define my ROI like this:
def make_spherical_ROI(ds,coords,radius=10):
'''Returns a copy of the dataset which is masked to only
include voxels within the sphere defined by coords.'''
coords.reverse() # Pynifti uses ZYX
centre = ds.mapper.getOutId(coords)
feats = ds.mapper.getNeighbors(centre,radius=radius)
roi_ds = ds.copy()
roi_ds = roi_ds.selectFeatures(feats)
return roi_ds
Which seems similar to what you're suggesting. The problem with doing
this on masked data is that you get an error whenever the center
coordinate is outside the mask (even if the sphere contains other
in-mask voxels). To get around this, I make the ROI based on unmasked
data, and then I apply the mask to the ROI dataset.
> also why do you want to invert the mapping with
>
>> lmap = dict(zip(ds.labels_map.values(),ds.labels_map.keys()))
> whenever creating a new dataset? (may be I got confused...)
If you just put in the ds.labels_map as it is, you get something like this:
m_ds = MaskedDataset(samples=ds.samples_original, labels=ds.L,
chunks=ds.C, labels_map=ds.labels_map)
ValueError: Provided labels_map {'212': 5, '211': 4, '121': 2, '122':
3, '111': 0, '112': 1, '222': 7, '221': 6} is insufficient to map all
the labels. Mapping for label 5 is missing
The 3-digit stringed values are my original labels. So it looks like
the ds.labels_map is stored with key=original label, value=mapped
label, but the opposite structure is needed when definining a new
dataset.
> in your code instead of MaskedDataset you could use NiftiDataset where
> samples... but before getting in details lets first figure out if above snippet
> was what you were looking for
That sounds very useful, please tell me more. :)
Cheers,
Johan
More information about the Pkg-ExpPsy-PyMVPA
mailing list