Beispiel #1
0
def search_all_vs_one(key, plot=False, **kwargs):
    """For each pair of variables, look for a significant regression slope."""

    sess = PINGDataSession()  # username/password stored in an env variable for me.
    sess.login()

    all_data = compute_all_asymmetries(prefix=['MRI_cort_area', 'MRI_cort_thick',
                                               'MRI_subcort_vol', 'DTI_fiber_vol'])
    results = []
    keys = list(set(all_data.keys()) - set(('SubjID',)))
    for loop_key in keys:
        results.append(sess.regress(key, loop_key, plot=plot, **kwargs))
        if plot:
            plt.show()
Beispiel #2
0
def search_all_vs_itself(covariates, plot=False, **kwargs):
    """For each pair of variables, look for a significant regression slope."""

    def add_subplot(fh, *args):
        return fh.add_subplot(*args) if plot else None

    sess = PINGDataSession()  # username/password stored in an env variable for me.
    sess.login()

    all_data = compute_all_asymmetries(prefix=['MRI_cort_area', 'MRI_cort_thick',
                                               'MRI_subcort_vol', 'DTI_fiber_vol'])
    results = []
    keys = list(set(all_data.keys()) - set(('SubjID',)))
    for X in keys:
        # Get relevant covariates
        try:
            added_covariates = sess.AI2flds(X)

            # Then regress on each side
            fh2 = plt.figure(figsize=(18, 6)) if plot else None
            sess.regress(X.replace('_AI', '_LH_PLUS_RH'),
                         X,
                         covariates=covariates, plot=add_subplot(fh2, 1, 3, 1),
                         **kwargs)
            sess.regress(added_covariates[1],
                         X,
                         covariates=covariates + ['MRI_cort_area_ctx_total_LH_PLUS_RH'],
                         plot=add_subplot(fh2, 1, 3, 2),
                         **kwargs)
            sess.regress('MRI_cort_area_ctx_total_LH_PLUS_RH',
                         X,
                         covariates=covariates,
                         plot=add_subplot(fh2, 1, 3, 3),
                         **kwargs)
        except Exception as e:
            print("Failed for %s (%s); moving on..." % (X, e))

        if plot:
            plt.show()