<jupyter_start><jupyter_text>Define simulation setup (simulator settings and toy cells)- define overall simulation setup: simulator parameters to infer for Gabor-RF simulator- generate a number of `toy' gabor cells with receptive field (RF) defined by their ground-truth parameters $\theta^*$ used for the simulator<jupyter_code>!mkdir -p results/

import numpy as np

params_ls = {'glm': ('bias',),
             'kernel': {'s' : ('gain', 'phase', 'freq', 'angle', 'ratio', 'width'),
                        'l' : ['xo', 'yo'],
                        't' : []}} # do no infer temporal kernels (assume to be instantaneous)

sim_info = {'d' : 41,  # STA is d x d 
            'parametrization' : 'gabor', 
            'params_ls' : params_ls,
            'duration' : 300, # duration in seconds
            'dt' : 0.025,     # bin width in seconds
            'len_kt' : 2 }    # length of temporal kernel (2 is minimum)

np.save('results/sim_info', sim_info)<jupyter_output><empty_output><jupyter_text>Define toy cells- three different archetypes are generated, differed mostly by their 'phase' parameter:     - sine-shaped RF: at phase $\frac{\pi}/2$, the Gabor RF is perfectly sine-shaped    - cosine-shaped RF: at phase $0$, the Gabor RF is perfectly cosine-shaped    - general RF: intermediate phase $\frac{\pi}{4}$- different archetypes also differ by location, ratio, width, angle frequency ...- we generate each archetype for two different firing rates (defined by different 'bias' and 'gain' parameters): 5 Hz and 1 Hz. The higher firing rate shifts posteriors over bias and gain, and generally leads to tighter posteriors on all other parameters (STAs become much clearer and better identify the RF).  5 Hz toy cells<jupyter_code>!mkdir -p results/toy_cells/

# cell number 1 (phase pi/4)
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': 1.48810066532243},
                    'kernel': {'s': {'angle': 0.7,
                                     'freq': 1.8,
                                     'gain': 0.49262003027013,
                                     'phase': np.pi/4,
                                     'ratio': 1.5,
                                     'width': 2.5},
                               'l': {'xo': 0.3,
                                     'yo': -0.4},
                               't': {'value': np.array([1., 0.])}}} # temporal here. Instantaneous here!

np.save('results/toy_cells/toy_cell_' + str(1), params_dict_true)
# cell number 2 (sine-shaped)
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': 1.48810066532243},
                    'kernel': {'s': {'angle': 0.7 + np.pi/4,
                                     'freq': 2.4,
                                     'gain': 0.49262003027013,
                                     'phase': np.pi/2-0.001, # -0.001 for numberical stability
                                     'ratio': 2.8,
                                     'width': 2.3},
                               'l': {'xo': -0.5,
                                     'yo': 0.1},
                               't': {'value': np.array([1., 0.])}}}

np.save('results/toy_cells/toy_cell_' + str(2), params_dict_true)
# cell number 3 (cosine-shaped), 5 Hz
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': 1.48810066532243},
                    'kernel': {'s': {'angle': 0.7 + np.pi/3,
                                     'freq': 1.8,
                                     'gain': 0.49262003027013,
                                     'phase': 0.001,
                                     'ratio': 0.8,
                                     'width': 2.7},
                               'l': {'xo': 0.3,
                                     'yo': 0.4},
                               't': {'value': np.array([1., 0.])}}}

np.save('results/toy_cells/toy_cell_' + str(3), params_dict_true)<jupyter_output><empty_output><jupyter_text>1 Hz toy cells<jupyter_code># cell number 4 (phase pi/4)
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': -0.202179976727683},
                    'kernel': {'s': {'angle': 0.7,
                                     'freq': 1.8,
                                     'gain': 0.635893036174612,
                                     'phase': np.pi/4,
                                     'ratio': 1.5,
                                     'width': 2.5},
                               'l': {'xo': 0.3,
                                     'yo': -0.4},
                               't': {'value': np.array([1., 0.])}}}

np.save('results/toy_cells/toy_cell_' + str(4), params_dict_true)
# cell number 5 (sine-shaped)
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': -0.202179976727683},
                    'kernel': {'s': {'angle': 0.7 + np.pi/4,
                                     'freq': 2.4,
                                     'gain': 0.635893036174612,
                                     'phase': np.pi/2-0.001,
                                     'ratio': 2.8,
                                     'width': 2.3},
                               'l': {'xo': -0.5,
                                     'yo': 0.1},
                               't': {'value': np.array([1., 0.])}}}

np.save('results/toy_cells/toy_cell_' + str(5), params_dict_true)<jupyter_output><empty_output><jupyter_text>results shown in paper only on cell 6: cosine-shaped (i.e. bimodal posterior in phase!) cell  firing at about 1Hz<jupyter_code># cell number 6 (cosine-shaped), 1 Hz
params_dict_true = {'glm': {'binsize': 0.025,
                            'bias': -0.202179976727683},
                    'kernel': {'s': {'angle': 0.7 + np.pi/3,
                                     'freq': 1.8,
                                     'gain': 0.635893036174612,
                                     'phase': 0.001,
                                     'ratio': 0.8,
                                     'width': 2.7},
                               'l': {'xo': 0.3,
                                     'yo': 0.4},
                               't': {'value': np.array([1., 0.])}}}

np.save('results/toy_cells/toy_cell_' + str(6), params_dict_true)<jupyter_output><empty_output><jupyter_text>validate<jupyter_code>for i in range(6):
    params_dict_true = np.load('results/toy_cells/toy_cell_' + str(i+1) + '.npy', allow_pickle=True)[()]
    print(params_dict_true)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14020270270270271, 'fraction_numerical': 0.05528255528255528, 'mean_word_length': 1.290889905029898, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '175963', 'license': 'MIT', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1858, 'n_words': 474, 'path': '3_gabor/01_simulation_setup.ipynb', 'repo_name': 'mackelab/IdentifyMechanisticModels_2020', 'size': '6512'}