<jupyter_start><jupyter_text>expr1  Description Changes in spatial patterning (Ω), temporal patterning (cv) and cross correlation patterning (cor) as a function of weight (g_w) and spikelet (g_k) of the GJ network.  init macro<jupyter_code>import os
import numpy as np

# macro
STIM_CURR = "stim-0.9"
DIR_ROOT = os.path.join("..", "expr1")
DIR_OUTPUTS = os.path.join(DIR_ROOT, "outputs", STIM_CURR)
DIR_FIGS = os.path.join(DIR_ROOT, "figs", STIM_CURR)<jupyter_output><empty_output><jupyter_text>read outputs<jupyter_code># init omegas & cvs & cors
omegas = []; cvs = []; cors = []

# read outputs
for idx in os.listdir(DIR_OUTPUTS):
    omegas.append(np.loadtxt(os.path.join(DIR_OUTPUTS, idx, "omegas.csv"), delimiter = ","))
    cvs.append(np.loadtxt(os.path.join(DIR_OUTPUTS, idx, "cvs.csv"), delimiter = ","))
    cors.append(np.loadtxt(os.path.join(DIR_OUTPUTS, idx, "cors.csv"), delimiter = ","))

# mean outputs
omegas = np.mean(np.array(omegas), axis = 0)
cvs = np.mean(np.array(cvs), axis = 0)
cors = np.mean(np.array(cors), axis = 0)<jupyter_output><empty_output><jupyter_text>plot outputs<jupyter_code>import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

# set random.seed
np.random.seed(0)
# init g_ws & g_ks & colors
g_ws = [.05, .1, .15, .2, .25, .3, .35, .4, .45, .5]
g_ks = [.05, .1, .15, .2, .25, .3, .35, .4, .45, .5]
colors = [np.random.randint(0,256,3)/255. for _ in range(omegas.shape[0])]

# init fig & gs
fig = plt.figure(
    figsize = (10,5),
    constrained_layout = True
)
gs = GridSpec(5, 30, figure = fig)

## axes 1: show colormap
for i in range(len(g_ws)):
    ax1i = fig.add_subplot(gs[0,3*i:3*(i+1)])
    # plot ax1i
    ax1i.set_xticks([]); ax1i.set_yticks([])
    ax1i.set_facecolor(colors[i])
    ax1i.text(0.5, 0.5, g_ws[i],
        va = "center", ha ="center",
        fontsize=12, transform=ax1i.transAxes
    )

## axes 21: show omegas
ax21 = fig.add_subplot(gs[1:,0:10])
for i in range(omegas.shape[0]):
    # plot ax21
    ax21.plot(
        # plot omegas
        g_ks, omegas[i],
        # plot settings
        linestyle = "-", linewidth = 1.5, marker = "x", markersize = 2, color = colors[i]
    )
ax21.set_xlim(left = np.min(g_ks) - .02, right = np.max(g_ks) + .02)
ax21.set_ylim(bottom = np.min(omegas) -.5, top = np.max(omegas) + .5)
ax21.set_xlabel(xlabel = "g_k")
ax21.set_ylabel(ylabel = "omega")
ax21.set_title(label = "omega as a function of g_k & g_w")

## axes 22: show cvs
ax22 = fig.add_subplot(gs[1:,10:20])
for i in range(cvs.shape[0]):
    # plot ax22
    ax22.plot(
        # plot cvs
        g_ks, cvs[i],
        # plot settings
        linestyle = "-", linewidth = 1.5, marker = "x", markersize = 2, color = colors[i]
    )
ax22.set_xlim(left = np.min(g_ks) - .02, right = np.max(g_ks) + .02)
ax22.set_ylim(bottom = np.min(cvs) -.5, top = np.max(cvs) + .5)
ax22.set_xlabel(xlabel = "g_k")
ax22.set_ylabel(ylabel = "cv")
ax22.set_title(label = "cv as a function of g_k & g_w")

## axes 23: show cors
ax23 = fig.add_subplot(gs[1:,20:30])
for i in range(cors.shape[0]):
    # plot ax23
    ax23.plot(
        # plot cors
        g_ks, cors[i],
        # plot settings
        linestyle = "-", linewidth = 1.5, marker = "x", markersize = 2, color = colors[i]
    )
ax23.set_xlim(left = np.min(g_ks) - .02, right = np.max(g_ks) + .02)
ax23.set_ylim(bottom = np.min(cors) -.5, top = np.max(cors) + .5)
ax23.set_xlabel(xlabel = "g_k")
ax23.set_ylabel(ylabel = "cor")
ax23.set_title(label = "cor as a function of g_k & g_w")

# integrate fig
fig.align_xlabels([ax21, ax22, ax23])

# img legend & show
fig.show()<jupyter_output><ipython-input-6-47def301ef2a>:81: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
  fig.show()
{'fraction_non_alphanumeric': 0.17128529955133281, 'fraction_numerical': 0.0485616257587754, 'mean_word_length': 3.610705596107056, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '323089', 'license': 'MIT', 'n_tokens_mistral': 1702, 'n_tokens_neox': 1601, 'n_words': 352, 'path': 'examples/gap-junction-2d/exprs/report/expr1.ipynb', 'repo_name': 'Fassial/pku-intern', 'size': '3789'}