Simulate Data from the SceneWalk Model

[1]:
import os
import shutil
import sys
from collections import OrderedDict
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import norm as normal, truncnorm as truncated_normal
import seaborn as sns
from scenewalk.scenewalk_model_object import scenewalk as scenewalk_model
from scenewalk.utils import loadData
from scenewalk.simulation import simulate_dataset

Get some basis data

[2]:
dataDict = loadData.load_data("spst_all")
dataDict = loadData.shorten_set(dataDict, 2)
x_dat, y_dat, dur_dat, im_dat, densities_dat, d_range = loadData.dataDict2vars(dataDict)
shortening from 35 to 2

Scenewalk Model

Here you define the setup of the model.

[3]:
sw = scenewalk_model("subtractive", "zero", "off", "off", "off", {'x': d_range[0], 'y': d_range[1]}, {"logged_z":True, "coupled_oms":True})

sw.whoami()
[3]:
'I am a subtractive scenewalk model, initialized with zero activation, in 2 exponents mode, with om_i as a fraction, with logged z'

It will tell you which parameters it needs and the order if you’re passing them in as a list:

[4]:
sw.get_param_list_order()
[4]:
['omegaAttention',
 'omfrac',
 'sigmaAttention',
 'sigmaInhib',
 'gamma',
 'lamb',
 'inhibStrength',
 'zeta']
[5]:
param_dict = OrderedDict({
    "omegaAttention": 18.5,
    "omfrac": 10,
    "sigmaAttention": 6,
    "sigmaInhib": 12,
    "gamma" : 8,
    "lamb" : 0.6,
    "inhibStrength" :0.7,
    "zeta" : -2,
})
[6]:
sw.update_params(param_dict)
#print(sw.get_params())
print("have we provided all relevant parameters?:", sw.check_params_for_config())
print("are the parameters within the defined bounds?:", sw.check_params_in_bounds())

have we provided all relevant parameters?: True
are the parameters within the defined bounds?: True

Now Simulate

[7]:
sim_id = simulate_dataset.simulate(dur_dat, im_dat, densities_dat, sw, params=None, start_loc="center", x_path=None, y_path=None, resample_durs=False, verbose = True)
sub 0
sub 1

Load simulated data

[8]:
sim_dat_dict = loadData.load_sim_data(os.path.abspath(sim_id))

More settings for simulations

Advanced settings include instead of params=None you can give it a dictionary of all parameters the model needs by subject. i.e.

[9]:
param_subj_dict = {
    0 : param_dict,
    1 : param_dict,
    2 : param_dict,
    3 : param_dict,
    4 : param_dict
}
[10]:
sim_id = simulate_dataset.simulate(dur_dat, im_dat, densities_dat, sw, params=param_subj_dict, start_loc="center", x_path=None, y_path=None, resample_durs=False, verbose=True)
sub 0
sub 1
[11]:
sw.get_params()
[11]:
OrderedDict([('omegaAttention', 18.5),
             ('omegaInhib', 1.85),
             ('sigmaAttention', 6),
             ('sigmaInhib', 12),
             ('gamma', 8),
             ('lamb', 0.6),
             ('inhibStrength', 0.7),
             ('zeta', 0.01)])