diff --git a/plots/balance_stdp.R b/plots/balance_stdp.R index 79a38f4..6d24aaf 100644 --- a/plots/balance_stdp.R +++ b/plots/balance_stdp.R @@ -95,7 +95,8 @@ plot_weights <- function(df_data, bins, bin_width, subset=NULL){ w_distribution <- df_weights %>% ggplot(aes(x=mids, y=count)) + geom_col(width=bin_width, fill=color_map[2], color=color_map[2]) + - theme_bw() + labs(x='weights (pA)', y='fraction of synapses') + theme_bw() + labs(x='weights (pA)', y='fraction of synapses') + + theme(text=element_text(size=16)) return(w_distribution) } @@ -110,8 +111,10 @@ protocols <- map_int(metadata, \(x) x$protocol) prot_id <- match(1, protocols) event_data <- read.csv(file.path(data_path[prot_id], 'events_spikes.csv')) fetches <- event_data %>% + mutate(time_ms = time_ms/1000) %>% ggplot(aes(x=time_ms, y=num_events)) + geom_line() + - theme_bw() + labs(x='time (ms)', y='# Active neurons') + theme_bw() + labs(x='time (s)', y='# active neurons') + + theme(text=element_text(size=16)) w_distribution <- plot_weights(data_path[prot_id], bins=19, bin_width=0.64) incoming_w_j0 <- plot_weights(data_path[prot_id], bins=19, bin_width=0.64, 0) @@ -137,8 +140,10 @@ if(metadata[[prot_id[1]]]$alpha==.1449) { event_data <- read.csv(file.path(data_path[prot_id], 'events_spikes.csv')) fetches <- event_data %>% filter(time_ms < 195000) %>% + mutate(time_ms = time_ms/1000) %>% ggplot(aes(x=time_ms, y=num_events)) + geom_line() + - theme_bw() + labs(x='time (ms)', y='# Active neurons') + theme_bw() + labs(x='time (s)', y='# active neurons') + + theme(text=element_text(size=16)) w_distribution <- plot_weights(data_path[prot_id], bins=35, bin_width=.7) w_distribution <- w_distribution + @@ -160,7 +165,8 @@ df_rates_init$group <- 'initial' freq <- bind_rows(df_rates_init, df_rates_final) %>% ggplot(aes(x=rate, color=group, fill=group)) + theme_bw() + geom_histogram(alpha=.5) + scale_color_manual(values=color_map) + - scale_fill_manual(values=color_map) + theme(legend.position = c(0.8, 0.8)) + + scale_fill_manual(values=color_map) + + theme(legend.position = c(0.8, 0.8), text=element_text(size=16)) + labs(x='firing rates (Hz)', y='count', fill=element_blank(), color=element_blank()) + scale_y_log10() diff --git a/plots/conditions_stdp.R b/plots/conditions_stdp.R index 719801b..57ad90f 100644 --- a/plots/conditions_stdp.R +++ b/plots/conditions_stdp.R @@ -52,18 +52,19 @@ t_final <- 250 fetch_dist_init <- df_events %>% filter(time_ms > t_init & time_ms < t_final) %>% ggplot(aes(x=group, y=num_fetch, fill=group)) + - geom_boxplot(outlier.shape=NA) + theme_bw() + theme(legend.position="none") + + geom_boxplot(outlier.shape=NA) + theme_bw() + + theme(legend.position="none", text = element_text(size=16)) + geom_jitter(color="black", size=0.7, alpha=0.5) + - labs(x=element_blank(), y='# Memory access') + + labs(x=element_blank(), y='mems') + scale_fill_manual(values=color_map) t_init <- 0 t_final <- 100 trace_init <- df_events %>% filter(time_ms > t_init & time_ms < t_final) %>% ggplot(aes(x=time_ms, y=num_fetch, color=group)) + geom_line() + - theme(legend.position="none") + theme_bw() + + theme_bw() + theme(legend.position="none", text = element_text(size=16)) + guides(color=guide_legend(override.aes=list(linewidth=4))) + - labs(x='time (ms)', y='# Memory access', color='Event threshold') + + labs(x='time (ms)', y='mems', color='Event threshold') + scale_color_manual(values=color_map) t_init <- 99500 @@ -71,23 +72,25 @@ t_final <- 99750 fetch_dist_final <- df_events %>% filter(time_ms > t_init & time_ms < t_final) %>% ggplot(aes(x=group, y=num_fetch, fill=group)) + - geom_boxplot(outlier.shape=NA) + theme_bw() + theme(legend.position="none") + + geom_boxplot(outlier.shape=NA) + theme_bw() + + theme(legend.position="none", text = element_text(size=16)) + geom_jitter(color="black", size=0.7, alpha=0.5) + - labs(x=element_blank(), y='# Memory access') + + labs(x=element_blank(), y='mems') + scale_fill_manual(values=color_map) t_init <- 99500 t_final <- 100000 trace_final <- df_events %>% filter(time_ms > t_init & time_ms < t_final) %>% ggplot(aes(x=time_ms, y=num_fetch, color=group)) + geom_line() + - theme_bw() + labs(x='time (ms)', y='# Memory access') + + theme_bw() + labs(x='time (ms)', y='mems') + scale_x_continuous(labels=c(t_init, t_final), breaks=c(t_init, t_final)) + - scale_color_manual(values=color_map) + theme(legend.position="none") + scale_color_manual(values=color_map) + + theme(legend.position="none", text = element_text(size=16)) df_spk <- read.csv(str_replace(nth(dir_list, -1), "events_spikes.feather", "spikes_post.csv")) rates <- df_spk %>% ggplot(aes(x=time_ms)) + geom_histogram(fill=color_map[3]) + theme_bw() + - labs(x='time (ms)', y='# spikes') + labs(x='time (ms)', y='# spikes') + theme(text = element_text(size=16)) n_fetch <- rates / (trace_init + trace_final) / diff --git a/plots/fp8_simple_stdp.R b/plots/fp8_simple_stdp.R index 5146cfa..e289899 100644 --- a/plots/fp8_simple_stdp.R +++ b/plots/fp8_simple_stdp.R @@ -41,10 +41,10 @@ state_vars <- df_vars %>% filter(!str_detect(monitor, "ref"), id==0) %>% mutate(monitor = str_replace(monitor, "statemon_pre_neurons", - "presynaptic neuron")) %>% + "presynaptic")) %>% mutate(monitor = str_replace(monitor, "statemon_post_neurons", - "postsynaptic neuron")) %>% + "postsynaptic")) %>% mutate(variable = str_replace(variable, "Ca", "x")) %>% mutate(variable = str_replace(variable, "g", "PSP")) state_vars$value <- map_dbl(state_vars$value, minifloat2decimal) @@ -54,7 +54,7 @@ states_stoch <- state_vars %>% geom_line() + labs(x='time (ms)', y='magnitude (a.u.)', color='state variables') + xlim(c(363, 713)) + scale_color_manual(values=color_map[c(1, 3, 5)]) + guides(color=guide_legend(override.aes=list(linewidth=5))) + - theme(legend.position="none") + theme(legend.position="none", text = element_text(size=16)) df_weights <- read.csv(file.path(data_path[sim_id], 'synapse_vars.csv')) w_trace <- df_weights %>% @@ -71,7 +71,7 @@ weights_stoch_high <- temp_weights + geom_line(data=avg_weight, aes(x=time_ms, y=value), color=color_map[4], linewidth=1) + labs(x='time (ms)', y='weight (a.u.)') + - xlim(c(363, 1957)) + theme_bw() + xlim(c(363, 1957)) + theme_bw() + theme(text=element_text(size=16)) selected_folder <- stoch_round & small_w sim_id <- match(T, selected_folder) @@ -90,7 +90,7 @@ weights_stoch_low <- temp_weights + geom_line(data=avg_weight, aes(x=time_ms, y=value), color=color_map[4], linewidth=1) + labs(x='time (ms)', y='weight (a.u.)') + - xlim(c(363, 1957)) + theme_bw() + xlim(c(363, 1957)) + theme_bw() + theme(text=element_text(size=16)) selected_folder <- !stoch_round & !small_w sim_id <- match(T, selected_folder) @@ -100,10 +100,10 @@ state_vars <- df_vars %>% filter(!str_detect(monitor, "ref"), id==0) %>% mutate(monitor = str_replace(monitor, "statemon_pre_neurons", - "presynaptic neuron")) %>% + "presynaptic")) %>% mutate(monitor = str_replace(monitor, "statemon_post_neurons", - "postsynaptic neuron")) %>% + "postsynaptic")) %>% mutate(variable = str_replace(variable, "Ca", "x")) %>% mutate(variable = str_replace(variable, "g", "PSP")) state_vars$value <- map_dbl(state_vars$value, minifloat2decimal) @@ -112,7 +112,8 @@ states_det <- state_vars %>% facet_grid(rows=vars(fct_rev(monitor)), scales="free") + geom_line() + labs(x='time (ms)', y='magnitude (a.u.)', color='state variables') + xlim(c(363, 713)) + scale_color_manual(values=color_map[c(1, 3, 5)]) + - guides(color=guide_legend(override.aes=list(linewidth=5))) + guides(color=guide_legend(override.aes=list(linewidth=5))) + + theme(text=element_text(size=16)) df_weights <- read.csv(file.path(data_path[sim_id], 'synapse_vars.csv')) w_trace <- df_weights %>% @@ -122,6 +123,7 @@ weights_det_high <- w_trace %>% filter(id==0) %>% ggplot(aes(x=time_ms, y=value, group=id)) + geom_line(alpha=.6, color=color_map[3]) + theme_bw() + + theme(text=element_text(size=16)) + scale_color_manual(values = color_map[3]) + labs(x='time (ms)', y='weight (a.u.)') + xlim(c(363, 1957)) @@ -137,6 +139,7 @@ weights_det_low <- w_trace %>% filter(id==0) %>% ggplot(aes(x=time_ms, y=value, group=id)) + geom_line(alpha=.6, color=color_map[3]) + theme_bw() + + theme(text=element_text(size=16)) + scale_color_manual(values = color_map[3]) + labs(x='time (ms)', y='weight (a.u.)') + xlim(c(363, 1957)) diff --git a/plots/multi_fetch_stdp.R b/plots/multi_fetch_stdp.R index 83c829f..7b1786c 100644 --- a/plots/multi_fetch_stdp.R +++ b/plots/multi_fetch_stdp.R @@ -57,7 +57,8 @@ df_events <- df_events %>% group_by(N_post, group) %>% mutate(mean_fetch=mean(num_fetch)) multi_fetch_avg <- df_events %>% ggplot(aes(x=group, y=num_fetch)) + - geom_boxplot(aes(fill=group)) + theme_bw() + theme(legend.position="none") + + geom_boxplot(aes(fill=group)) + theme_bw() + + theme(legend.position="none", text=element_text(size=16)) + geom_point(aes(y=mean_fetch, color=group), shape=2, size=7) + facet_wrap(~N_post) + scale_y_log10() + labs(x=element_blank(), y='# Memory access') + diff --git a/plots/simple_stdp.R b/plots/simple_stdp.R index b51ef03..436241b 100644 --- a/plots/simple_stdp.R +++ b/plots/simple_stdp.R @@ -27,7 +27,7 @@ ca_traces <- ggplot() + geom_histogram(data=df_pre_events, aes(x=time_ms), fill=color_map[2], alpha=0.3, binwidth=1) + labs(x=element_blank(), y=TeX(r'($x_i$ (a.u))')) + - theme_bw() + theme(panel.grid.minor=element_blank()) + theme_bw() + theme(panel.grid.minor=element_blank(), text = element_text(size=16)) df_post_ca_trace <- df_vars %>% filter(id==0) %>% @@ -35,7 +35,8 @@ df_post_ca_trace <- df_vars %>% filter(time_ms>690 & time_ms<890) %>% ggplot(aes(x=time_ms, y=value)) + labs(x='time (ms)', y=TeX(r'($x_j$ (a.u))')) + - theme_bw() + theme(panel.grid.minor=element_blank()) + geom_line() + theme_bw() + theme(panel.grid.minor=element_blank(), text = element_text(size=16)) + + geom_line() b_rang <- c(0, 310, 420, 720, 800, 1110, 1210, 1510, 1610, 2010, 2080, 2320) w_trace <- df_weights %>% @@ -57,7 +58,8 @@ w_trace <- df_weights %>% annotate(geom='text', x=b_rang[6] - (b_rang[6]-b_rang[5])/2, y=11.2, label='III') + annotate(geom='text', x=b_rang[8] - (b_rang[8]-b_rang[7])/2, y=11.2, label='IV') + annotate(geom='text', x=b_rang[10] - (b_rang[10]-b_rang[9])/2, y=11.2, label='V') + - annotate(geom='text', x=b_rang[12] - (b_rang[12]-b_rang[11])/2, y=11.2, label='VI') + annotate(geom='text', x=b_rang[12] - (b_rang[12]-b_rang[11])/2, y=11.2, label='VI') + + theme(text = element_text(size=16)) # Mean is taken over all connections, i.e. id mse_w <- df_weights %>% @@ -68,10 +70,12 @@ mse_w <- df_weights %>% group_by(time_ms) %>% summarise(mse = mean(squared_error)) %>% ggplot(aes(x=time_ms, y=mse)) + labs(x='time (ms)', y='mean squared error') + - geom_line() + theme_bw() + theme(panel.grid.minor=element_blank()) + geom_line() + theme_bw() + + theme(panel.grid.minor=element_blank(), text = element_text(size=16)) + + scale_x_continuous(breaks = scales::pretty_breaks(n = 3)) -w_changes <- wrap_elements(w_trace + plot_annotation(title='A')) / - (wrap_elements(mse_w + plot_annotation(title='B')) + - wrap_elements(ca_traces / df_post_ca_trace + plot_annotation(title='C'))) +w_changes <- wrap_elements(w_trace + plot_annotation(title='A', theme=theme(text=element_text(size=16)))) / + (wrap_elements(mse_w + plot_annotation(title='B', theme=theme(text=element_text(size=16)))) + + wrap_elements(ca_traces / df_post_ca_trace + plot_annotation(title='C', theme=theme(text=element_text(size=16))))) ggsave(argv$dest, w_changes) diff --git a/plots/stochastic_balance_stdp.R b/plots/stochastic_balance_stdp.R index 7936e24..d703bf8 100644 --- a/plots/stochastic_balance_stdp.R +++ b/plots/stochastic_balance_stdp.R @@ -96,7 +96,8 @@ plot_weights <- function(df_data, bin_width, subset=NULL){ w_distribution <- df_weights %>% ggplot(aes(x=mids, y=count)) + geom_col(width=bin_width, fill=color_map[1], color=color_map[1]) + - theme_bw() + labs(x='weights (a.u.)', y='fraction of synapses') + theme_bw() + labs(x='weights (a.u.)', y='fraction of synapses') + + theme(text=element_text(size=16)) return(w_distribution) } @@ -116,9 +117,9 @@ variables <- state_vars %>% mutate(variable = str_replace(variable, "Ca", "x")) %>% mutate(variable = str_replace(variable, "g", "PSP")) %>% ggplot(aes(x=time_ms, y=value, color=variable)) + - labs(x='time (s)', y='magnitude (a.u.)') + scale_color_manual(values=color_map) + + labs(x='time (ms)', y='magnitude (a.u.)') + scale_color_manual(values=color_map) + guides(color=guide_legend(override.aes=list(linewidth=5))) + - geom_line() + theme_bw() + geom_line() + theme_bw() + theme(text=element_text(size=16)) w_distribution <- plot_weights(data_path, bin_width=0.64) incoming_w_j0 <- plot_weights(data_path, bin_width=0.64, 0) @@ -126,8 +127,10 @@ incoming_w_j10 <- plot_weights(data_path, bin_width=0.64, 10000) event_data <- read.csv(file.path(data_path, 'events_spikes.csv')) fetches <- event_data %>% + mutate(time_ms = time_ms/1000) %>% ggplot(aes(x=time_ms, y=num_events)) + geom_line(color=color_map[1]) + - theme_bw() + labs(x='time (ms)', y='# active neurons') + theme_bw() + labs(x='time (s)', y='# active neurons') + + theme(text=element_text(size=16)) df_raster <- read.csv(file.path(data_path, 'output_spikes.csv')) print("Statistics with bimodal experiment: ") @@ -146,10 +149,13 @@ df_rates_final$group <- 'final' df_rates_init$group <- 'initial' freq <- bind_rows(df_rates_init, df_rates_final) %>% ggplot(aes(x=rate, color=group, fill=group)) + theme_bw() + - geom_histogram(alpha=.5) + scale_color_manual(values=color_map) + - scale_fill_manual(values=color_map) + theme(legend.position = c(0.8, 0.8)) + - labs(x='firing rates (Hz)', y='count', fill=element_blank(), color=element_blank()) + - scale_y_log10() + geom_histogram(alpha=.5, binwidth=1) + scale_color_manual(values=color_map) + + scale_fill_manual(values=color_map) + + scale_x_continuous(breaks = scales::pretty_breaks(n = 4)) + + theme(legend.position = c(0.25, 0.8), + text=element_text(size=16), + legend.text=element_text(size=10)) + + labs(x='firing rates (Hz)', y='count', fill=element_blank(), color=element_blank()) fig <- fetches + variables + freq + w_distribution + plot_annotation(tag_levels='A') diff --git a/plots/stochastic_kernel.R b/plots/stochastic_kernel.R index 57253a5..7867b1b 100644 --- a/plots/stochastic_kernel.R +++ b/plots/stochastic_kernel.R @@ -37,7 +37,7 @@ generate_plot <- function(df, time) { ggplot(aes(x=id, y=value)) + geom_line(color=color_map[3]) + theme_bw() + labs(x=TeX(r'($\Delta$\;t (ms))'), y=element_blank(), color=element_blank()) + guides(color=guide_legend(override.aes=list(linewidth=4))) + - theme(legend.position = c(0.25, 0.8)) + theme(legend.position = c(0.25, 0.8), text=element_text(size=16)) return(kernel) } @@ -61,8 +61,8 @@ kernel_small_middle <- kernel_small_middle + labs(y='weight (a.u.)') kernel_small_final <- generate_plot(df_weights_small, 9000) fig_kernel <- wrap_elements(kernel_high_middle + kernel_high_final + - plot_annotation(title='A')) / + plot_annotation(title='A', theme=theme(text=element_text(size=16)))) / wrap_elements(kernel_small_middle + kernel_small_final + - plot_annotation(title='B')) + plot_annotation(title='B', theme=theme(text=element_text(size=16)))) ggsave(argv$dest, fig_kernel) diff --git a/plots/stochastic_operations.R b/plots/stochastic_operations.R index 7d4b4fa..c0033b9 100644 --- a/plots/stochastic_operations.R +++ b/plots/stochastic_operations.R @@ -63,7 +63,8 @@ if (op_type == "addition"){ L_heatmap <- ggplot(df_L, aes(delta, lambda, fill=L)) + scale_fill_gradientn(colors=color_map, name=TeX(r'($L$)')) + labs(x=TeX(r'($\delta$)'), y=TeX(r'($\lambda$)')) + theme_bw() + geom_tile() + - theme(legend.position="top") + theme(legend.position="top", text = element_text(size=16), + legend.text=element_text(angle=45)) } my_breaks<-c(1, 10, 100, 1000) @@ -76,7 +77,8 @@ probs_scatter <- ggplot(df_scatter, aes(x=p_round_closer_ideal, y=p_round_closer geom_smooth(colour='black', method=lm) + geom_bin2d(bins=25) + geom_abline(slope=1, intercept=0, linetype="dashed", color="black") + theme_bw() + labs(x=TeX(r'($P_i$)'), y=TeX(r'($P_s$)')) + - theme(legend.position="top") + theme(legend.position="top", text = element_text(size=16), + legend.text=element_text(angle=45)) if (op_type == "addition"){ sim_id <- match("stickier", selected_folders) @@ -90,7 +92,7 @@ if (op_type == "addition"){ geom_smooth(colour='black', method=lm) + geom_bin2d(bins=25) + geom_abline(slope=1, intercept=0, linetype="dashed", color="black") + theme_bw() + labs(x=TeX(r'($P_i$)'), y=TeX(r'($P_s$)')) + - theme(legend.position="none") + theme(legend.position="none", text = element_text(size=16)) sim_id <- match("cutoff", selected_folders) df_cut <- read.csv(file.path(data_path[sim_id], "probs.csv")) @@ -103,7 +105,7 @@ if (op_type == "addition"){ geom_smooth(colour='black', method=lm) + geom_bin2d(bins=25) + geom_abline(slope=1, intercept=0, linetype="dashed", color="black") + theme_bw() + labs(x=TeX(r'($P_i$)'), y=TeX(r'($P_s$)')) + - theme(legend.position="none") + theme(legend.position="none", text = element_text(size=16)) } if (op_type == "addition"){ diff --git a/plots/stochastic_pd.R b/plots/stochastic_pd.R index 92d5909..1cb0f91 100644 --- a/plots/stochastic_pd.R +++ b/plots/stochastic_pd.R @@ -42,7 +42,8 @@ freq <- rates %>% mutate(layer=fct_rev(layer)) %>% ggplot(aes(rate, layer)) + theme_bw() + theme(panel.grid.minor=element_blank(), - panel.grid.major=element_blank()) + + panel.grid.major=element_blank(), + text=element_text(size=16)) + labs(x='firing rates (Hz)', y=element_blank()) + geom_boxplot() + stat_summary(fun='mean', geom='point', shape=2) @@ -123,7 +124,7 @@ histograms <- df_raster %>% ggplot(aes(x=t, color=type)) + geom_step(stat='bin', bins=50) + guides(color=guide_legend(override.aes=list(size=4))) + facet_grid(rows=vars(laminae), scales='free') + theme_bw() + - theme(legend.position = 'bottom') + + theme(legend.position = 'bottom', text=element_text(size=16)) + scale_color_manual(values=color_map[c(1, 3)]) + guides(color=guide_legend(override.aes=list(linewidth=5))) + labs(x='time (ms)') + xlim(670, 730) @@ -136,7 +137,9 @@ variables <- state_vars %>% ggplot(aes(x=time_ms, y=value, color=variable)) + geom_line() + theme_bw() + facet_grid(layer ~ type, scales="free") + - theme(legend.position = 'bottom', strip.text.y = element_blank()) + + theme(legend.position = 'bottom', + strip.text.y = element_blank(), + text=element_text(size=16)) + labs(x='time (s)', y='magnitude (a.u.)') + scale_color_manual(values=color_map) + guides(color=guide_legend(override.aes=list(linewidth=5))) diff --git a/plots/weights_stdp.R b/plots/weights_stdp.R index 4edc03b..f8dd898 100644 --- a/plots/weights_stdp.R +++ b/plots/weights_stdp.R @@ -22,7 +22,10 @@ kernel <- df_weights %>% ggplot(aes(x=id, y=value, color=monitor)) + geom_line() + theme_bw() + labs(x=TeX(r'($\Delta$\;t (ms))'), y='weight (mV)', color=element_blank()) + guides(color=guide_legend(override.aes=list(linewidth=4))) + - scale_color_manual(values=color_map) + theme(legend.position = c(0.25, 0.8)) + scale_color_manual(values=color_map) + + theme(legend.position = c(0.75, 0.2), + text = element_text(size=16), + legend.text=element_text(size=10)) kernel_mse <- df_weights %>% filter(variable == 'w_plast') %>% @@ -32,7 +35,8 @@ kernel_mse <- df_weights %>% group_by(time_ms) %>% summarise(mse = mean(squared_error)) %>% ggplot(aes(x=time_ms, y=mse)) + labs(x='time (ms)', y='mean squared error') + - geom_line() + theme_bw() + theme(panel.grid.minor=element_blank()) + geom_line() + theme_bw() + + theme(panel.grid.minor=element_blank(), text = element_text(size=16)) sim_dir <- 'distribution_sim' df_weights <- read.csv(file.path(argv$source, sim_dir, 'synapse_vars_weights.csv')) @@ -40,7 +44,7 @@ df_weights$w_plast <- df_weights$w_plast * 1000 w_distribution <- df_weights %>% filter(label=='Proposed') %>% ggplot(aes(x=w_plast, color=label, fill=label)) + geom_histogram(alpha=0.8) + - theme_bw() + theme(legend.position="none") + + theme_bw() + theme(legend.position="none", text = element_text(size=16)) + labs(x='weights (mV)', color=element_blank(), fill=element_blank()) + scale_color_manual(values=color_map[2]) + scale_fill_manual(values=color_map[2])