API Reference

neuropredict (designed with the goal of not needing the user to code) is designed primarily be working on the command line. Hence, it is recommended to follow Usage, although you can peek into its internal API and provide us with any feedback you may have.

visualize.feature_importance_map(feat_imp, method_labels, base_output_path, feature_names=None, show_distr=False, plot_title='feature importance', show_all=False)[source]

Generates a map/barplot of feature importance.

feat_imp must be a list of length num_datasets,

each an ndarray of size [num_repetitions,num_features[idx]] where num_features[idx] refers to the dimensionality of n-th dataset.

metho_names must be a list of strings of the same length as feat_imp. feature_names must be a list (of ndarrays of strings) same size as feat_imp,

each element being another list of labels corresponding to num_features[idx].

Parameters
feat_implist

List of numpy arrays, each of length num_features

method_labelslist

List of names for each method (or feature set).

base_output_pathstr
feature_nameslist

List of names for each feature.

show_distrbool

plots the distribution (over different trials of cross-validation) of feature importance for each feature.

plot_titlestr

Title of the importance map figure.

show_allbool

If true, this will attempt to show the importance values for all the features. Be advised if you have more than 50 features, the figure would illegible. The default is to show only few important features (ranked by their median importance), when there is more than 25 features.

visualize.confusion_matrices(cfmat_array, class_labels, method_names, base_output_path, cmap='cividis')[source]

Display routine for the confusion matrix. Entries in confusin matrix can be turned into percentages with display_perc=True.

Use a separate method to iteratve over multiple datasets. confusion_matrix dime: [num_repetitions, num_classes, num_classes, num_datasets]

Parameters
cfmat_array
class_labels
method_names
base_output_path
cmap
visualize.freq_hist_misclassifications(num_times_misclfd, num_times_tested, method_labels, outpath, separate_plots=False)[source]

Summary of most/least frequently misclassified subjects for further analysis

visualize.compare_distributions(metric, labels, output_path, y_label='metric', horiz_line_loc=None, horiz_line_label=None, upper_lim_y=1.01, lower_lim_y=-0.01, ytick_step=None)[source]

Distribution plots of various metrics such as balanced accuracy!

metric is expected to be ndarray of size [num_repetitions, num_datasets]

upper_lim_y = None would make it automatic and adapt to given metric distribution upper_lim_y = 1.01 and ytick_step = 0.05 are targeted for Accuracy/AUC metrics,

in classification applications

visualize.compare_misclf_pairwise_parallel_coord_plot(cfmat_array, class_labels, method_labels, out_path)[source]

Produces a parallel coordinate plot (unravelling the cobweb plot) comparing the the misclassfication rate of all feature sets for different pairwise classifications.

Parameters
cfmat_array
class_labels
method_labels
out_path
visualize.compare_misclf_pairwise(cfmat_array, class_labels, method_labels, out_path)[source]

Produces a cobweb plot comparing the the misclassfication rate of all feature sets for different pairwise classifications.

Parameters
cfmat_array
class_labels
method_labels
out_path
compare.check_if_better(rank_one, rank_two, critical_dist)[source]

Checks whether rank1 is greater than rank2 by at least critical dist

compare.compute_critical_dist(ranks)[source]
compare.pairwise(accuracy_balanced, method_names, out_results_dir, num_repetitions)[source]
Produces a matrix of pair-wise significance tests,

where each cell [i, j] answers the question: is method i significantly better than method j?

The result would be based on a test of choice. The default test would be non-parametric Friedman test.

compare.vertical_nemenyi_plot(data, num_reps, alpha=0.05, cmap=<matplotlib.colors.LinearSegmentedColormap object at 0x1a15ee48d0>)[source]

Vertical Nemenyi plot to compare model ranks and show differences.

freesurfer.aseg_stats_subcortical(fspath, subjid)[source]

Returns all the subcortical volumes found in stats/aseg.stats.

Equivalent of load_fs_segstats.m

freesurfer.aseg_stats_whole_brain(fspath, subjid)[source]

Returns a feature set of whole brain volumes found in Freesurfer output: subid/stats/aseg.stats