def stage2(session, var, doo, myPoints, dbc, mouse): fc.dataRecordStart2(var, dbc) var.stg = 2 # specify number of stage var.goodPokesInARoll = 0 # reset counter var.rewardGot = 0 # reset total points var.sessid = session # specify sessid while var.trialCounter < var.trial: # run given number of trials if not var.sameInitPos: # get a new init and fix position if no violation made in the last trial fc.getInitPos(var) fc.getFixmag(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() # reset mouse before each state var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) fc.dataRecord2(var, dbc) # record data if fc.again_or_next(var) == 'again': # if any violations made var.trialCounter += 1 # plus 1 in trialCounter var.sameInitPos = True # next trial will use the same init position var.goodPokesInARoll = 0 # reset goodPokesInARoll to 0 var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list continue # start over the same trial else: # if no violation made var.trialCounter += 1 # plus 1 in trialCounter var.fixation_clicks = [] # reset fixation_clicks record list var.reward_clicks = [] # reset reward_clicks record list if fc.passStageTest( var) == 'pass': # if this stage is passed, break the loop break fc.show_bigCoins(var, myPoints) # show total coins earned return var
def stage5_r(session,var,doo,myPoints,dbc,mouse): fc.dataRecordStart5(var,dbc) var.stg = 5 # specify number of stage var.sessid = session highlowIndex = 0 var.goodPokesInARoll = 0 var.rewardGot = 0 # reset total points var = fc.getKindHighLowList(var) while var.trialCounter < var.trial: # run given number of trials if not var.sameInitPos: # get a new setup if no violation made in the last trial fc.getInitPos(var) fc.getFixmag(var) fc.getYellowPos(var) fc.getHitmag(var) fc.getDelayTime(var) fc.getInitStimDis(var) var,doo,myPoints = fc.draw_initCircle(var,doo,myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var,doo,myPoints = fc.funcDic[var.state](var,doo,myPoints) fc.dataRecord5(var,dbc) # record data if fc.again_or_next(var) == 'again': # if any violations made var.trialCounter+=1 # plus 1 in trialCounter var.totalTrialCounter+=1 # not in used here, just for consistency, see stage5.py var.mergedTrialCounter+=1 # not in used here, just for consistency, see stage5.py var.sameInitPos = True # next trial will use the same init position var.goodPokesInARoll = 0 # reset goodPokesInARoll to 0 var.fixation_clicks=[] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks=[] # reset reward_clicks(records the clicks during reward) list var.delay_clicks=[] # reset delay_clicks(records the clicks during delay waiting time) list continue # start over the same trial else: # if no violation made var.trialCounter+=1 # plus 1 in trialCounter var.totalTrialCounter+=1 # not in used here var.mergedTrialCounter+=1 # not in used here var.fixation_clicks = []# reset fixation_clicks record list var.reward_clicks=[]# reset reward_clicks record list var.delay_clicks=[] # reset delay_clicks(records the clicks during delay waiting time) list if fc.passStageTest(var) == 'pass':# if this stage is passed, break the loop break fc.show_bigCoins(var,myPoints) # show total coins earned return var
def MixNonverbal_r(var, doo, myPoints, dbc, mouse, getName=True, sub_id=None): var.stg = 6 # specify stage number ( assign stage #6 for mixnonverbal) fc.setpath() # set up directory fN = os.path.basename(__file__) # get expName of this file expName, extN = os.path.splitext(fN) # get expName and extN expDate = datetime.datetime.now().strftime( "%Y-%m-%d_T%H_%M_%S") # get stageName sessid, p_num, p_net, setiddtb, host_ip, var, dbc = fc.exp_setup( var, doo, dbc, getName, sub_id, expName, expDate) # database setup and data start recording setupList = fc.nonverbalSetup( var.nonverbalTotalTrial_r, var.mag, var.shortmag ) # setup the reward of blocks for the whole experiment(same as in nonverbal) shuffledSetupList = copy.copy(setupList) # shuffle the reward list random.shuffle(shuffledSetupList) # show subjects stage name (short delay) for i in range( len(shuffledSetupList)): # apply a reward mag for each block var.blockRewMag = shuffledSetupList[i][ 0] # assign reward mag for this block var.blockName = i + 1 # assign blockName var = fc.instruction(var, doo) # show block instruction to the subject while var.blockTrialCounter < shuffledSetupList[i][ 1]: # run pre-determined number of trials in each block var.rewmag = var.blockRewMag # assign reward mag if not var.sameInitPos: # get a new setup if no violation made in the last trial fc.getInitPos(var) fc.getFixmag(var) fc.getBluePos(var) var = fc.symmetricYBPair(var) # gets symmetric yellow position fc.getDelayTime(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) fc.dataRecord_mixNon(var, dbc, sessid) # record data if fc.again_or_next(var) == 'again': # if any violations made var.trialCounter += 1 # plus 1 in trialCounter var.totalTrialCounter += 1 # not in used here var.mergedTrialCounter += 1 # not in used here var.sameInitPos = True # next trial will use the same init position var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list continue # start over the same trial else: # if no violation made var.trialCounter += 1 # plus 1 in trialCounter (total trial num) var.blockTrialCounter += 1 # plus 1 in blockTrialCounter (trial num in current block) var.fixation_clicks = [] # reset fixation_clicks record list var.reward_clicks = [] # reset reward_clicks record list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list var.blockTrialCounter = 0 # reset blockTrialCounter to 0 for next block fc.show_bigCoins(var, myPoints) # show the total profits to the subjects var.dataFile.close() # close the data file fc.end_instruction_mixNon( doo) # give the ending instruciton to the subject endt = datetime.datetime.now() # record end time sql.w_after_mixNonALL( dbc, var, sessid, p_num, expDate, endt, expName, host_ip, setiddtb) # save the data of this session to database
def ShortVerbal(var, doo, myPoints, dbc, mouse, getName=True, sub_id=None, pre_points=0, pre_trials=0, pre_trialsCorrect=0): var.rewardGot = pre_trialsCorrect # if it's the second short verbal session in the experiment, rewardGot is accumulated from the first short verbal session var.trialCounter = pre_trials # if it's the second short verbal session in the experiment, trialCounter is accumulated from the first short verbal session var.points = pre_points # if it's the second short verbal session in the experiment, points are accumulated from the first short verbal session var.shortVerbal = True # specify short verbal for specific functions fc.setpath() # set up directory fN = os.path.basename(__file__) # get expName of this file expName, extN = os.path.splitext(fN) # get expName and extN stageName = expName[:-7] # get stageName expDate = datetime.datetime.now().strftime( "%Y-%m-%d_T%H_%M_%S") # get expDate sessid, p_num, p_net, setiddtb, host_ip, var, dbc = fc.exp_setup( var, doo, dbc, getName, sub_id, expName, expDate) # database setup and data start recording setupList = fc.verbalSetup( var.verbalTotalTrial, var.mag, var.shortmag ) # setup the reward of blocks for the whole experiment(same as in nonverbal) shuffledSetupList = copy.copy(setupList) # shuffle the reward list random.shuffle(shuffledSetupList) fc.stage_instruction(stageName, var, doo) # show subjects stage name (short delay) for i in range( len(shuffledSetupList)): # apply a reward mag for each block var.blockRewMag = shuffledSetupList[i][ 0] # assign reward mag for this block var.blockName = i + 1 # assign blockName fc.block_instruction(var, doo) # show block instruction to the subject while var.blockTrialCounter < shuffledSetupList[i][ 1]: # run pre-determined number of trials in each block var.rewmag = var.blockRewMag # assign reward mag if not var.sameInitPos: # get a new setup if no violation made in the last trial fc.getInitPos(var) fc.getFixmag(var) fc.getBluePos(var) var = fc.symmetricYBPair(var) fc.getDelayTime(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) if fc.again_or_next(var) == 'again': # if any violations made var.trialCounter += 1 # plus 1 in trialCounter var.sameInitPos = True # next trial will use the same init position var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list again = True else: # if no violation made var.trialCounter += 1 # plus 1 in trialCounter (total trial num) var.blockTrialCounter += 1 # plus 1 in blockTrialCounter (trial num in current block) var.fixation_clicks = [] # reset fixation_clicks record list var.reward_clicks = [] # reset reward_clicks record list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list again = False fc.dataRecord_shortVerbal(var, dbc, sessid) # record the data for this trial fc.resetVar(var, again) var.blockTrialCounter = 0 # reset blockTrialCounter fc.show_bigCoins(var, myPoints) # show the total profits to the subjects var.dataFile.close() # close the data file var.shortVerbal = False # reset shortVerbal boolean to be False endt = datetime.datetime.now() # record end time sql.w_after_Verbal(dbc, var, sessid, p_num, expDate, endt, expName, host_ip, setiddtb) # save data of this session in database return p_net, var.points, var.trialCounter, var.rewardGot
def stage5(session, var, doo, myPoints, dbc, mouse): fc.dataRecordStart5(var, dbc) var.stg = 5 # specify number of stage var.sessid = session highlowIndex = 0 # make high low reward delay index start from 0 var = fc.getKindHighLowList( var) # generate a high & low (6 in total) delay list var.rewardGot = 0 # reset rewardGot to 0 # the min and max delay trial block (6 trials) while var.rewardGot < var.highLowTrialNum: var.forcedTrial = True # set a boolean for later use if not var.sameInitPos: # get a new setup if no violation made in the last trial fc.getInitPos(var) var.rewmag = var.shortmag var = fc.get_forcedYellowPosCode(var) var = fc.getHighLowDelayTime_kind(var, highlowIndex) var = fc.getInitStimDis(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) fc.dataRecord5(var, dbc) # record data if fc.again_or_next(var) == 'again': # if any violations made var.forcedTrialCounter += 1 # plus 1 in forcedTrialCounter var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after min-max block) var.sameInitPos = True # next trial will use the same init position var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list continue # start over the same trial else: var.forcedTrialCounter += 1 # plus 1 in forcedTrialCounter var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after min-max block) highlowIndex += 1 # proceed to next high & low reward mag var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list var.forcedTrial = False # after forced trials, set this to False var.mergedTrialCounter = 0 # resert mergedTrialCounter # the orderly trials (10 trials) var.forcedTrial = True # boolean for forced trials inc = True while var.delayIndex <= len( var.delay ) and var.delayIndex >= 0: # go through all the ordered forced trials if not var.sameInitPos: # if no violation made in last trial if var.delayIndex < len( var.delay ) - 1: # let Delay magnitutude vary from 1 to 10 and back to 1 fc.getDelaymag(var) else: inc = False fc.getDelaymag(var) if inc: var.delayIndex += 1 else: var.delayIndex -= 1 # get variables for the new trial fc.getInitPos(var) fc.getFixmag(var) fc.get_forcedYellowPosCode(var) fc.getInitStimDis(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) fc.dataRecord5(var, dbc) # record data if fc.again_or_next(var) == 'again': # if any violations made var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after orderly forced block) var.sameInitPos = True # next trial will use the same init position var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list continue # start over the same trial else: var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after orderly forced block) var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.forcedTrial = False # after forced trials, set this to False var.mergedTrialCounter = 0 # resert mergedTrialCounter var.goodPokesInARoll = 0 # normal trials (4 trials correct to pass) while var.trialCounter < var.trial: # run given number of trials if not var.sameInitPos: # get a new setup if no violation made in the last trial fc.getInitPos(var) fc.getFixmag(var) fc.getYellowPos(var) fc.getHitmag(var) fc.getDelayTime(var) fc.getInitStimDis(var) var, doo, myPoints = fc.draw_initCircle( var, doo, myPoints) # start the first state while var.state != 'none': # go through all connected states in one trial mouse.clickReset() var, doo, myPoints = fc.funcDic[var.state](var, doo, myPoints) fc.dataRecord5(var, dbc) # record data if fc.again_or_next(var) == 'again': # if any violations made var.trialCounter += 1 # plus 1 in trialCounter var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after normal block) var.sameInitPos = True # next trial will use the same init position var.goodPokesInARoll = 0 # reset goodPokesInARoll to 0 var.fixation_clicks = [ ] # reset fixation_clicks(records the clicks during fixation) list var.reward_clicks = [ ] # reset reward_clicks(records the clicks during reward) list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list continue # start over the same trial else: # if no violation made var.trialCounter += 1 # plus 1 in trialCounter var.totalTrialCounter += 1 # plus 1 in totalTrialCounter var.mergedTrialCounter += 1 # # plus 1 in mergedTrialCounter (will be reset to 0 after normal block) var.fixation_clicks = [] # reset fixation_clicks record list var.reward_clicks = [] # reset reward_clicks record list var.delay_clicks = [ ] # reset delay_clicks(records the clicks during delay waiting time) list if fc.passStageTest( var) == 'pass': # if this stage is passed, break the loop break fc.show_bigCoins(var, myPoints) # show total coins earned return var