<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Nick:<div> </div><div>Thanks very much for your helpful reply; the operations I wanted to do were of the first type (e.g. shuffling samples of a particular target and chunk type) and all is working now (using the indices).</div><div><br></div><div>Cheers,</div><div><br></div><div>Regina</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Sat, 9 Sep 2017 14:03:55 +0200<br>
From: Nick Oosterhof <<a href="mailto:n.n.oosterhof@googlemail.com">n.n.oosterhof@googlemail.com</a>><br>
To: Development and support of PyMVPA<br>
        <<a href="mailto:pkg-exppsy-pymvpa@lists.alioth.debian.org">pkg-exppsy-pymvpa@lists.<wbr>alioth.debian.org</a>><br>
Subject: Re: [pymvpa] additional data shuffling/cleaning after loading<br>
        up data using fmri_dataset<br>
Message-ID: <<a href="mailto:5FFA9939-0D8B-4534-AC63-01EBCB47F06D@googlemail.com">5FFA9939-0D8B-4534-AC63-<wbr>01EBCB47F06D@googlemail.com</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
> On 9 Sep 2017, at 06:28, Regina Lapate <<a href="mailto:lapate@gmail.com">lapate@gmail.com</a>> wrote:<br>
><br>
> --Can one do regular python operations such as shuffling trials (or excluding trials with extreme outlier values) after loading up a dataset (nifti & targets) using mvpa2.datasets.mri.fmri_<wbr>dataset?<br>
><br>
> I assumed so, but upon trying to shuffle trials of a given condition using numpy:<br>
> np.random.shuffle(ds[ds.<wbr>targets==1])<br>
<br>
Shuffling can mean at least two things in this context:<br>
<br>
1) randomly re-order the order of the samples and the associated sample attributes; this can be achieved by simple indexing. For example, if a dataset ds has 4 samples, then ds[[3,2,1,0]]  would reverse the order of the samples and the associated sample attributes in .sa. Also, ds[[0,2]] would select the first and third sample.<br>
2) randomly change condition labels (targets), for example to generate a null distribution. AttributePermutator in mvpa2.generators.permutation may be helpful for this.<br>
<br>
Which one applies to your question?<br>
<br>
For the second option: My personal preferred strategy would be to split the dataset by unique chunks, then randomly re-assign targets for each sub-dataset, and then stack these sub-datasets back into a big dataset. This seems better than the 'simple' strategy - at least in an fMRI context - because that can break independence assumptions.<br>
However I did not find this option available (using strategy='chunks' gave an error). Maybe I missed it - or if not, we may consider adding it.<br>
<br>
<br>
<br><br>
******************************<wbr>*******************<br>
</blockquote></div><br></div></div>