Giving credit

Previous topic

7.1.4. nilearn.connectome.sym_to_vec

Next topic

7.2.1. nilearn.datasets.fetch_atlas_craddock_2012

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

7.1.5. nilearn.connectome.group_sparse_covariance

nilearn.connectome.group_sparse_covariance(subjects, alpha, max_iter=50, tol=0.001, verbose=0, probe_function=None, precisions_init=None, debug=False)

Compute sparse precision matrices and covariance matrices.

The precision matrices returned by this function are sparse, and share a common sparsity pattern: all have zeros at the same location. This is achieved by simultaneous computation of all precision matrices at the same time.

Running time is linear on max_iter, and number of subjects (len(subjects)), but cubic on number of features (subjects[0].shape[1]).

Parameters:

subjects : list of numpy.ndarray

input subjects. Each subject is a 2D array, whose columns contain signals. Each array shape must be (sample number, feature number). The sample number can vary from subject to subject, but all subjects must have the same number of features (i.e. of columns).

alpha : float

regularization parameter. With normalized covariances matrices and number of samples, sensible values lie in the [0, 1] range(zero is no regularization: output is not sparse)

max_iter : int, optional

maximum number of iterations.

tol : positive float or None, optional

The tolerance to declare convergence: if the duality gap goes below this value, optimization is stopped. If None, no check is performed.

verbose : int, optional

verbosity level. Zero means “no message”.

probe_function : callable or None

This value is called before the first iteration and after each iteration. If it returns True, then optimization is stopped prematurely. The function is given as arguments (in that order):

  • empirical covariances (ndarray),
  • number of samples for each subject (ndarray),
  • regularization parameter (float)
  • maximum iteration number (integer)
  • tolerance (float)
  • current iteration number (integer). -1 means “before first iteration”
  • current value of precisions (ndarray).
  • previous value of precisions (ndarray). None before first iteration.

precisions_init: numpy.ndarray

initial value of the precision matrices. If not provided, a diagonal matrix with the variances of each input signal is used.

debug : bool, optional

if True, perform checks during computation. It can help find numerical problems, but increases computation time a lot.

Returns:

emp_covs : numpy.ndarray, shape (n_features, n_features, n_subjects)

empirical covariances matrices

precisions : numpy.ndarray, shape (n_features, n_features, n_subjects)

estimated precision matrices

Notes

The present algorithm is based on:

Jean Honorio and Dimitris Samaras. “Simultaneous and Group-Sparse Multi-Task Learning of Gaussian Graphical Models”. arXiv:1207.4255 (17 July 2012). http://arxiv.org/abs/1207.4255.