<jupyter_start><jupyter_text>Setup SimsWe instantiate 300 networks, run each 20 times, yielding an original batch of 6,000 simulationsthat will be re-analyzed and re-run throughout the paper (see Methods, simulations).<jupyter_code>%matplotlib inline
import matplotlib
matplotlib.rcParams['figure.dpi'] = 300.
from tctx import simsetup
from tctx.analysis import simbatch as sb
from tctx import postpro
iwm_range = (50, 110)
iws_range = (0, 120)<jupyter_output><empty_output><jupyter_text>Original batch<jupyter_code>%%time

input_batch_path = simsetup.setup_original_batch(
    'nets_2021.12.01',
    'original',
    net_count=300,
    sim_count_per_net=20,
    iwm_range=iwm_range,
    iws_range=iws_range,
)
input_batch = sb.SimBatch.load(input_batch_path)

input_batch.describe_reg()
!ls -lha ../../../data/interim/nets_*
!ls -lha ../../../data/interim/batch_*<jupyter_output><empty_output><jupyter_text>Post-process<jupyter_code># Look up the results of executing seqexp.py
results_batch_path = sb.abs_path('seqexp/2021.12.01.00.00.00.000000/sweeps.h5')
!ls -lh $results_batch_path

batch_results = sb.SimBatch.load(results_batch_path).sel(status='success')
simsetup.plot_input_param_sampling(batch_results, iwm_range, iws_range)
batch_results.describe_reg()
working_filename = sb.abs_path('batch_2021.12.01_processed/registry.h5')
seqs_folder = working_filename.parent / 'seqs'

simsetup.save_batch(batch_results, working_filename)<jupyter_output><empty_output><jupyter_text>Register the results of the simulations and extract basic stats like firing rates<jupyter_code>postpro.register_raw(working_filename)

postpro.extract_simstats(working_filename)<jupyter_output><empty_output><jupyter_text>Extract $\Delta$ FR for all cells, tag followers, and extract sequence stats<jupyter_code>postpro.extract_followers(working_filename, seqs_folder)
postpro.extract_extents(working_filename)
postpro.extract_order_entropy(working_filename, seqs_folder / 'order_entropy.h5')<jupyter_output><empty_output><jupyter_text>Store follower cells and follower-to-follower connections separately for quicker access<jupyter_code>postpro.extract_all_foll_cells(working_filename, seqs_folder / 'foll_cells.h5')

postpro.extract_net_foll_conns(working_filename, seqs_folder / 'net_foll_conns.h5')

postpro.extract_str_foll_conns(working_filename, seqs_folder / 'str_foll_conns.h5', mask_col=None)<jupyter_output><empty_output><jupyter_text>Extract activation matrices of followers and cluster using k-modes for Fig. 4<jupyter_code>postpro.extract_foll_amats(working_filename, seqs_folder / 'amat.h5')
postpro.extract_kmodes_labels(working_filename, seqs_folder / f'kmode_labels.h5')
sb.SimBatch.load(working_filename).describe_reg()<jupyter_output><empty_output><jupyter_text>Spike transfer extraction<jupyter_code>working_filename = sb.abs_path('batch_2021.12.01_processed/registry.h5')

batch_results = sb.SimBatch.load(working_filename)<jupyter_output><empty_output><jupyter_text>Randomly tag simulations for extraction<jupyter_code>motif_sim_count = 900
simsetup.randomly_tag(batch_results, motif_sim_count, 'uniform_sampling_sub')

simsetup.plot_input_param_sampling(
    batch_results,
    iwm_range,
    iws_range,
    highlight='uniform_sampling_sub',
)
simsetup.save_batch(batch_results, working_filename)<jupyter_output><empty_output><jupyter_text>Post-process<jupyter_code>postpro.extract_all_jumps(
    working_filename,
    seqs_folder / 'jumps.h5',
    mask_col='uniform_sampling_sub',
)
postpro.extract_motifs(
    working_filename,
    seqs_folder / 'motifs.h5',
    mask_col='uniform_sampling_sub',
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10162489672266593, 'fraction_numerical': 0.02340952905535665, 'mean_word_length': 8.171717171717171, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '649580', 'license': 'MIT', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1277, 'n_words': 189, 'path': 'notebooks/sims.ipynb', 'repo_name': 'comp-neural-circuits/tctx', 'size': '3631'}