LuckyFace's Systems Lifescience

State conversion in trials 본문

Systems Neuroscience/ARDUINO functions

State conversion in trials

LuckyFace 2017. 4. 19. 15:51

    // Task state

    else if (state < 9) {

        times = micros();


  // State conversion if time reaches each epoch duration

        if (times >= timeStart+duration[state]) { // is current duration(=time-timeStart) longer than epoch duration?

            timeStart = times; // reset epoch start time

            

       



select창에 s를 치면 state는 6으로 변경됨.

따라서 큰 if/else if 함수에서 state <9에 걸려서 본격적으로 시작되게 됨.

timeStart 함수는 초기에 0으로 설정되어있음.

duration은 7개의 값이 담긴 matrix로


duration[7] = {500000,1000000,500000,500000,130000,2370000,2000000}; // epoch duration

각 time epoch가 지나면 timeStart는 그때의 time으로 reset되게 되어있음.

그리고 state conversion이 됨.


   // state 6: iti -> 0: base

            else if (state==6) {

                if (iTrial>=nTrial) { // if current trial number is reached goal trial number, return to standby state

                    PORTD = B10000000;

                    delay(10);

                    PORTB &= B00010000; // reset water valve

                    PORTD &= B00000011; // reset odor valve

                    

                    state = 9;

                    iTrial = 0;

                    nTrial = 200;

                    itiDuration = 2;

                    duration[4] = 130000;

                    waterClear = true;


                    printf("%lue%d\n",times,state);

                }


state 6이지만 iTrial( trial 종료마다 1씩 증가)이 nTrial과 같아진다면, PORTD는 다 off (final valve빼고), 10초 delay이후에 PORTB sensor빼고는 다 off, PORT D역시 0,1pin 뺴고는 다 off.  그뒤에 state는 stand-by state로 돌아감.




    else {

                    cue = addCue + ratio*random(nCue); // choice cue for next trial

                    if (cue==2 && noC) {

                        cue=3;

                    }

                    if (cue==prevCue) {

                        ++nRepeat;

                        if (nCue>1 && nRepeat>maxRepeat) {

                            cue = addCue + random(nCue-1);

                            if (cue >= prevCue) {

                              cue = cue + ratio;

                              if (cue==2 && noC) {

                                  cue=3;

                              }

                            }

                        }

                    } // if same cue repeats over 3 times, choose difference cue.

                    else {

                        nRepeat = 1;

                    }

                    PORTD = B10000100 | (B00001000 << cue); // turn on NO valve, final valve, and cue stimulus valve



자, 여기에서 iTrial이 nTrial보다 작다면 cue를 진행해야할텐데, 그다음에 나올 cue는 random(pseudorandom)으로 결정되게 됨.


'Systems Neuroscience > ARDUINO functions' 카테고리의 다른 글

sensor  (0) 2017.04.19
bit Math  (0) 2017.04.19
Serial 통신(2)  (0) 2017.04.19
void setup과 Serial 통신  (0) 2017.04.18
boolean and String, char  (0) 2017.04.18
Comments