def plot_pooled_correlation_dists_by_condition(cfg): """ Plot the pooled (ie. combined, pooled) correlation distributions separately for each of the conditions (each list in fname_group_list) corresponds to a condition. Parameters ---------- cfg : dict the user-specified config dictionary. The following keys are required:: "group_1_mat_fnames" "group_2_mat_fnames" "group_1_color" "group_2_color" "group_1_label" "group_2_label" Returns ------- fig : the matplotlib figure object """ # CFGCHANGE? config.require(cfg, [ "group_1_mat_fnames", "group_2_mat_fnames", "group_1_color", "group_2_color", "group_1_label", "group_2_label" ]) fname_group_list = [cfg["group_1_mat_fnames"], cfg["group_2_mat_fnames"]] colors = [cfg["group_1_color"], cfg["group_2_color"]] labels = [cfg["group_1_label"], cfg["group_2_label"]] n_bins = 100 corr_bins, corr_bin_centers = aux.get_lin_bins(n_bins, -1, 1.) bin_counts = [np.zeros(n_bins) for f in fname_group_list] fig = plt.figure() ax = fig.add_subplot(111) for i, fname_group in enumerate(fname_group_list): for fname in fname_group: flat_corr_mat = \ dataio.get_blacklist_filtered_and_flattened_adj_mat( fname, cfg["blacklist_fname"] ) bin_counts[i] += aux.get_bin_counts(flat_corr_mat, corr_bins) # normalize bin_counts[i] = bin_counts[i] / \ (np.sum(bin_counts[i] * (corr_bins[1] - corr_bins[0]))) ax.plot(corr_bin_centers, bin_counts[i], color=colors[i], label=labels[i]) ax.set_xlabel(settings.get_prop_tex_name(settings.correlation_tag)) ax.set_ylabel(r"Probability density P(c)") ax.legend(loc=0) fig.savefig(cfg['outdata_dir'] + "pooledCorrDists.pdf", format="pdf", bbox_inches='tight') return fig
def plot_pooled_corr_t_val_dists(cfg): """ Plot the tvalue distributions for movie and rest Parameters ---------- config : dict The following keys are required:: "group_1_mat_fnames" "group_2_mat_fnames" "group_1_color" "group_2_color" "group_1_label" "group_2_label" "outdata_dir" "paired" Returns ------- fig : the matplotlib figure object """ config.require(cfg, [ "group_1_mat_fnames", "group_2_mat_fnames", "group_1_color", "group_2_color", "group_1_label", "group_2_label", "outdata_dir", "paired" ]) # get tvals flat_mats = dataio.get_blacklist_filtered_and_flattened_adj_mats( cfg["all_fnames"], cfg["blacklist_fname"]) if cfg["paired"]: t_vals = measures.paired_t_value(flat_mats, len(cfg['group_1_mat_fnames'])) else: t_vals = measures.unpaired_t_value(flat_mats, len(cfg['group_1_mat_fnames'])) minVal = np.min(t_vals) maxVal = np.max(t_vals) n_bins = 100 bins, binCenters = aux.get_lin_bins(n_bins, minVal - (np.abs(minVal) * 0.1), maxVal + (np.abs(maxVal) * 0.1)) bin_counts = aux.get_bin_counts(t_vals, bins) fig = plt.figure() ax = fig.add_subplot(111) # normalize bin_counts = bin_counts * 1. / (np.sum(bin_counts) * (bins[1] - bins[0])) labels = cfg['group_1_label'], cfg["group_2_label"] ax.plot(binCenters, bin_counts, label=r"" + labels[0] + "-" + labels[1]) ax.set_xlabel(settings.get_prop_tex_name(settings.tval_tag)) ax.set_ylabel(r"Probability density") ax.legend(loc=0) plt.savefig(cfg["outdata_dir"] + "tvalDist.pdf", format="pdf", bbox_inches='tight') return fig
def plot_individual_correlation_dists(cfg): """ Plotting the individual correlation profiles to see the variations. Parameters ---------- cfg : dict the user-specified config dictionary. The following keys are required:: "group_1_mat_fnames" "group_2_mat_fnames" "group_1_color" "group_2_color" "group_1_label" "group_2_label" "outdata_dir" Returns ------- fig : the matplotlib figure object """ # CFGCHANGE? config.require(cfg, ) fname_group_list = [cfg["group_1_mat_fnames"], cfg["group_2_mat_fnames"]] colors = [cfg["group_1_color"], cfg["group_2_color"]] labels = [cfg["group_1_label"], cfg["group_2_label"]] fig = plt.figure() ax = fig.add_subplot(111) n_bins = 100 corr_bins, corr_bin_centers = aux.get_lin_bins(n_bins, -1, 1.) for i, fname_group in enumerate(fname_group_list): for fname in fname_group: flat_corr_mat = \ dataio.get_blacklist_filtered_and_flattened_adj_mat( fname, cfg['blacklist_fname'] ) bin_counts = aux.get_bin_counts(flat_corr_mat, corr_bins) # normalize bin_counts = bin_counts / \ (np.sum(bin_counts * (corr_bins[1] - corr_bins[0]))) ax.plot(corr_bin_centers, bin_counts, color=colors[i], label=labels[i]) ax.set_xlabel(settings.get_prop_tex_name("corr")) ax.set_ylabel(r"Probability density P(c)") ax.legend(loc=0) fig.savefig(cfg['outdata_dir'] + "individualCorrDists.pdf", format="pdf", bbox_inches='tight') return fig
def test_get_default_config(self): cfg = config.get_default_config() assert type(cfg) is dict for key in config.CONFIG_KEYS: assert key in cfg for key in [ "all_fnames", "blacklist_fname", "group_1_mat_fnames", "group_2_mat_fnames", "paired", "outdata_dir", "node_info_fname", "paired" ]: assert key in cfg self.assertRaises(AssertionError, config.check_property, cfg, key) keys = [ "bootstrap_samples", "bootstrap_coverage", "density", "density_range", "group_1_label", "group_2_label", "group_1_color", "group_2_color", "include_mst", "n_it_permutation" ] config.require(cfg, keys)
def plot_link_dist_probs_by_condition(cfg): """ Plots the link distance PDFs pooled by condition. Parameters ---------- cfg : dict the user-specified config dictionary. The following keys are required:: "group_1_mat_fnames" "group_2_mat_fnames" "group_1_color" "group_2_color" "group_1_label" "group_2_label" "outdata_dir" Returns ------- None """ # CFGCHANGE? config.require(cfg, [ "group_1_mat_fnames", "group_2_mat_fnames", "group_1_color", "group_2_color", "group_1_label", "group_2_label", "outdata_dir", "density" ]) fname_group_list = [cfg["group_1_mat_fnames"], cfg["group_2_mat_fnames"]] colors = [cfg["group_1_color"], cfg["group_2_color"]] labels = [cfg["group_1_label"], cfg["group_2_label"]] # ns = [] data_example = dataio.load_pickle( fnc.get_ind_fname(fname_group_list[0][0], cfg, settings.link_distance_tag)) densities = data_example[settings.config_tag][settings.densities_tag] # for individual plots: # figs = [plt.figure() for p in densities] # axs = [fig.add_subplot(111) for fig in figs] group_distances = [] for i, fname in enumerate(fname_group_list): # ns.append(len(fname)) distances = [np.array([]) for p in densities] for fname in fname: print fname data = dataio.load_pickle( fnc.get_ind_fname(fname, cfg, settings.link_distance_tag)) p_f_dists = data[settings.link_distance_tag] for j, p in enumerate(densities): # print p distances[j] = np.hstack((distances[j], p_f_dists[j])) # for individual plots: # for j in range(len(densities)): # genplots.plot_inv_cdf( # axs[j], distances[j], yscale='log', # label=labels[i], color=colors[i]) group_distances.append(distances) indices = range(len(densities)) # [6,7,10] #density indices print densities for k, j in enumerate(indices): fig = plt.figure(figsize=(4, 3)) p = densities[j] ax = fig.add_subplot(1, 1, 1) ax.set_xlabel(settings.get_prop_tex_name(settings.link_distance_tag)) ax.set_ylabel(r"1-CDF(d)") print p, j ax.text(.5, 0.10, r"$\rho$ = " + str(p * 100) + "\%", ha='center', va='center', transform=ax.transAxes) for i in range(len(fname_group_list)): genplots.plot_inv_cdf(ax, group_distances[i][j], label=labels[i], color=colors[i], yscale='log') plt.tight_layout() fig.savefig(cfg['outdata_dir'] + "linkDistProbs_" + str(p) + ".pdf", format="pdf", bbox_inches="tight") plt.close(fig) return None