311ac284d99ea7243e0918949f3a499a7a93fab5,examples/decoding/plot_haxby_space_net.py,,,#,14

Before Change


                  title="%s: accuracy %g%%" % (penalty, accuracy),
                  cut_coords=(-34, -16), display_mode="yz")
    coef_img.to_filename("haxby_%s_weights.nii" % penalty)
    print("- %s %s" % (penalty, "-" * 60))
    print("Number of train samples : %i" % condition_mask_train.sum())
    print("Number of test samples  : %i" % condition_mask_test.sum())
    print("Classification accuracy : %g%%" % accuracy)

After Change



// Compute the mean epi to be used for the background of the plotting
from nilearn.image import mean_img
background_img = mean_img(func_filenames)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fit SpaceNet with a Graph-Net penalty
from nilearn.decoding import SpaceNetClassifier

// Fit model on train data and predict on test data
decoder = SpaceNetClassifier(memory="cache", penalty="graph-net")
decoder.fit(X_train, y_train)
y_pred = decoder.predict(X_test)
accuracy = (y_pred == y_test).mean() * 100.
print("Graph-net classification accuracy : %g%%" % accuracy)

// Visualization
from nilearn.plotting import plot_stat_map, show
coef_img = decoder.coef_img_
plot_stat_map(coef_img, background_img,
              title="graph-net: accuracy %g%%" % accuracy,
              cut_coords=(-34, -16), display_mode="yz")

// Save the coefficients to a nifti file
coef_img.to_filename("haxby_graph-net_weights.nii")


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Now Fit SpaceNet with a TV-l1 penalty
decoder = SpaceNetClassifier(memory="cache", penalty="tv-l1")
decoder.fit(X_train, y_train)
y_pred = decoder.predict(X_test)
accuracy = (y_pred == y_test).mean() * 100.
print("TV-l1 classification accuracy : %g%%" % accuracy)

// Visualization
coef_img = decoder.coef_img_
plot_stat_map(coef_img, background_img,
              title="tv-l1: accuracy %g%%" % accuracy,
              cut_coords=(-34, -16), display_mode="yz")

// Save the coefficients to a nifti file
coef_img.to_filename("haxby_tv-l1_weights.nii")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: nilearn/nilearn
Commit Name: 311ac284d99ea7243e0918949f3a499a7a93fab5
Time: 2015-11-29
Author: gael.varoquaux@normalesup.org
File Name: examples/decoding/plot_haxby_space_net.py
Class Name:
Method Name:


Project Name: nilearn/nilearn
Commit Name: a35656d57bb4352639274a41c423607af32a4aeb
Time: 2016-05-22
Author: dkamalakarreddy@gmail.com
File Name: examples/04_manipulating_images/plot_roi_extraction.py
Class Name:
Method Name:


Project Name: nilearn/nilearn
Commit Name: 422881afa09ccd1e5a19ae31a38638e04d6eae7d
Time: 2014-11-24
Author: loic.esteve@ymail.com
File Name: plot_localizer_simple_analysis.py
Class Name:
Method Name: