Exemplo n.º 1
0
def make_histograms():

    os.makedirs('Histograms', exist_ok=True)

    task_dofs = load_dofs()
    for task in contrasts:

        subjs = load_covars_df(task, return_perf=False).index
        plt.hist(task_dofs[task].loc[subjs], bins=50)
        plt.title(task + ' DOF Histogram')
        plt.ylabel('Counts')
        plt.xlabel('Value')
        plt.savefig('Histograms/' + task + '_dof_histogram.png', dpi=750)
        plt.show()
        plt.clf()
        plt.close()

    mean_motions = load_motion()
    for task in contrasts:

        subjs = load_covars_df(task, return_perf=False).index
        plt.hist(mean_motions[task].loc[subjs], bins=50)
        plt.title(task + ' FD Histogram')
        plt.ylabel('Counts')
        plt.xlabel('Value')

        if task == 'nBack':
            plt.xlim(0, 3)

        plt.savefig('Histograms/' + task + '_fd_histogram.png', dpi=750)
        plt.show()
        plt.clf()
        plt.close()
Exemplo n.º 2
0
def load_raw_data(task, resid=False, overlap_with=None):

    all_data = {}

    # Subjects will be same for all
    # overwrite w/ latest
    subjects = None

    # Get covars df + de-mean
    covars = load_covars_df(task, return_perf=False)
    covars = proc_covars_func(covars)

    # Overlap with one or more series
    if overlap_with is not None:

        if not isinstance(overlap_with, list):
            overlap_with = [overlap_with]

        for ow in overlap_with:
            to_keep = np.intersect1d(covars.index, ow.index)
            covars = covars.loc[to_keep]

    # For each contrast
    for contrast in contrasts[task]:
        for is_cortical in [True, False]:

            # Get mask
            mask = get_mask(task, contrast, is_cortical=is_cortical)

            # Generate template path
            tp = get_template_path(task, is_cortical=is_cortical)

            # Load raw data
            subjects, data =\
                load_resid_data(covars, contrast, tp, mask=mask,
                                resid=resid, n_jobs=16, verbose=1)

            # Add to all_data dict
            app_name = '.subcortical'
            if is_cortical:
                app_name = '.cortical'

            all_data[contrast + app_name] = data

    return all_data, covars.loc[subjects]
Exemplo n.º 3
0
import sys
from Rely import load_resid_data
import numpy as np
import os

from info import (load_covars_df, proc_covars_func, get_mask,
                  get_template_path, contrasts)
from helpers import get_cohens, fast_corr

# Process arguments
task = str(sys.argv[1])
contrast = int(str(sys.argv[2]))
is_cortical = bool(int(str(sys.argv[3])))

# Load the covars df
covars_df, perf_df = load_covars_df(task, return_perf=True)

# De-MEAN!
covars_df = proc_covars_func(covars_df)

# Generate the proper mask based off contrast + cortical vs. subcortical
mask = get_mask(task, contrast, is_cortical)

# Generate template path
template_path = get_template_path(task, is_cortical)

# Load resid data
subjects, resid_data =\
    load_resid_data(covars_df, contrast, template_path, mask=mask,
                    n_jobs=8, verbose=1)
print('Final Shape:', resid_data.shape, flush=True)
Exemplo n.º 4
0
import matplotlib.pyplot as plt
import numpy as np

from info import (load_covars_df, proc_covars_func, get_mask,
                  get_template_path, get_strat_series)

# Process arguments
task = str(sys.argv[1])
contrast = int(str(sys.argv[2]))
is_cortical = bool(int(str(sys.argv[3])))
run = str(sys.argv[4])

print('sys.argv=', sys.argv, flush=True)

# Load the covars df
covars_df = load_covars_df(task, return_perf=False)

# Get the strat series
strat_series = get_strat_series(covars_df)

# Generate the proper mask based off contrast + cortical vs. subcortical
mask = get_mask(task, contrast, is_cortical)

# Generate template path
template_path = get_template_path(task, is_cortical)

print('is_cortical=', is_cortical)
print('mask.shape=', mask.shape)
print('contrast=', contrast)
print('template_path=', template_path)