from pyitab.results import get_results_bids, filter_dataframe, apply_function import seaborn as sns import h5py path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/pipeline-blp-dexterity-trial" dataframe = get_results_bids(path, field_list=['sample_slicer','estimator__clf', 'feature_slicer'], pipeline=['raw'], ) dataframe['networks'] = dataframe['nodes_1']+'+'+dataframe['nodes_2'] average_df = apply_function(dataframe, 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)
from pyitab.results import get_results_bids, filter_dataframe, apply_function import seaborn as sns import h5py tasks_dict = dict( 'task1': 'left_hand', 'task2': 'left_foot', 'task4': 'right_hand', 'task5': 'right_foot', ) path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/pipeline-dexterity+full/" dataframe = get_results_bids(path, field_list=['sample_slicer','estimator__clf', 'feature_slicer'], pipeline=['dexterity+full'], scores=['accuracy'] ) dataframe['networks'] = dataframe['nodes_1']+'+'+dataframe['nodes_2'] average_df = apply_function(dataframe, 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):
'feature_slicer', 'estimator__clf', 'estimator__fsel__k', #'estimator__pca__n_components', 'target_transformer__attr' ] scores = ['r2', 'explained_variance', 'neg_mean_squared_error'] 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,
sns.heatmap(pdf, annot=False, cmap="RdBu_r", fmt=".2f", center=0, vmax=1) loaded_keywords = [ 'sample_slicer', 'feature_slicer', 'estimator__clf', 'target_transformer__attr' ] scores = ['r2', 'explained_variance', 'neg_mean_squared_error'] 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,
from pyitab.results import get_results_bids, filter_dataframe, apply_function import seaborn as sns import h5py path = "/media/robbis/DATA/meg/viviana-hcp/derivatives/pipeline-fingerprint+taskband" dataframe = get_results_bids( path, field_list=['sample_slicer', 'estimator__clf', 'feature_slicer'], pipeline=['fingerprint+taskband'], scores=['accuracy']) dataframe['nodes_1'] = [v.split('+')[0] for v in dataframe['value'].values] dataframe['nodes_2'] = [v.split('+')[1] for v in dataframe['value'].values] task = ['rest ', 'task1 ', 'task14', 'task2 ', 'task25', 'task4 ', 'task5 '] band = [ 'alpha ', 'betahigh ', 'betalow ', 'gammahigh', 'gammalow ', 'gammamid ' ] 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]]