subsample = 5 # initialize pseudo random number generator seed = time() prng = Random() prng.seed(seed) # initialize data t = np.arange(0, problem.simulation_params['tstop']+dt, dt) i_inj = problem.simulation_params['i_amp'] data = np.zeros((n_data, len(t)/subsample, 2)) # inputs are the trace of v and i_inj labels = np.zeros(n_data) for i in range(n_data): # modify parameter candidate = problem.generator(prng, None) # run simulation problem.update_cell(candidate) v, t = iclamp(problem.cell, **problem.simulation_params) data[i, :, 0] = v[:-1:subsample] data[i, :, 1] = i_inj[:-1:subsample] labels[i] = candidate[0] # store data if not os.path.exists(save_dir): os.makedirs(save_dir) with open(save_dir+'/problem.json', 'w') as f: json.dump(params, f, indent=4) with open(save_dir+'/cell.json', 'w') as f: json.dump(Cell.from_modeldir(params['model_dir']).get_dict(), f, indent=4)