def subject_connectivity(timeseries, subject, atlas_name, kind, save=True, save_path=root_folder):
    '\n        timeseries   : timeseries table for subject (timepoints x regions)\n        subject      : the subject short ID\n        atlas_name   : name of the atlas used\n        kind         : the kind of connectivity to be used, e.g. lasso, partial correlation, correlation\n        save         : save the connectivity matrix to a file\n        save_path    : specify path to save the matrix if different from subject folder\n\n    returns:\n        connectivity : connectivity matrix (regions x regions)\n    '
    print(('Estimating %s matrix for subject %s' % (kind, subject)))
    if (kind == 'lasso'):
        covariance_estimator = GraphLassoCV(verbose=1)
        covariance_estimator.fit(timeseries)
        connectivity = covariance_estimator.covariance_
        print('Covariance matrix has shape {0}.'.format(connectivity.shape))
    elif (kind in ['tangent', 'partial correlation', 'correlation']):
        conn_measure = connectome.ConnectivityMeasure(kind=kind)
        connectivity = conn_measure.fit_transform([timeseries])[0]
    if save:
        subject_file = os.path.join(save_path, subject, (((((subject + '_') + atlas_name) + '_') + kind.replace(' ', '_')) + '.mat'))
        sio.savemat(subject_file, {'connectivity': connectivity})
    return connectivity
timeseries   : timeseries table for subject (timepoints x regions)
    subject      : the subject short ID
    atlas_name   : name of the atlas used
    kind         : the kind of connectivity to be used, e.g. lasso, partial correlation, correlation
    save         : save the connectivity matrix to a file
    save_path    : specify path to save the matrix if different from subject folder

returns:
    connectivity : connectivity matrix (regions x regions)
def subject_connectivity(timeseries, subject, atlas_name, kind, save=True, save_path=root_folder):
    '\n        timeseries   : timeseries table for subject (timepoints x regions)\n        subject      : the subject short ID\n        atlas_name   : name of the atlas used\n        kind         : the kind of connectivity to be used, e.g. lasso, partial correlation, correlation\n        save         : save the connectivity matrix to a file\n        save_path    : specify path to save the matrix if different from subject folder\n\n    returns:\n        connectivity : connectivity matrix (regions x regions)\n    '
    print(('Estimating %s matrix for subject %s' % (kind, subject)))
    if (kind == 'lasso'):
        covariance_estimator = GraphLassoCV(verbose=1)
        covariance_estimator.fit(timeseries)
        connectivity = covariance_estimator.covariance_
        print('Covariance matrix has shape {0}.'.format(connectivity.shape))
    elif (kind in ['tangent', 'partial correlation', 'correlation']):
        conn_measure = connectome.ConnectivityMeasure(kind=kind)
        connectivity = conn_measure.fit_transform([timeseries])[0]
    if save:
        subject_file = os.path.join(save_path, subject, (((((subject + '_') + atlas_name) + '_') + kind.replace(' ', '_')) + '.mat'))
        sio.savemat(subject_file, {'connectivity': connectivity})
    return connectivity