<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:large;color:rgb(0,0,0)">Hi, I keep plugging away with this pretty basic classification <br>to recap the inputs are  FEAT parameter estimates for each subject (N=19) for each of two conditions (the key classification targets) and across 2 cognitive tasks- the idea is train the classifier in task 1 and the test it in task 2.<br>

<br><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:large;color:rgb(0,0,0)">I run a whole-brain classification using SVM i.e.<br><br><p style="margin:0px;text-indent:0px">>ds = fmri_dataset(samples=os.path.join(datapath1, 'data.nii.gz'),</p>


<p style="margin:0px;text-indent:0px">                  targets=attr.targets, chunks=attr.chunks,</p>
<p style="margin:0px;text-indent:0px">                  mask=os.path.join(datapath1, 'mask.nii.gz')) </p> <p style="margin:0px;text-indent:0px">>zscore(ds, chunks_attr='task')</p>
<br>
<p style="margin:0px;text-indent:0px">>clf=LinearCSVMC()</p>

<p>>partitioner=HalfPartitioner(count=2, selection_strategy='first', attr='task')</p><p style="margin:0px;text-indent:0px"></p><p style="margin:0px;text-indent:0px">>cv=CrossValidation(clf, partitioner) <br>
</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">>res=cv(ds)</p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">Here I get a whole-brain classification accuracy of around 68%</p><p style="margin:0px;text-indent:0px">

(though did not assess significance)<br></p><p style="margin:0px;text-indent:0px">Then I run a searchlight analyses and looking at the classification accuracy maps it appears like a chance distribution with mean 50% and the max classification accuracy</p>
<p style="margin:0px;text-indent:0px">around 56%- I wonder how it be that none of the searchlights reaches the level of wholebrain classification ? and if this is the case then can it be the wholebrain classification meaningful at all?<br>
</p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">The same pattern emerges with searchlight spheres of 0 1 2 and 3 radius.</p><p style="margin:0px;text-indent:0px">Below is the example searchlight code that I use</p>
<p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">>ds = fmri_dataset(samples=os.path.join(datapath1, 'data.nii.gz'),</p>
<p style="margin:0px;text-indent:0px">                  targets=attr.targets, chunks=attr.chunks,</p>
<p style="margin:0px;text-indent:0px">                  mask=os.path.join(datapath1, 'mask.nii.gz'),<br></p>
<p style="margin:0px;text-indent:0px">                  add_fa={'unmbral_glm': os.path.join(datapath1, 'mask.nii.gz')})</p>  <br><p style="margin:0px;text-indent:0px">>zscore(ds, chunks_attr='task')</p>

<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">> clf=LinearCSVMC()</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">> partitioner=HalfPartitioner(count=2, selection_strategy='first', attr='task')</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">> cv=CrossValidation(clf, partitioner)</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">>center_ids = ds.fa.unmbral_glm.nonzero()[0]</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">>sl=sphere_searchlight(cv, radius=3, space='voxel_indices', center_ids=center_ids, postproc=mean_sample(), nproc=16)</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">> res=sl(ds) </p><p style="margin:0px;text-indent:0px"><br></p><p style="margin:0px;text-indent:0px">cheers</p><p style="margin:0px;text-indent:0px">david<br></p></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jul 16, 2014 at 4:24 AM, Hanson, Gavin Keith <span dir="ltr"><<a href="mailto:ghanson0@ku.edu" target="_blank">ghanson0@ku.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div style="word-wrap:break-word">
<div>I don’t think your rig, as it’s set up, will do what you want.</div>
<div>I attempted to do something similar in my own work, and I think I have a solution for you.</div>
<div><br>
</div>
<div>First, merge your two tasks together into 1 bold image</div>
<div>fslmerge -t bold_taska.nii.gz bold_taskb.nii.gz bold_taskab.nii.gz</div>
<div>Also double up your attr.txt, so it corresponds to the new double-length bold image</div>
<div>Now you have a dataset with shape (608, whatever) </div>
<div>ds=fmri_dataset(samples=‘bold_taskab.nii.gz’, targets=attr.targets, chunks=attr.chunks, mask=‘mask.nii.gz’)</div>
<div>now, do this:</div>
<div><br>
</div>
<div><a href="http://ds.sa" target="_blank">ds.sa</a>[‘task’]=np.repeat([‘A’,’B’], 304)</div>
<div><br>
</div>
<div>which will label the first half of your data as “A” and the second half as “B"</div>
<div><br>
</div>
<div>Now zscore, making sure you’re conscious of your task assignment</div>
<div>zscore(ds, chunks_attr=‘task’)</div>
<div><br>
</div>
<div>Now set up the SL</div>
<div>clf=LinearCSVMC()</div>
<div>partitioner=HalfPartitioner(count=2, selection_strategy=‘first’, attr=‘task’)</div>
<div>cv=CrossValidation(clf, partitioner)</div>
<div>sl=sphere_searchlight(cv, radius=3, postproc=mean_sample(), nproc=16)</div>
<div>res=sl(ds)</div>
<div><br>
</div>
<div>The HalfPartitioner as its set up will split you data into 2 chunks based on your new ‘task’ attribute. It’ll train on task A and test on task B, then visa versa. Usually you want the average errors of that, but if you’re really set on just training on
 A and testing on B, then omit the postproc=mean_sample() bit, and you’ll get per-fold error in the res dataset, and you can find the fold corresponding to what you want.</div>
<div>Anyway, hope that helps.</div>
<div>- Gavin</div>
<div><br>
</div>
<div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div>
<div>Gavin Hanson, B.S.<br>
Research Assistant<br>
Department of Psychology<br>
University of Kansas<br>
1415 Jayhawk Blvd., 426 Fraser Hall <br>
Lawrence, KS 66045</div><div><div class="h5">
<br>
<div>
<div>On Jul 15, 2014, at 6:11 PM, David Soto <<a href="mailto:d.soto.b@gmail.com" target="_blank">d.soto.b@gmail.com</a>> wrote:</div>
<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
Hi, I hope you have enjoyed the worldcup :)<br>
<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
I am trying a searchlight pipeline for the first time now,  it has been running<br>
for some 6-8 hours and remains on with little RAM and CPU used . To recapitulate, I am training a SVM on FSL copes from task A<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
regarding classes X & Y and then testing the model on FSL copes from task B regarding the same classes.</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
The shape of training and testing datasets is  (304, 902629)<br>
<br>
My searchlight pipeline is the following, would you please let me know if this is OK?<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
cheers,<br>
ds<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
<br>
<div style="margin:0px;text-indent:0px">from mvpa2.suite import * </div>
<div style="margin:0px;text-indent:0px">datapath1='/home/dsoto/Documents/fmri/rawprepro_wmintrosp'</div>
<div style="margin:0px;text-indent:0px">attr = SampleAttributes(os.path.join(datapath1, 'attr.txt'))</div>
<div style="margin:0px;text-indent:0px">ds = fmri_dataset(samples=os.path.join(datapath1, 'bold_taska.nii.gz'),</div>
<div style="margin:0px;text-indent:0px">targets=attr.targets, chunks=attr.chunks)</div>
<p style="margin:0px;text-indent:0px"></p>
<div style="margin:0px;text-indent:0px">ts = fmri_dataset(samples=os.path.join(datapath1, 'bold_taskb.nii.gz'),</div>
<div style="margin:0px;text-indent:0px">targets=attr.targets, chunks=attr.chunks)</div>
<br>
<div style="margin:0px;text-indent:0px">zscore(ds)</div>
<div style="margin:0px;text-indent:0px">zscore(ts)<br>
</div>
<div style="margin:0px;text-indent:0px"><br>
</div>
<div style="margin:0px;text-indent:0px">clf= LinearCSVMC()</div>
<div style="margin:0px;text-indent:0px">clf.train(ds)</div>
<div style="margin:0px;text-indent:0px">predictions = clf.predict(ts.samples)</div>
<div style="margin:0px;text-indent:0px">#validation= np.mean(predictions== ts.sa.targets)</div>
<div style="margin:0px;text-indent:0px">sl = sphere_searchlight(predictions, radius=3, space='voxel_indices',
</div>
<div style="margin:0px;text-indent:0px">postproc=mean_sample())</div>
<div style="margin:0px;text-indent:0px">sl_map = sl(ds)</div>
<div style="margin:0px;text-indent:0px"><br>
</div>
<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
the ipython gui currently says<br>
<b><br>
[SLC] DBG:                            Starting off 4 child processes for nblocks=4<br>
</b><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Fri, Jul 4, 2014 at 2:44 PM, David Soto <span dir="ltr">
<<a href="mailto:d.soto.b@gmail.com" target="_blank">d.soto.b@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
great thanks!<br>
<br>
</div>
<div class="gmail_default" style="font-family:georgia,serif;font-size:large">
best of luck in the semifinals!<br>
<br>
cheers<br>
ds<br>
</div>
</div>
<div class="gmail_extra">
<div>
<div><br>
<br>
<div class="gmail_quote">On Fri, Jul 4, 2014 at 2:33 PM, Michael Hanke <span dir="ltr">
<<a href="mailto:mih@debian.org" target="_blank">mih@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<div><br>
On Tue, Jul 01, 2014 at 12:25:40AM +0100, David Soto wrote:<br>
> Hi Michael, indeed ..well done for germany today! :).<br>
> Thanks for the reply and the suggestion on KNN<br>
> I should have been  more clear that for each subject I have the<br>
</div>
> following *block<br>
> *sequences<br>
<div>> ababbaabbaabbaba in TASK 1<br>
> ababbaabbaabbaba in TASK 2<br>
><br>
> this explains that I have  8 a-betas and 8 b-betas for each task<br>
> AND for each subject..so if i concatenate & normalize all the beta data<br>
> across subjects I will have 8 x 19 (subjects)= 152 beta images for class a<br>
> and the same for class b<br>
<br>
</div>
Ah, I guess you model each task with two regressors (hrf + derivative?).<br>
You can also use a basis function set and get even more betas...<br>
<div>><br>
> then could I use SVM searchlight trained to discriminate a from b in  task1<br>
> betas and tested in the task2 betas?<br>
<br>
</div>
yes, no problem.<br>
<br>
Cheers,<br>
<br>
Michael<br>
<br>
PS: Off to enjoy the quarter finals ... ;-)<br>
<span><font color="#888888"><br>
<br>
--<br>
Michael Hanke<br>
<a href="http://mih.voxindeserto.de/" target="_blank">http://mih.voxindeserto.de</a><br>
<br>
_______________________________________________<br>
Pkg-ExpPsy-PyMVPA mailing list<br>
<a href="mailto:Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org" target="_blank">Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa</a><br>
</font></span></blockquote>
</div>
<br>
<br clear="all">
<br>
</div>
</div>
<span><font color="#888888">-- <br>
<div dir="ltr"><a href="http://www1.imperial.ac.uk/medicine/people/d.soto/" style="color:rgb(17,85,204)" target="_blank">http://www1.imperial.ac.uk/medicine/people/d.soto/</a><br>
</div>
</font></span></div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div dir="ltr"><a href="http://www1.imperial.ac.uk/medicine/people/d.soto/" style="color:rgb(17,85,204)" target="_blank">http://www1.imperial.ac.uk/medicine/people/d.soto/</a><br>
</div>
</div>
_______________________________________________<br>
Pkg-ExpPsy-PyMVPA mailing list<br>
<a href="mailto:Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org" target="_blank">Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa</a></blockquote>
</div>
<br>
</div></div></div>

<br>_______________________________________________<br>
Pkg-ExpPsy-PyMVPA mailing list<br>
<a href="mailto:Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org">Pkg-ExpPsy-PyMVPA@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa</a><br></blockquote></div><br><br clear="all">
<br>-- <br><div dir="ltr"><a href="http://www1.imperial.ac.uk/medicine/people/d.soto/" style="color:rgb(17,85,204)" target="_blank">http://www1.imperial.ac.uk/medicine/people/d.soto/</a><br></div>
</div>