int snc_size = .layers.SNc.units.size;
float k = 1.0*.processes.Train_Prob.init_procs[0].s_args[0]/.layers.SNc.n_units;
// k is percentage of intact SNC units

UnitSpec* us = .specs.FixedBiasUnitSpec.LearnBiasUnitSpec.matrisom_unitspec;


int max_monval = .processes.Cycle_Prob.final_stats.size;
// number of monitor value statistics

int j;
for (j=0;j<max_monval;j++) .processes.Cycle_Prob.final_stats[j].mod.flag=0;
// don't monitor activities in plus phase (only care about activities during resp selection, in minus phase)

if ((k>0)&&(owner[0].se.val<0.5)) {
  int i; 
  for (i=0;i<snc_size;i++) {
//DA on Rew
   owner.owner.cur_event.patterns[2].value[i]=1.0; 
  .layers.SNc.units[i].ext=1.0; }

  us.act.gain=k*10000; // bigger gain (for D1 contrast effect)

}

else {

int i;
 for (i=0;i<snc_size;i++) {
   owner.owner.cur_event.patterns[2].value[i]=0.027; // smaller dip: simulates DA meds
   .layers.SNc.units[i].ext=0.027; // 
 }

 us.act.gain=600-k*300; // smaller gain (contrast)
 us.act.thr=0.25;

}	

.processes.Settle_Prob.cycle.max=30; // burst/dip shouldn't last that long in plus phase!

float act0 = .layers."Motor Cortex".units[0].act_m;
float act1 = .layers."Motor Cortex".units[1].act_m;



// check to see which motor resp was most active in minus phase and clamp on in plus phase (so that learns about response just selected, whether good or bad)

if (act0 > act1) {
  owner.owner.cur_event.patterns[3].value[0] = 1.0;
  owner.owner.cur_event.patterns[3].value[1] = 0;
  owner.owner.cur_event.patterns[3].value[2] = 1.0;
  owner.owner.cur_event.patterns[3].value[3] = 0;
}

if (act1 > act0) {
  owner.owner.cur_event.patterns[3].value[0] = 0;
  owner.owner.cur_event.patterns[3].value[1] = 1.0;
  owner.owner.cur_event.patterns[3].value[2] = 0;
  owner.owner.cur_event.patterns[3].value[3] = 1.0;
}




GetMyTrialProc().SetCurLrate();