On Thu, 20 Oct 2011, Mike E. Klein wrote:
> Thanks for the quick response. I actually don't know how to crossplot…

should be as easy as

    import pylab as pl # not needed if you did import from mvpa.suite
    pl.plot(np.ravel(s1_map), np.ravel(s2_map), '.')
    pl.show() # your might not even need this one

alternatively -- here is a helper I hacked up/use -- probably should
place it under PyMVPA (see attached) -- just give it two nifti files ;-)

> histrograms are output from MRICron. 

    pl.hist

should become your friend

> I've tried to follow the plotting
> from the searchlight example from the manual, but haven't figured out
> to get my searchlight data in there (from nifti) without running the
> entire multi-hour script first.

just load using fmri_dataset with the original mask ;)

> As far as ds.summary, I've pasted below. It has been run averaged, but
> not detrended or zscored.

if I were you I would have detrended, zscored and only then averaged!

if averaging was done across multiple conditions spread through the
'run' detrending might be detremental

and I think I might know where other catch could be -- if you
zscore such a dataset as you have (2 samples total per chunk) with
zscoring per chunk -- do you know what values would you get? ;)

so -- how was zscoring done?

what about ds.summary() right before you fed it into searchlight?

-- 
=------------------------------------------------------------------=
Keep in touch                                     www.onerussian.com
Yaroslav Halchenko                 www.ohloh.net/accounts/yarikoptic
#!/usr/bin/python
#emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- 
#ex: set sts=4 ts=4 sw=4 noet:
#------------------------- =+- Python script -+= -------------------------
"""
 @file      cross_plot.py
 @date      Thu Jul 14 14:56:33 2011
 @brief


  Yaroslav Halchenko                                            Dartmouth
  web:     http://www.onerussian.com                              College
  e-mail:  [email protected]                              ICQ#: 60653192

 DESCRIPTION (NOTES):

 COPYRIGHT: Yaroslav Halchenko 2011

 LICENSE: MIT

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
"""
#-----------------\____________________________________/------------------

__author__ = 'Yaroslav Halchenko'
__revision__ = '$Revision: $'
__date__ = '$Date:  $'
__copyright__ = 'Copyright (c) 2011 Yaroslav Halchenko'
__license__ = 'MIT'


from mvpa.base import verbose
import sys
import pylab as pl
import nibabel as nb
import numpy as np

files = sys.argv[1:]


assert(len(files) == 2)                 # just 2 files

if files[1].endswith('.nii.gz'):
    niftis = [nb.load(f) for f in files]
    datas = [n.get_data() for n in niftis]
elif files[1].endswith('.hdf5'):
    from mvpa.base.hdf5 import h5load
    datas = [h5load(f).samples for f in files]

data = np.asarray(datas).reshape((2, -1))


nz = (data != 0)
#nz[:, 80000:] = False # for quick testing

nzsum = np.sum(nz, axis=0)

intersection = nzsum == 2
union = nzsum > 0
x, y = datainter = data[:, intersection]
xnoty = (nz[0].astype(int) - nz[1].astype(int))>0
ynotx = (nz[1].astype(int) - nz[0].astype(int))>0

verbose(1, "total: %d union: %d intersection: %d x_only: %d y_only: %d"
        % (len(nzsum), np.sum(union), np.sum(intersection),
           np.sum(xnoty), np.sum(ynotx)))



#fig=pl.figure()
#pl.plot(datainter[0], datainter[1], '.')
#fig.show()

nullfmt   = pl.NullFormatter()         # no labels

# definitions for the axes
left, width = 0.1, 0.65
bottom, height = 0.1, 0.65
bottom_h = left_h = left+width+0.02

rect_scatter = [left, bottom, width, height]
rect_histx = [left, bottom_h, width, 0.2]
rect_histy = [left_h, bottom, 0.2, height]

# start with a rectangular Figure
pl.figure(1, figsize=(10,10))

axScatter = pl.axes(rect_scatter)
axHistx = pl.axes(rect_histx)
axHisty = pl.axes(rect_histy)

# no labels
axHistx.xaxis.set_major_formatter(nullfmt)
axHisty.yaxis.set_major_formatter(nullfmt)

# the scatter plot:
axScatter.scatter(x, y, s=1, facecolors='none') #, '.')

if np.sum(xnoty):
    axScatter.scatter(data[0, np.where(xnoty)[0]],
                      data[1, np.where(xnoty)[0]],
                      s=1, edgecolor='b',facecolors='none')
if np.sum(ynotx):
    axScatter.scatter(data[0, np.where(ynotx)[0]],
                      data[1, np.where(ynotx)[0]],
                      s=1, edgecolor='g',facecolors='none')
# pl.xlabel(files[0])
# pl.ylabel(files[1])

# now determine nice limits by hand:
binwidth = np.max(datainter)/51. # 0.25
xymax = np.max( [np.max(x), np.max(y)] )
xymin = np.min( [np.min(x), np.min(y)] )
xyrange = xymax - xymin
xyamax = np.max( [np.max(np.fabs(x)), np.max(np.fabs(y))] )
limn = -( int(-xymin/binwidth) + 1) * binwidth
limp = ( int(xymax/binwidth) + 1) * binwidth

axScatter.plot((limn*0.9, limp*0.9), (limn*0.9, limp*0.9), 'y--')
axScatter.plot((np.min(x), np.max(x)), (0, 0), 'r', alpha=0.5)
axScatter.plot((0,0), (np.min(y), np.max(y)), 'r', alpha=0.5)

axScatter.set_xlim( (limn, limp) )
axScatter.set_ylim( (limn, limp) )

bins = np.arange(limn, limp + binwidth, binwidth)
histx = axHistx.hist(x, bins=bins, facecolor='b')
histy = axHisty.hist(y, bins=bins, orientation='horizontal', facecolor='g')

axHistx.set_xlim( axScatter.get_xlim() )
axHistx.vlines(0, 0, 0.9*np.max(histx[0]), 'r')

axHisty.set_ylim( axScatter.get_ylim() )
axHisty.hlines(0, 0, 0.9*np.max(histy[0]), 'r')

rect_scatter = [left, bottom, width, height]

abpx = pl.axes( [left, bottom+height * 0.9, width, height/10], axisbg='y' )
abpx.axis('off')
bpx = abpx.boxplot(x, vert=0) #'r', 0)
abpx.set_xlim(axScatter.get_xlim())

abpy = pl.axes( [left + width * 0.9, bottom, width/10, height], axisbg='y' )
abpy.axis('off')
bpy = abpy.boxplot(y, sym='g+')
abpy.set_ylim(axScatter.get_ylim())

pl.show()

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Pkg-ExpPsy-PyMVPA mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-exppsy-pymvpa

Reply via email to