[pymvpa] Searchligh SVM on fMRI Beta Values in PyMVPA (Raúl Hernández)

Alireza Karami alireza.kr at gmail.com
Sun May 26 10:21:06 BST 2019


Hi
Thank you for your answer.

>   For sure there is a better approach, but I also had the same issue.
What I
>   ended up doing is pretending that each beta map was a volume of a raw
fMRI
>   acquisition. So I calculated the beta maps and then used the FSL command
>   fslmerge to concatenate every beta map to analyze. Then I put the
resulting
>   4D in a folder following the structure required for PyMVPA and loaded
the
>   file as if it were a raw fMRI. Then proceeded with my searchlight script
>   just skipping the preprocessing.

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/1bdb0b71/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list