[pymvpa] Combine the fMRI data with other data in the pattern analysis?

Nynke van der Laan nynkevanderlaan at gmail.com
Wed Mar 16 13:10:04 UTC 2011


Hello Michael and Yaroslav,

again thanks for the help! Sorry for putting so much workload for you
on the mailinglist but I think that I now managed to implement it in
the right way. See below for the total script (could be useful for
other users with version 0.4 that want to do the same). Would you
please check it if this is indeed what it is doing?

Just to be sure about how and in which sequence this data is handled:
The searchlight first makes a subdataset of an amount of voxels
(features) depending of the chozen sphere size. Is it correct that,
AFTER THAT, the covariate is added as an additional feature? So for
example, you have a sphere of 26 voxels, the covariate is added as an
extra (27th) voxel for in the classification analysis(and thus added
to each sphere). Then I wonder: doesnt' the fact that the covariate
has very different values (i.e., in the range of 1-9 instead of the
much smaller voxel values) complicate the analysis?

Best,
Nynke

code:

class MyMeasure:
	def __init__(self, measure, cov): # This is done when you do
MyMeasure(cv , covariate_ds): the cv is the measure, cov the covariate
		self._msre = measure
		self._cov = cov

	def __call__(self, ds):
		cov_ds = Dataset(samples=N.hstack((ds.samples, self._cov)),
                                   labels = ds.labels, chunks = ds.chunks)
		return self._msre(cov_ds)



covariate = N.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])
# The covariate has 1 value for each of the 38 samples
covariate = covariate.reshape((38,1)) # It is important to reshape in
order to have the same dimensions for the covariate and the ds.
m_nynke = MyMeasure(cv, covariate)
sl = Searchlight(m_nynke, radius=6)
sl_map = sl(dataset)


On Tue, Mar 15, 2011 at 5:33 PM, Nynke van der Laan
<nynkevanderlaan at gmail.com> wrote:
> Dear Michael,
> it still does not work for me (I have version 0.4).
>
> When I do:
> covariate_ds = Dataset([1,2,3,4,5,6,7,8,3,5,4,5,4,4,3,4,5,4,3,4,5,6,7,8,9,7,5,4,5,6,7,8,7,4,3,3,3,4])
> I get the error: AttributeError: 'list' object has no attribute
> 'copy'. Also making a Numpy array of it doesn't seem to help.
>
> But I do I understand correctly from your post that for version 0.4
> covariate_ds = [1,2,3,4,5,6,7,8,3,5,4,5,4,4,3,4,5,4,3,4,5,6,7,8,9,7,5,4,5,6,7,8,7,4,3,3,3,4]
> would also work? (I used that now for the analysis below which
> probably explains the error I get (see below).
>
>
> I have moderated your script a little to the following:
> class MyMeasure:
>        def __init__(self, measure, cov):
>                self._msre = measure
>                self._cov = cov
>
>        def __call__(self, ds):    # was: _call(self, ds) but gives an error:
> MyMeasure instance has no __call__ method
>                cov_ds = mvpa.base.dataset.hstack(ds, cov)
>                return self._msre(cov_ds)
>
> However, now I get the AttributeError: 'module' object has no
> attribute 'dataset' when I use, which probably originates by the fact
> that the covariate_ds I use is just a list. How can I do this in 0.4?
> Did the architecture of the dataset baseclass change in version 0.6 or
> am I doing something wrong?
> cv = CrossValidatedTransferError(
>         TransferError(LinearNuSVMC()),
>         NFoldSplitter())
> m_nynke = MyMeasure(cv, covariate_ds)
> sl = Searchlight(m_nynke, radius=6)
> sl_map = sl(dataset)
>
> Thanks!
>



More information about the Pkg-ExpPsy-PyMVPA mailing list