Npost_1=1
group_dict = {}
# run(run_time)
P.simulation['trials']=10
for trial in range(P.simulation['trials']):
	net.restore('initial')
	P.init_synapses['1']['w_ampa'] = param._weight_matrix_randn(Npre=Npre_1, Npost=Npost_1, w_mean=1, w_std=0.5)
	synapses['1'].w_ampa = P.init_synapses['1']['w_ampa']
	print synapses['1'].w_ampa
	net.store('randomized')
	synapses['1'].w_ampa = P.init_synapses['1']['w_ampa']
	P.simulation['trial_id'] = str(uuid.uuid4())
	for field_i, field in enumerate(P.simulation['field_mags']):
		P.simulation['field_mag'] = field
		P.neurons['1']['I_field'] = field
		net.restore('randomized')
		neurons['1'].I_field= field
		net.run(P.simulation['run_time'])
		data_df = analysis._rec2df(rec=rec, P=P)
		group_df = group_df.append(data_df, ignore_index=True)
		data_dict = analysis._rec2dict(rec=rec, P=P)
		group_dict = analysis._add_to_group_data(group_data=group_dict, data_dict=data_dict)

group_df = analysis._dict2frame(data_dict=group_dict)



# for group_key, group in neurons.iter
# brian_objects = collect(level=0)

# net = Network(nrn, self.input_nrn, self.input_syn, self.rec)
    net.run(P.simulation['run_time'])

    print 'first run finished'

    # get trained weights
    trained_weights = {}
    weight_keys = ['w_ampa', 'w_nmda', 'w_gaba', 'w_clopath', 'w_vogels']
    for syn_group, syn in synapses.iteritems():
        trained_weights[syn_group] = {}
        for weight_key in weight_keys:
            if hasattr(syn, weight_key):
                trained_weights[syn_group][weight_key] = getattr(
                    syn, weight_key)[-1]

    # training data
    train_df = analysis._rec2df(rec=rec, P=P, include_P=False)

    # Test
    #==================================================================
    # restore randomized network
    net.restore('randomized')

    # set ampa weights to be fixed
    # synapses['EE'].update_ampa_online = 0
    P.synapses['EE']['update_ampa_online'] = 0
    P.synapses['FE_train']['update_ampa_online'] = 0
    P.synapses['FE_test']['update_ampa_online'] = 0

    print synapses['EE'].namespace
    # initialize weights to trained values
    for syn_group, syn in synapses.iteritems():