replacer_dict_fname = get_jumeg_path() + '/data/replacer_dictionaries.yaml' with open(replacer_dict_fname, 'r') as f: replacer_dict = yaml.safe_load(f)['replacer_dict_aparc'] # load the distances matrix con = np.load(label_distances_fname) node_order_size = con.shape[0] # forget long range connections, plot short neighbouring connections neighbor_range = 30. # millimetres con[con > neighbor_range] = 0. plot_grouped_connectivity_circle(yaml_fname, con, label_names, labels_mode='cortex_only', node_order_size=node_order_size, replacer_dict=replacer_dict, out_fname='label_com_distances_circle_%0.1f_%s.png' % (neighbor_range, parc), colorbar_pos=(0.1, 0.1), n_lines=None, colorbar=True, colormap='Reds') # compute the distances between COM's of the labels _, coords, _, _ = get_label_distances(subject, subjects_dir, parc=parc) # compute the degree degs = mne.connectivity.degree(con, threshold_prop=1) # show the label ROIs using Nilearn plotting fig = plotting.plot_connectome(np.zeros((node_order_size, node_order_size)), coords, node_size=20, edge_threshold='99%', node_color='cornflowerblue', display_mode='ortho',
Plot grouped connectivity circle with these grouped labels for the Destriux atlas. """ from jumeg import get_jumeg_path from jumeg.connectivity import (plot_grouped_connectivity_circle, generate_random_connectivity_matrix) import yaml grouping_yaml_fname = get_jumeg_path( ) + '/data/destriux_aparc_cortex_based_grouping.yaml' label_names_yaml_fname = get_jumeg_path() + '/data/destriux_label_names.yaml' with open(label_names_yaml_fname, 'r') as f: label_names = yaml.safe_load(f)['label_names'] # make a random matrix with 148 nodes con = generate_random_connectivity_matrix(size=(148, 148), symmetric=True) con[con < 0.5] = 0. # plot grouped connnectivity plot_grouped_connectivity_circle(grouping_yaml_fname, con, label_names, labels_mode=None, colorbar_pos=(0.1, 0.1), replacer_dict=None, out_fname='fig_destriux_circle.png', n_lines=50, colorbar=True)
''' Read grouped aparc labels from yaml file. Plot grouped connectivity circle with these grouped labels. ''' import numpy as np from jumeg import get_jumeg_path from jumeg.connectivity import plot_grouped_connectivity_circle import pickle labels_fname = get_jumeg_path() + '/examples/label_names.list' yaml_fname = get_jumeg_path() + '/examples/aparc_cortex_based_grouping.yaml' with open('label_names.list', 'r') as f: label_names = pickle.load(f) # make a random matrix with 68 nodes # use simple seed for reproducibility np.random.seed(42) con = np.random.random((68, 68)) con[con < 0.5] = 0. indices = (np.array((1, 2, 3)), np.array((5, 6, 7))) plot_grouped_connectivity_circle(yaml_fname, con, label_names, labels_mode='cortex_only', colorbar_pos=(0.1, 0.1), n_lines=10, colorbar=True)
con[16, 31] = 0.4 # Auditory con[50, 14] = con[50, 15] = con[50, 28] = con[14, 15] = con[14, 28] = con[15, 28] = 0.5 # DMN con[22, 23] = 0.6 # Visual con[14, 60] = 0.7 # Left FP con[62, 63] = 0.8 # Sensorimotor con[15, 61] = 0.9 # Right FP con[16, 17] = 1 # Frontoinsular con += con.T # since we only add the combinations # plot the connectivity circle showing standard RSNs from matplotlib.colors import ListedColormap cmap = ListedColormap(['m', 'k', 'b', 'y', 'r', 'c', 'g']) yaml_fname = get_jumeg_path( ) + '/data/desikan_aparc_cortex_based_grouping.yaml' plot_grouped_connectivity_circle(yaml_fname, con, aparc_names, n_lines=12, labels_mode=None, colormap=cmap, colorbar=True, replacer_dict=None, indices=None, out_fname='fig_rsn_circle_plot.png')
con, coords, _, _ = get_label_distances(subject, subjects_dir, parc=parc) # forget long range connections, plot short neighbouring connections neighbor_range = 30. # millimetres con[con > neighbor_range] = 0. cortex_colors = ['m', 'b', 'y', 'c', 'r', 'g', 'g', 'r', 'c', 'y', 'b', 'm'] out_fname = 'fig_label_com_distances_circle_%0.1f_%s.png' % (neighbor_range, parc) plot_grouped_connectivity_circle(yaml_cortex_fname, con, label_names, replacer_dict=replacer_dict, yaml_color_fname=None, labels_mode='replace', cortex_colors=cortex_colors, out_fname=out_fname, colorbar_pos=(0.1, 0.1), n_lines=None, colorbar=True, colormap='Reds') # compute the degree degs = mne.connectivity.degree(con, threshold_prop=1) # show the label ROIs and short range connections using nilearn glass brain fig = plotting.plot_connectome(con, coords, node_size=degs, edge_threshold='99%', node_color='cornflowerblue',
''' import numpy as np from jumeg import get_jumeg_path from jumeg.connectivity import plot_grouped_connectivity_circle import yaml labels_fname = get_jumeg_path() + '/data/desikan_label_names.yaml' yaml_fname = get_jumeg_path() + '/data/desikan_aparc_cortex_based_grouping.yaml' replacer_dict_fname = get_jumeg_path() + '/data/replacer_dictionaries.yaml' with open(labels_fname, 'r') as f: label_names = yaml.safe_load(f)['label_names'] with open(replacer_dict_fname, 'r') as f: replacer_dict = yaml.safe_load(f)['replacer_dict_aparc'] # make a random matrix with 68 nodes # use simple seed for reproducibility np.random.seed(42) con = np.random.random((68, 68)) con[con < 0.5] = 0. indices = (np.array((1, 2, 3)), np.array((5, 6, 7))) plot_grouped_connectivity_circle(yaml_fname, con, label_names, labels_mode='cortex_only', replacer_dict=replacer_dict, out_fname='example_grouped_con_circle.png', colorbar_pos=(0.1, 0.1), n_lines=10, colorbar=True)
with open(labels_fname, 'r') as f: label_names = yaml.safe_load(f)['label_names'] with open(replacer_dict_fname, 'r') as f: replacer_dict = yaml.safe_load(f)['replacer_dict_aparc'] # make a random matrix with 68 nodes con = generate_random_connectivity_matrix(size=(68, 68), symmetric=True) # plot simple connectivity circle with cortex based grouping and colors plot_grouped_connectivity_circle(yaml_cortex_fname, con, label_names, labels_mode='replace', replacer_dict=replacer_dict, out_fname='fig_grouped_con_circle_cortex.png', colorbar_pos=(0.1, 0.1), n_lines=10, colorbar=True, colormap='viridis') # plot connectivity circle with cluster-based grouping but same node colors as above plot_grouped_connectivity_circle( yaml_cluster_fname, con, label_names, labels_mode=None, replacer_dict=None, yaml_color_fname=yaml_cortex_fname, out_fname='fig_grouped_con_circle_cluster.png', colorbar_pos=(0.1, 0.1),
#!/usr/bin/env python ''' Read grouped aparc labels from yaml file. Plot grouped connectivity circle with these grouped labels. ''' import numpy as np from jumeg import get_jumeg_path from jumeg.connectivity import plot_grouped_connectivity_circle import pickle labels_fname = get_jumeg_path() + '/examples/label_names.list' yaml_fname = get_jumeg_path() + '/examples/aparc_cortex_based_grouping.yaml' with open('label_names.list', 'r') as f: label_names = pickle.load(f) # make a random matrix with 68 nodes # use simple seed for reproducibility np.random.seed(42) con = np.random.random((68, 68)) con[con < 0.5] = 0. plot_grouped_connectivity_circle(yaml_fname, con, label_names, n_lines=10, colorbar=True)
}, { 'parietal': parietal }, { 'temporal': temporal }, { 'insula': insula }, { 'cingulate': cingulate }, { 'frontal': frontal }] n_colors = len(label_groups) cmap = plt.get_cmap('Pastel1') cortex_colors = cmap.colors[:n_colors] + cmap.colors[:n_colors][::-1] # plot simple connectivity circle with cortex based grouping and colors plot_grouped_connectivity_circle(label_groups, con, label_names, labels_mode='replace', replacer_dict=replacer_dict, cortex_colors=cortex_colors, vmin=0., vmax=1., out_fname='fig_grouped_con_circle_cortex.png', colorbar_pos=(0.1, 0.1), n_lines=50, colorbar=True, colormap='viridis')