[scikit-learn] using a mask for brain images

Alle Meije Wink a.m.wink at gmail.com
Thu May 4 11:52:27 EDT 2017


I have a script to classify MRI perfusion maps from healthy subjects and
patients. For the file IO and the classifier I have started with the
example code in Abraham et al 2014 [https://arxiv.org/pdf/1412.3919.pdf].

I use the same classifier as in the paper to produce a back-projected map
of classification weights, which I then want to 'unmask' like in the paper:

    coef=clf.coef_
    coef=featureselection.inverse_transform(coef)

and

    map_name='weights_check.nii.gz'
    wmap=np.zeros(mask.shape, dtype=X.dtype)
    wmap[mask]=coef
    img=nb.Nifti1Image(wmap,np.eye(4))
    img.to_filename(map_name)

But the line "wmap[mask]=coef" throws an error "ValueError: boolean index
array should have 1 dimension". I tried the example code from the paper and
that works.

Is the 'coef' array of back-projected SVM weights in some way different
than the masked input image? Or am I doing something else wrong? The error
suggests that the mask array is the problem.

The complete script is attached.

Many thanks for your help!
Alle Meije
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170504/2a49ccb5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mr_class.py
Type: text/x-python
Size: 3442 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170504/2a49ccb5/attachment-0001.py>


More information about the scikit-learn mailing list