Exemplo n.º 1
0
                            keys=['nodes_1', 'nodes_2', 'band', 'task', 'estimator__clf'], 
                            attr='score_accuracy', 
                            fx=lambda x:np.vstack(x).mean())

grid = sns.FacetGrid(dataframe, col="band", row="task", palette="tab20c",
                     height=1.5)
grid.map(sns.barplot, "networks", 'score_accuracy')

def plot_heatmap(nodes1, nodes2, accuracy, **kwargs):

    df = dict(n1=nodes1, n2=nodes2, a=accuracy)
    df = pd.DataFrame(df)
    pdf = df.pivot("n1", "n2", "a")

    nz = np.nonzero(np.isnan(pdf.values))
    pdf.values[nz] = pdf.values[nz[::-1]]

    sns.heatmap(pdf, annot=True, cmap="RdBu", fmt=".2f", center=.5, vmax=.8)


for t in np.unique(average_df['task']):
    task_df = filter_dataframe(average_df, task=[t])
    grid = sns.FacetGrid(task_df, col="band", row="task")
    grid.map(plot_heatmap, "nodes_1", "nodes_2", "score_accuracy")

    fname = "/home/robbis/Dropbox/PhD/experiments/blp-hcp-viviana/Figure-%s.png" % (t)
    grid.savefig(fname, dpi=150)
    


Exemplo n.º 2
0
def plot_heatmap(nodes1, nodes2, accuracy, **kwargs):

    df = dict(n1=nodes1, n2=nodes2, a=accuracy)
    df = pd.DataFrame(df)
    pdf = df.pivot("n1", "n2", "a")
    mask = np.triu(np.ones_like(corr, dtype=bool), k=1)

    nz = np.nonzero(np.isnan(pdf.values))
    pdf.values[nz] = pdf.values[nz[::-1]]

    sns.heatmap(pdf, annot=True, cmap="RdBu_r", fmt=".2f", center=.5, vmax=.7, mask=mask)

for clf in np.unique(average_df['estimator__clf']):
    for t in np.unique(average_df['task']):
        task_df = filter_dataframe(average_df, task=[t], estimator__clf=[clf])
        grid = sns.FacetGrid(task_df, col="band", row="task")
        grid.map(plot_heatmap, "nodes_1", "nodes_2", "score_accuracy")

    fname = "/home/robbis/Dropbox/PhD/experiments/blp-hcp-viviana/Figure-%s.png" % (t)
    grid.savefig(fname, dpi=150)
    


##############################################

def plot_heatmap(nodes1, nodes2, accuracy, **kwargs):
    
    df = dict(n1=nodes1, n2=nodes2, a=accuracy)
    df = pd.DataFrame(df)
    pdf = df.pivot("n1", "n2", "a")
pipeline = 'dexterity+prediction'
pipeline = 'dexterity+prediction+featureselection'
#pipeline = 'dexterity+prediction+pca'

path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/pipeline-%s/" % (
    pipeline)
dataframe = get_results_bids(path,
                             field_list=loaded_keywords,
                             pipeline=[pipeline],
                             scores=scores)

for score in scores:
    score_key = 'score_' + score
    for clf in np.unique(dataframe['estimator__clf']):
        #for task in np.unique(dataframe['task']):
        df = filter_dataframe(dataframe, estimator__clf=[clf], fx=[score])
        #print(clf)

        grid = sns.relplot(
            data=df,
            x="estimator__fsel__k",
            #x='estimator__pca__n_components',
            row='band',
            y=score_key,
            col="target_transformer__attr",
            hue='task',
            kind="line",
            marker='o',
            markersize=10,
            markeredgecolor=None,
            palette='Dark2')
pipeline = 'dexterity+prediction+network'

path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/pipeline-%s/" % (
    pipeline)
dataframe = get_results_bids(path,
                             field_list=loaded_keywords,
                             pipeline=[pipeline],
                             scores=scores)

for score in scores:
    score_key = 'score_' + score
    for clf in np.unique(dataframe['estimator__clf']):
        for t in np.unique(dataframe['task']):
            df = filter_dataframe(dataframe,
                                  estimator__clf=[clf],
                                  fx=[score],
                                  task=[t])

            df = apply_function(
                df,
                keys=['nodes_1', 'nodes_2', 'band', 'estimator__clf', 'fx'],
                attr=score_key,
                fx=lambda x: np.vstack(x).mean())

            grid = sns.FacetGrid(df, col="band")
            grid.map(plot_heatmap, "nodes_1", "nodes_2", score_key)

            fname = "/home/robbis/Dropbox/PhD/experiments/blp-hcp-viviana/figure-regression-%s.png" % (
                t)
            grid.savefig(fname, dpi=150)
Exemplo n.º 5
0
]


def plot_heatmap(nodes1, nodes2, accuracy, **kwargs):

    df = dict(n1=nodes1, n2=nodes2, a=accuracy)
    df = pd.DataFrame(df)
    pdf = df.pivot("n1", "n2", "a")

    nz = np.nonzero(np.isnan(pdf.values))
    pdf.values[nz] = pdf.values[nz[::-1]]

    sns.heatmap(pdf, annot=True, cmap="RdBu", fmt=".2f")


band_df = filter_dataframe(dataframe, num=['2'])
band_df['band'] = [band[f - 1] for f in band_df['fold'].values]

task_df = filter_dataframe(dataframe, num=['1'])
task_df['task'] = [task[t - 1] for t in task_df['fold'].values]

grid = sns.FacetGrid(band_df, col="band", col_wrap=3)
grid.map(plot_heatmap, "nodes_1", "nodes_2", "score_accuracy")

grid = sns.FacetGrid(task_df, col="task", col_wrap=3)
grid.map(plot_heatmap, "nodes_1", "nodes_2", "score_accuracy")

####################
path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/analysis-roi+decoding/"
dataframe = get_results_bids(
    path,