<p>Hi Nick,</p><p>Thank you very much for your reply!</p><p>I typed print clf.mapper.slicearg and it returned something like [300, 301,...]. </p><p>However, I still don't know how to export features from PyMVPA (sorry I'm not very familiar with PyMVPA). I'd like to see which brain regions were selected. And maybe i shouldn't combine crossvalidation with feature select and use the selected voxels as a mask.</p><p>Any suggestions?</p><p>Best,</p><p>Bin Liu</p><p><br></p><div id="origbody"><div style="background: #f2f2f2;">----- 原始邮件 -----<br>发件人:Nick Oosterhof <n.n.oosterhof@googlemail.com><br>收件人:ibinliu@sina.com, Development and support of PyMVPA <pkg-exppsy-pymvpa@lists.alioth.debian.org><br>主题:Re: [pymvpa] How could I know which features were selected by feature selection?<br>日期:2016年04月19日 16点51分<br></div><br><br>> On 19 Apr 2016, at 09:31, <ibinliu@sina.com> <ibinliu@sina.com> wrote:<br>> <br>> Hi all,<br>> <br>> I performed feature selection using anova and wanted the features back to NIfTI. I used the following comment lines but encountered an error:<br>> <br>> <br>> <br>> clf = LinearCSVMC()<br>> <br>> fsel = SensitivityBasedFeatureSelection(OneWayAnova(),<br>> <br>>                                         FixedNElementTailSelector(2000, mode='select', tail='upper'))<br>> <br>> <br>> <br>> fclf = FeatureSelectionClassifier(clf, fsel)<br>> <br>> <br>> <br>> cvte = CrossValidation(fclf, NFoldPartitioner(),<br>> <br>>                        errorfx=lambda p, t: np.mean(p == t),<br>> <br>>                        enable_ca=['stats'])<br>> <br>> cv_results = cvte(ds)<br>> <br>> <br>> <br>> final_dataset = fclf.mapper.forward(ds)<br>> <br>> <br>> <br>> print final_dataset<br>> <br>> <Dataset: 128x2000@float32, <sa: chunks,targets,time_coords,time_indices>, <fa: voxel_indices>, <a: imgaffine,imghdr,imgtype,mapper,voxel_dim,voxel_eldim>><br>> <br>> <br>> <br>> nimg = map2nifti(final_dataset)<br>> <br>> nimg.to_filename('features.nii')<br>> <br>> ValueError: array is not broadcastable to correct shape<br>> <br>> <br>> <br>> Has anyone else had the same errors before?<br>According to the FAQ [1] it would seem that the clf.mapper.slicearg contains which features were selected. <br>It seems you are doing crossvalidation combined with feature selection, which means that for every fold a different subset of features may be selected for training the classifier. As such, you cannot directly convert which features were selected to a nifti volume - except, if you compute a separate volume for each fold.<br>[1] http://www.pymvpa.org/faq.html#how-do-i-know-which-features-were-finally-selected-by-a-classifier-doing-feature-selection<br></div>