Nilearn: decoding analysis with 4 classes

Hi everyone,

I started using nilearn for my MVPA analyzes with the function permutation_test_score.

It was working pretty well when using 2 classes, but now I would like to compute a decoding analysis with 4 classes.

However, my first attempt with the same function gives me only one score (e.g., left STS = 63%). Is it possible to obtain the accuracy score (with this function or another) for each of my classes in a given ROI?

Thank you very much,


Ahoi hoi @Mathieu,

without knowing more about your analysis (classifier, CV, etc.), I would suggest
you have a look at this nilearn example on ROI based decoding. It shows you how to set up a decoding analysis within which the predictive ability of ROI specific voxel patterns wrt specific categories is computed.
Instead of obtaining the chance level from a dummy classifier, you could also use the one computed through permutation_test_score.

HTH, cheers, Peer

Thanks Peer,

I will try that!

In the script (see below), I saw that standardizing is important in the NiftiMasker function. Could you please tell me why? I use beta maps from a GLM based on realigned and unwarped EPI (neither normalization , nor smoothing). Do I have to standardize?

For decoding, standardizing is often very important

mask_filename = haxby_dataset[mask_name][0]
masker = NiftiMasker(mask_img=mask_filename, standardize=True)



Hi Mathieu,

Jumping in, standardizing is generally important for many machine learning approaches. You may also see it referred to as “feature scaling.”

One demonstration of why this is important is available here: