def correlation_brain_image(outside_brain_value):
    """
    Uses a mask to plot only the areas that are the brain itself and saves
    that image into the figures folder.

    Parameters
    ----------
    outside_brain_values : int

    Returns
    -------
    None
    """
    if outside_brain_value < 0:
        title = 'light'
    else:
        title = 'dark'
    correlations_3d = np.reshape(
        get_correlations('mean',
                         nan=False),
        VOXEL_DIMENSIONS)
    image = correlations_3d[:, :, 24]
    image += image.min()
    outside_brain_mask = np.logical_not(bm.get_brain_mask())[:, :, 24]
    image[outside_brain_mask] = outside_brain_value
    hot_mask = image >= np.percentile(get_correlations('mean', nan=True), 95)
    hot_pixels = np.zeros_like(image, dtype=np.float)
    hot_pixels[hot_mask] = image[hot_mask]
    hot_pixels[~hot_mask] = np.nan
    plt.imshow(image, interpolation='nearest', cmap='gray')
    plt.imshow(hot_pixels, interpolation='nearest', cmap='Blues')
    plot_path = '{0}/figures/correlated_brain_{1}.png'.format(REPO_HOME_PATH,
                                                              title)
    plt.savefig(plot_path)
    print('Saved {0}'.format(plot_path))
示例#2
0
def correlation_brain_image(outside_brain_value):
    """
    Uses a mask to plot only the areas that are the brain itself and saves
    that image into the figures folder.

    Parameters
    ----------
    outside_brain_values : int

    Returns
    -------
    None
    """
    if outside_brain_value < 0:
        title = 'light'
    else:
        title = 'dark'
    correlations_3d = np.reshape(get_correlations('mean', nan=False),
                                 VOXEL_DIMENSIONS)
    image = correlations_3d[:, :, 24]
    image += image.min()
    outside_brain_mask = np.logical_not(bm.get_brain_mask())[:, :, 24]
    image[outside_brain_mask] = outside_brain_value
    hot_mask = image >= np.percentile(get_correlations('mean', nan=True), 95)
    hot_pixels = np.zeros_like(image, dtype=np.float)
    hot_pixels[hot_mask] = image[hot_mask]
    hot_pixels[~hot_mask] = np.nan
    plt.imshow(image, interpolation='nearest', cmap='gray')
    plt.imshow(hot_pixels, interpolation='nearest', cmap='Blues')
    plot_path = '{0}/figures/correlated_brain_{1}.png'.format(
        REPO_HOME_PATH, title)
    plt.savefig(plot_path)
    print('Saved {0}'.format(plot_path))
def get_pairwise_correlations(only_brain = True):
    """
    Finds and returns the paths to the correlations of all possible pairs of
    subjects (if the paths exist)

    Parameters
    ----------
    None

    Returns
    -------
    paths : string array
    """
    subject_pairs = itertools.combinations(SUBJECTS, 2)
    brain_mask = np.ravel(bm.get_brain_mask())
    correlations = [np.load(dp.get_correlation_path(subj_a, subj_b))
            for subj_a, subj_b in subject_pairs]
    if only_brain:
        return [c[brain_mask] for c in correlations]
    return correlations
示例#4
0
def get_pairwise_correlations(only_brain=True):
    """
    Finds and returns the paths to the correlations of all possible pairs of
    subjects (if the paths exist)

    Parameters
    ----------
    None

    Returns
    -------
    paths : string array
    """
    subject_pairs = itertools.combinations(SUBJECTS, 2)
    brain_mask = np.ravel(bm.get_brain_mask())
    correlations = [
        np.load(dp.get_correlation_path(subj_a, subj_b))
        for subj_a, subj_b in subject_pairs
    ]
    if only_brain:
        return [c[brain_mask] for c in correlations]
    return correlations