net = Network()
net = run_control._collect_brian_objects(net, input_path, neurons, synapses, rec['neurons'], rec['synapses'])

# run simulation
#=======================================================================
# set time step
defaultclock.dt = P.simulation['dt']
# store initialized network state
net.store('initial')

# set number of pre and post synaptic neurons
Npre_1=1
Npost_1=1

# dictionary for group data over multiple trials
group_df = analysis._load_group_data(directory=group_data_directory, file_name=group_data_filename, df=True)

# set number of trials
P.simulation['trials']=3
for trial in range(P.simulation['trials']):
    # restore initial conditions after each trial
    net.restore('initial')
    
    # randomize input weights
    P.init_synapses['1']['w_ampa'] = param._weight_matrix_randn(Npre=Npre_1, Npost=Npost_1, w_mean=1, w_std=0.5)
    P.init_synapses['2']['w_ampa'] = param._weight_matrix_randn(Npre=Npre_1, Npost=Npost_1, w_mean=1, w_std=0.5)
    
    # set initial weights
    synapses['1'].w_ampa = P.init_synapses['1']['w_ampa']
    synapses['2'].w_ampa = P.init_synapses['2']['w_ampa']
    
# FIXME use timed array to turn field on and off at specific time
# choose a poissoninput group that is always paired with dcs
# use the same timedarray (corresponding row from input_timed_array)

# FIXME assign spatial variable to each neuron and use that to design connectivity
# directory and file name to store data
#====================================================================
exp_name = '.'.join(__name__.split('analysis_')[1:])
group_data_directory = 'Datatemp/' + exp_name + '/'
group_data_filename = exp_name + '_data.pkl'
group_data_filename_train = exp_name + '_data_train.pkl'
group_data_filename_test = exp_name + '_data_test.pkl'

# dictionary for group data over multiple trials
train_group_df = analysis._load_group_data(directory=group_data_directory,
                                           file_name=group_data_filename_train,
                                           df=True)
test_group_df = analysis._load_group_data(directory=group_data_directory,
                                          file_name=group_data_filename_test,
                                          df=True)

# print train_group_df.keys()
# df_w_train = train_group_df[train_group_df.variable=='w_clopath']
# df_u_train = train_group_df[train_group_df.variable=='u']
# df_w_test = test_group_df[train_group_df.variable=='w_clopath']
# df_u_test = test_group_df[train_group_df.variable=='u']

# df_w_train_FF = df_w_train[df_w_train.group_name=='FF_train']
# df_w_train_EE = df_w_train[df_w_train.group_name=='EE']
# df_u_train_E = df_u_train[df_u_train.group_name=='E']
# df_u_train_I = df_u_train[df_u_train.group_name=='I']