2020String ver = " Force" ; // unique identifier text
2121Force force (ver); // start FORCE object
2222
23- int prob_left = 70 ; // Probability of pellet on the high-reward poke
24- int prob_right = 30 ; // Probability of pellet on the low-reward poke
23+ int prob_left = 100 ; // Probability of pellet on the high-reward poke
24+ int prob_right = 100 ; // Probability of pellet on the low-reward poke
2525int trialsToSwitch = 20 ; // # of trials before probabilities on the pokes switch
2626int trial_counter = 0 ; // Tracks how many pellets have been obtained in this set of probabilities
2727int highp_counter = 0 ; // Tracks how many pokes in a row in high probability poke
2828int trialTimeout = 5 ; // timeout duration after each poke, set to 0 to remove the timeout
2929int probs[5 ] = {10 , 30 , 50 , 70 , 90 };
30- unsigned long trial_start = 0 ;
31- unsigned long trial_length = 5000 ;
32- bool trial_available = false ;
3330bool press = false ;
3431
3532void setup () {
36- force.begin (); // setup FORCE
33+ force.log_lite = true ;
34+ force.begin (force.log_lite ); // setup FORCE
3735 force.trial_window = 60000 ;
36+ force.ver = prob_left;
37+ force.FRC = prob_right;
38+ force.trials_per_block = trialsToSwitch;
3839}
3940
4041void loop () {
@@ -43,19 +44,26 @@ void loop() {
4344 // This is the non-stationary part of the task ///
4445 // meaning that probabilities change every trialsToSwitch trials ///
4546 // /////////////////////////////////////////////////////////////////////
46- force.run (false );
47+ force.run ();
4748 if (trial_counter == trialsToSwitch) {
4849 highp_counter = 0 ;
4950 trial_counter = 0 ;
5051 prob_left = probs[random (0 ,5 )];
5152 prob_right = 100 -prob_left;
53+ force.ver = prob_left;
54+ force.FRC = prob_right;
5255 }
5356
5457 else if (highp_counter == 8 ) {
5558 highp_counter = 0 ;
5659 trial_counter = 0 ;
5760 prob_left = probs[random (0 ,5 )];
5861 prob_right = 100 -prob_left;
62+
63+ force.ver = prob_left;
64+ force.FRC = prob_right;
65+ // force.dispense_delay = highp_counter;
66+ force.dispense_amount = trial_counter;
5967 }
6068
6169 // ///////////////////////////////////////////////////////////////
@@ -65,18 +73,16 @@ void loop() {
6573 // //////////////////////////////////////////////////////////////
6674 force.readPoke ();
6775 if (force.poke ) {
68- trial_start = millis ();
76+ force.run ();
77+ force.event = " CENTER" ;
78+ force.logdata_lite ();
79+ force.trial_start = millis ();
6980 force.Tone ();
70- trial_available = true ;
81+ force. trial_available = true ;
7182 }
7283
73- while (((millis ()-trial_start) < force.trial_window ) && trial_available == true ) {
74- force.ratioLeft = prob_left;
75- force.ratioRight = prob_right;
76- force.trials_per_block = trial_counter;
77- force.FRC = highp_counter;
78- force.library_version = trialsToSwitch;
79- force.run (true );
84+ while (((millis ()-force.trial_start ) < force.trial_window ) && force.trial_available ) {
85+ force.run ();
8086
8187 // ///////////////////////////////////////////////////////////
8288 // // If mouse presses the left lever ///
@@ -88,17 +94,21 @@ void loop() {
8894 else {
8995 highp_counter = 0 ;
9096 }
91- delay (500 );
97+ // force.dispense_delay = highp_counter;
98+ force.loglite_Left ();
99+
92100 if (random (100 ) < prob_left) {
93- force.Tone () ;
101+ force.event = " RewardLeft " ;
94102 force.DispenseLeft ();
95103 trial_counter ++;
104+ force.dispense_amount = trial_counter;
105+ force.logdata_lite ();
96106 }
97107 else {
98108 force.Tone (300 ,600 );
99109 }
100110 press = true ;
101- trial_available = false ;
111+ force. trial_available = false ;
102112 }
103113
104114 // ////////////////////////////////////////////////////////////
@@ -111,34 +121,40 @@ void loop() {
111121 else {
112122 highp_counter = 0 ;
113123 }
114- delay (500 );
124+ // force.dispense_delay = highp_counter;
125+ force.loglite_Right ();
126+
115127 if (random (100 ) < prob_right) {
116- force.Tone () ;
128+ force.event = " RewardRight " ;
117129 force.DispenseRight ();
118130 trial_counter ++;
131+ force.dispense_amount = trial_counter;
132+ force.logdata_lite ();
133+
119134 }
120135 else {
121136 force.Tone (300 ,600 );
122137 }
123138 press = true ;
124- trial_available = false ;
139+ force. trial_available = false ;
125140 }
126141 }
127142
128143 // ////////////////////////////////////////////////////////////
129144 // // If there was no press during the time window ////
130145 // ///////////////////////////////////////////////////////////
131- if (trial_available && press == false ) {
146+ if (force. trial_available && press == false ) {
132147 force.Tone (300 ,600 );
148+ force.trial_available = false ;
133149 }
134150
135151 // ////////////////////////////////////////////////////////////
136152 // // Finish trial and start inter-trial timeout ////
137153 // ///////////////////////////////////////////////////////////
138- if (trial_available ) {
154+ if (press ) {
139155 press = false ;
140- trial_available = false ;
156+ force. trial_available = false ;
141157 force.Timeout (trialTimeout);
142- force.Tone ();
143158 }
159+
144160}
0 commit comments