<div dir="ltr"><div>I wanted to do the same and had to make some changes to PyMVPA here:<br><a href="https://github.com/bpinsard/PyMVPA/tree/gnbsearchlight_confusiontable">https://github.com/bpinsard/PyMVPA/tree/gnbsearchlight_confusiontable</a><br></div><div>using it with:<br>errorfx = ConfusionMatrix(labels=ds.uniquetargets)<br>slght = GNBSearchlight(clf, prtnr, qe, errorfx=errorfx)<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 28, 2015 at 2:23 PM, marco tettamanti <span dir="ltr"><<a href="mailto:mrctttmnt@gmail.com" target="_blank">mrctttmnt@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 bgcolor="#FFFFFF" text="#000000">
<font size="-1"><font face="Arial">Thanks again!<br>
I am on Debian testing (well, reverted on stable now, because of
troubles with gcc5) and have version 2.3.1.<br>
I will give a try to the one from git.<br>
Best,<br>
Marco<br>
<br>
<br>
PyMVPA:<br>
Version: 2.3.1<br>
Hash: d1da5a749dc9cc606bd7f425d93d25464bf43454<br>
Path:
/usr/lib/python2.7/dist-packages/mvpa2/__init__.pyc<br>
Version control (GIT):<br>
GIT information could not be obtained due <br>
"/usr/lib/python2.7/dist-packages/mvpa2/.. is not under GIT"<br>
SYSTEM:<br>
OS: posix Linux 4.1.0-1-amd64 #1 SMP Debian 4.1.3-1
(2015-08-03)<br>
Distribution: debian/stretch/sid<br>
</font></font><br>
<br>
<blockquote type="cite"><span class=""><b>Yaroslav Halchenko</b> <a href="mailto:pkg-exppsy-pymvpa%40lists.alioth.debian.org?Subject=Re%3A%20%5Bpymvpa%5D%20Confusion%20Matrix%20for%20each%20Node%20with%0A%20sphere_gnbsearchlight&In-Reply-To=%3C20150828161509.GS19455%40onerussian.com%3E" title="[pymvpa] Confusion Matrix for each Node with
sphere_gnbsearchlight" target="_blank">debian at onerussian.com </a><br>
</span><i>Fri Aug 28 16:15:09 UTC 2015</i>
<hr>
<pre><span class="">On Fri, 28 Aug 2015, marco tettamanti wrote:
><i> Dear Yaroslav,
</i>><i> thank you very much for your reply. I have made several attempts, trying
</i>><i> to guess a solution, but it seems I always get a
</i>><i> 'TypeError: 'NoneType' object is not callable'.
</i></span>
oh shoot... forgotten that this one was implemented after the last 2.4.0
release: in upstream/2.4.0-34-g55e147e this June... we should release I
guess. what system are you on and what version of pymvpa currently?
if you could use/try the one from git directly... ?
><i> Case 1:
</i><span class="">><i> slght = sphere_gnbsearchlight(clf, partitioner, radius=slradius,
</i>><i> space='voxel_indices', errorfx=None, postproc=mean_sample())
</i></span>
not the problem here BUT there should be no mean_sample() if errorfx is
None -- you wouldn't want to average labels ;)
--
Yaroslav O. Halchenko, Ph.D.
<span class=""><a href="http://neuro.debian.net" target="_blank">http://neuro.debian.net</a> <a href="http://www.pymvpa.org" target="_blank">http://www.pymvpa.org</a> <a href="http://www.fail2ban.org" target="_blank">http://www.fail2ban.org</a>
Research Scientist, Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: <a href="tel:%2B1%20%28603%29%20646-9834" value="+16036469834" target="_blank">+1 (603) 646-9834</a> Fax: <a href="tel:%2B1%20%28603%29%20646-1419" value="+16036461419" target="_blank">+1 (603) 646-1419</a>
WWW: <a href="http://www.linkedin.com/in/yarik" target="_blank">http://www.linkedin.com/in/yarik</a>
</span></pre>
</blockquote><div><div class="h5">
<br>
<br>
<br>
<div>On 08/28/2015 05:28 PM, marco
tettamanti wrote:<br>
</div>
<blockquote type="cite">
Dear Yaroslav,<br>
thank you very much for your reply. I have made several attempts,
trying to guess a solution, but it seems I always get a<br>
'TypeError: 'NoneType' object is not callable'.<br>
<br>
Any further advice is greatly appreciated!<br>
Best,<br>
Marco<br>
<br>
<br>
Case 1:<br>
slght = sphere_gnbsearchlight(clf, partitioner, radius=slradius,
space='voxel_indices', errorfx=None, postproc=mean_sample())<br>
slght_map = slght(fds)<br>
<br>
<blockquote>In [70]: slght = sphere_gnbsearchlight(clf,
partitioner, radius=slradius, space='voxel_indices',
errorfx=None, postproc=mean_sample())<br>
<br>
In [71]: slght_map = slght(fds)<br>
[SLC] DBG: Phase 1. Initializing partitions using
<NFoldPartitioner> on <Dataset: 108x111@float32,
<sa: chunks,targets,time_coords,time_indices>, <fa:
voxel_indices>, <a:
imgaffine,imghdr,imgtype,mapper,voxel_dim,voxel_eldim>><br>
[SLC] DBG: Phase 2. Blocking data for 18 splits and
3 labels<br>
[SLC] DBG: Phase 3. Computing statistics for 54
blocks<br>
[SLC] DBG: Phase 4. Deducing neighbors information
for 111 ROIs<br>
[SLC] DBG: Phase 4b. Converting neighbors to sparse
matrix representation<br>
[SLC] DBG: Phase 5. Major loop<br>
[SLC] DBG: Split 0 out of 18<br>
[SLC] DBG: 'Training' is done<br>
[SLC] DBG: Doing 'Searchlight'<br>
[SLC] DBG: Assessing accuracies<br>
---------------------------------------------------------------------------<br>
TypeError Traceback (most recent
call last)<br>
<ipython-input-71-1146d298ca06> in <module>()<br>
----> 1 slght_map = slght(fds)<br>
<br>
/usr/lib/python2.7/dist-packages/mvpa2/base/learner.pyc in
__call__(self, ds)<br>
257 "used and auto
training is disabled."<br>
258 % str(self))<br>
--> 259 return super(Learner, self).__call__(ds)<br>
260 <br>
261 <br>
<br>
/usr/lib/python2.7/dist-packages/mvpa2/base/node.pyc in
__call__(self, ds)<br>
119 <br>
120 self._precall(ds)<br>
--> 121 result = self._call(ds)<br>
122 result = self._postcall(ds, result)<br>
123 <br>
<br>
/usr/lib/python2.7/dist-packages/mvpa2/measures/searchlight.pyc
in _call(self, dataset)<br>
141 <br>
142 # pass to subclass<br>
--> 143 results = self._sl_call(dataset, roi_ids,
nproc)<br>
144 <br>
145 if 'mapper' in dataset.a:<br>
<br>
/usr/lib/python2.7/dist-packages/mvpa2/measures/adhocsearchlightbase.pyc
in _sl_call(self, dataset, roi_ids, nproc)<br>
513 # error functions without a chance to
screw up<br>
514 for i, fpredictions in
enumerate(predictions.T):<br>
--> 515 results[isplit, i] =
errorfx(fpredictions, targets)<br>
516 <br>
517 <br>
<br>
TypeError: 'NoneType' object is not callable<br>
</blockquote>
<br>
<br>
<br>
Similarly for other cases and combinations of them:<br>
<br>
Case 2:<br>
slght = sphere_gnbsearchlight(clf, partitioner, radius=slradius,
space='voxel_indices', errorfx=ConfusionMatrixError(),
postproc=mean_sample())<br>
slght_map = slght(fds)<br>
<br>
<br>
Case3:<br>
class KeepConfusionMatrix(Node):<br>
def _call(self, fds):<br>
out = np.zeros(1, dtype=object)<br>
out[0] = (fds.samples)<br>
return out<br>
<br>
slght = sphere_gnbsearchlight(clf, partitioner, errorfx=None,
radius=slradius, space='voxel_indices',
postproc=ChainNode([Confusion(labels=fds.UT)]))<br>
slght.postproc.append(KeepConfusionMatrix())<br>
slght_map = slght(fds)<br>
<br>
<br>
Case4:<br>
class KeepConfusionMatrix(Node):<br>
def _call(self, fds):<br>
out = np.zeros(1, dtype=object)<br>
out[0] = (fds.samples)<br>
return out<br>
<br>
slght = sphere_gnbsearchlight(clf, partitioner, errorfx=None,
radius=slradius, space='voxel_indices',
postproc=ChainNode([mean_sample(),Confusion(labels=fds.UT)]))<br>
slght.postproc.append(KeepConfusionMatrix())<br>
slght_map = slght(fds)<br>
<br>
<br>
<br>
Case5:<br>
class KeepConfusionMatrix(Node):<br>
def _call(self, fds):<br>
out = np.zeros(1, dtype=object)<br>
out[0] = (fds.samples)<br>
return out<br>
<br>
slght = sphere_gnbsearchlight(clf, partitioner,
errorfx=ConfusionMatrixError(), radius=slradius,
space='voxel_indices',
postproc=ChainNode([mean_sample(),Confusion(labels=fds.UT)]))<br>
slght.postproc.append(KeepConfusionMatrix())<br>
slght_map = slght(fds)<br>
<br>
<br>
<br>
<blockquote type="cite">Yaroslav Halchenko debian at
<a href="http://onerussian.com" target="_blank">onerussian.com</a><br>
Fri Aug 28 13:16:38 UTC 2015<br>
<pre>quick an possible partial reply
1. "not sure" -- if it pukes then probably not, although judging from
the code I foresaw arbitrary shape of the errorfx output
2. but you could make sphere_gnbsearchlight to return labels (not
errors) and then post-process to get those confusion matrices. Just
specify errorfx=None to it (not to CV). But you could also try
passing errorfx=ConfusionMatrixError and see how that goes
Please share what you discover/end up with.
mvpa2/tests/test_usecases.py has more of usecase demos for gnb
searchlights which might come handy
--
Yaroslav O. Halchenko, Ph.D.
<a href="http://neuro.debian.net" target="_blank">http://neuro.debian.net</a> <a href="http://www.pymvpa.org" target="_blank">http://www.pymvpa.org</a> <a href="http://www.fail2ban.org" target="_blank">http://www.fail2ban.org</a>
Research Scientist, Psychological and Brain Sciences Dept.
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: <a href="tel:%2B1%20%28603%29%20646-9834" value="+16036469834" target="_blank">+1 (603) 646-9834</a> Fax: <a href="tel:%2B1%20%28603%29%20646-1419" value="+16036461419" target="_blank">+1 (603) 646-1419</a>
WWW: <a href="http://www.linkedin.com/in/yarik" target="_blank">http://www.linkedin.com/in/yarik</a>
</pre>
</blockquote>
<br>
<div>On 08/28/2015 01:48 PM, marco
tettamanti wrote:<br>
</div>
<blockquote type="cite">
<font size="-1"><font face="Arial">Dear all,<br>
is it possible to obtain confusion matrices for all nodes
with "sphere_gnbsearchlight", as was suggested before with
"sphere_searchlight":<br>
<br>
slcvte = CrossValidation(clf, partitioner, errorfx=None,
postproc=ChainNode([Confusion(labels=fds.UT)]))<br>
class KeepConfusionMatrix(Node):<br>
def _call(self, fds):<br>
out = np.zeros(1, dtype=object)<br>
out[0] = (fds.samples)<br>
return out<br>
<br>
slcvte.postproc.append(KeepConfusionMatrix())<br>
slght = sphere_searchlight(slcvte, radius=slradius,
space='voxel_indices', nproc=4, postproc=mean_sample())<br>
slght_map = slght(fds)<br>
<br>
<br>
Thank you and best wishes,<br>
Marco<br>
</font></font>
<pre cols="80">--
Marco Tettamanti, Ph.D.
Nuclear Medicine Department & Division of Neuroscience
San Raffaele Scientific Institute
Via Olgettina 58
I-20132 Milano, Italy
Phone <a href="tel:%2B%2B39-02-26434888" value="+390226434888" target="_blank">++39-02-26434888</a>
Fax <a href="tel:%2B%2B39-02-26434892" value="+390226434892" target="_blank">++39-02-26434892</a>
Email: <a href="mailto:tettamanti.marco@hsr.it" target="_blank">tettamanti.marco@hsr.it</a>
Skype: mtettamanti</pre>
</blockquote>
<br>
</blockquote>
<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" rel="noreferrer" 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 class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><font size="1">Basile Pinsard<br></font></div><i><font size="1">PhD candidate, <br></font></i></div><font size="1">Laboratoire d'Imagerie Biomédicale, UMR S 1146 / UMR 7371, Sorbonne Universités, UPMC, INSERM, CNRS</font><br><font size="1"><span><span style="color:#333333"><span style="font-family:Arial,serif"><span lang="en-GB"><em>Brain-Cognition-Behaviour Doctoral School </em></span></span></span><span style="color:#333333"><span style="font-family:Arial,serif"><span lang="en-GB"><strong>, </strong>ED3C<strong>, </strong>UPMC, Sorbonne Universités<br>Biomedical Sciences Doctoral School, Faculty of Medicine, Université de Montréal <br></span></span></span></span></font><font size="1">CRIUGM, Université de Montréal</font><br></div></div></div></div>
</div>