[pymvpa] Searchligh SVM on fMRI Beta Values in PyMVPA (Yaroslav O Halchenko)

Alireza Karami alireza.kr at gmail.com
Sun May 26 10:17:19 BST 2019


Thank you for your answer.

>   you probably never want to do searchlight SVM on truly "raw" data -- at
>   least motion correction etc should be done ;)

Sorry for my mistake. By raw data, I mean preprocessed data, without
smoothing the data.

>   nothing should change for your code -- just load from your .nii.gz with
>   beta values (the same fmri_dataset, can give it a list of filenames with
>   betas), assign targets/chunks, might want to do zscoring or not
>   depending on how many categories and total # of betas etc, and do
>   whatever you were doing on "raw" data.

I have done it! I loaded beta values and did searchlight SVM based on the
example <http://www.pymvpa.org/examples/searchlight.html> on PyMVPA site.
The following is my code:

> from mvpa2.suite import *
>
> if __debug__:
>     debug.active += ["SLC"]
>
> for i in range(1,321):
>     ds = fmri_dataset('beta_0'+str(i)+'.nii','mask.nii')
>     datasets.append(ds)
>
> dataset = vstack(datasets, a=0)
>
> dataset.sa['targets'] = #My Target
> dataset.sa['chunks'] = #My Chunk
>
> fds = dataset.copy(deep=False,
>                 sa=['targets', 'chunks'],
>                 fa=['voxel_indices'],
>                 a=['mapper'])
>
> # choose classifier
> clf = LinearNuSVMC()
>
> # setup measure to be computed by Searchlight
> # cross-validated mean transfer using an N-fold dataset splitter
> cv = CrossValidation(clf, NFoldPartitioner())
>
> # setup plotting parameters (not essential for the analysis itself)
> plot_args = {
>     'background' : os.path.join(highrespath, 'structure.nii'),
>     'overlay_mask' : os.path.join('mask.nii'),
>     'do_stretch_colors' : False,
>     'cmap_bg' : 'gray',
>     'cmap_overlay' : 'autumn', # YlOrRd_r # pl.cm.autumn
>     'interactive' : cfg.getboolean('examples', 'interactive', True),
>     }
>
> for radius in [1, 3]:
>     # tell which one we are doing
>     print "Running searchlight with radius: %i ..." % (radius)
>
> sl = sphere_searchlight(cv, radius=radius, space='voxel_indices',
> postproc=mean_sample())
>
> sl_map = sl(fds)
> sl_map.samples *= -1
> sl_map.samples += 1
>
> niftiresults = map2nifti(sl_map, imghdr=dataset.a.imghdr)
>
> fig = pl.figure(figsize=(12, 4), facecolor='white')
> subfig = plot_lightbox(overlay=niftiresults,
>                         vlim=(0.5, None), slices=range(23,31),
>                         fig=fig, **plot_args)
> pl.title('Accuracy distribution for radius %i' % radius)
>

but when I run my code, I get the following message:

> [SLC] DBG:                        +0:04:48 _______[0%]_______
> -347+16:07:18  ROI 2 (2/208302), 57 features
>

I think it takes time more than usual and I think something is wrong in my
code, but I do not know what is wrong with it.
Would you please help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-exppsy-pymvpa/attachments/20190526/1d740bc0/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list