Commits

ryan...@asu.edu  committed 97d3ab1

Removed __main__.py

  • Participants
  • Parent commits 326972d

Comments (0)

Files changed (1)

File __main__.py

-"""
-Created on Sat Jun 22 14:04:17 2013
-
-@author: Ryan Brackney
-
-To do:
-Get it working QtDesigner
-Figure out python crash on exit
-Get input fields for mouse name/experiment info/ect
-Allow Phase 3 to start at different stages
-Implement microcontroller support (wrapper currently working)
-Implement the text file output (code written, just not integrated yet)
-
-"""
-
-import sys,os
-# Add this file's directory to the python path.  
-sys.path.append(os.path.abspath(os.path.dirname(__file__))) 
-import random
-import time
-from qt.gui import Ui_MainWindow
-# Eventually you will want to replace 'Primary' with the auto-generated 'Ui_MainWindow'
-from PyQt4 import QtCore, QtGui
-from __init__ import *
-import Phase1, Phase3, Box_Test, Discrimination2
-
-USE_QT_DESIGNER = False
-
-class Communicate(QtCore.QObject):
-    '''
-    not used at the moment
-    '''
-    lickOn = QtCore.pyqtSignal()
-    headEntry = QtCore.pyqtSignal()
-    reinforce = QtCore.pyqtSignal()
-    
-class My_MainWindow(QtGui.QWidget):
-    def __init__(self):
-        super(My_MainWindow, self).__init__()        
-        #MainWindow = QtGui.QMainWindow()
-        #self.setupUi(MainWindow)
-
-        self.c = Communicate()
-        self.initUI()
-        self.initVars()
-        self.initConnect()        
-        
-    def initUI(self):
-        self.btnHead = QtGui.QPushButton('Sim Head Entry',self)
-        self.btnResp = QtGui.QPushButton('Sim Lick', self)
-        self.btnClose = QtGui.QPushButton('Close', self)
-        
-        self.btnStartPhase1 = QtGui.QPushButton('Start Phase 1')
-        self.btnStartPhase3 = QtGui.QPushButton('Start Phase 3')
-        self.btnStartDisc2 = QtGui.QPushButton('Start D2')
-        self.btnBoxTest = QtGui.QPushButton('Start Box Test')
-        self.btnDeliverR = QtGui.QPushButton('Activate Reinforcer')
-        
-        self.lblTimeLabel = QtGui.QLabel(self)
-        self.lcdTimeCnt = QtGui.QLCDNumber(self)
-        for i in range(20):
-            setattr(self,'lblEct%d' % (i+1),QtGui.QLabel(self))
-        
-        vbox = QtGui.QVBoxLayout()
-        vbox.addWidget(self.lblTimeLabel)
-        vbox.addWidget(self.lcdTimeCnt)
-        vbox.addWidget(self.btnResp)
-        vbox.addWidget(self.btnHead)
-        vbox.addWidget(self.btnDeliverR)
-        vbox.addWidget(self.btnStartPhase1)
-        vbox.addWidget(self.btnStartPhase3)
-        vbox.addWidget(self.btnBoxTest)
-        vbox.addWidget(self.btnStartDisc2)
-        
-
-        for i in range(20):
-            vbox.addWidget(getattr(self,'lblEct%d' % (i+1)))
-        vbox.addWidget(self.btnClose)
-
-        self.lblTimeLabel.setText('Session Time (s)')
-        
-        self.btnHead.setEnabled(False)
-        self.btnResp.setEnabled(False)
-        self.btnDeliverR.setEnabled(False)
-        
-        #self.btnStartPhase1.setEnabled(False)
-        self.setLayout(vbox)
-        self.setGeometry(300, 300, 300, 300)
-        self.setWindowTitle('Main')
-    
-    def initConnect(self):
-        self.btnResp.clicked.connect(self.respBtnClicked)
-        self.btnClose.clicked.connect(self.quitApp)
-        self.btnHead.clicked.connect(self.headEntryBtnClicked)
-        self.btnStartPhase1.clicked.connect(self.startPhase1)
-        self.btnStartPhase3.clicked.connect(self.startPhase3)
-        self.btnBoxTest.clicked.connect(self.startBoxTest)
-        self.btnDeliverR.clicked.connect(self.deliveryReinf)    
-        self.btnStartDisc2.clicked.connect(self.startDisc2)
-        
-    def initVars(self):#
-        '''
-        start all variables here
-        '''
-        self.bSesStart = False
-        self.bPhase1 = False    
-        self.bPhase3 = False
-        self.bBoxTest = False         
-        self.bDisc2 = False
-        
-    def timingInit(self):
-        self.timer = QtCore.QBasicTimer()
-        self.timer.start(10, self) #this should start the timer
-        self.iTime = RunInternalTimer()
-#        print(self.curTrialTime)
-
-    def quitApp(self):
-        self.turnAllOff()
-        QtCore.QCoreApplication.instance().quit()
-        
-        
-    def turnAllOff(self):
-        ie = InternalEvent()
-        for i in range(3):
-            ie.valveOff(i+1)
-        ie.finalValveOff()
-        #ie.toneOff()
-        ie.lightOff()
-        ie.outsideEvent.reinforceOff()
-        
-        
-    def respBtnClicked(self):
-        self.curPhase.lickOn()  
-    
-    def headEntryBtnClicked(self):
-        self.curPhase.toggleHeadEntry()
-    
-    def disableStartButtons(self):
-        self.btnStartPhase3.setEnabled(False)
-        self.btnStartPhase1.setEnabled(False)        
-    
-    def startPhase1(self):
-        self.startSession()
-        self.bPhase1 = True
-        self.curPhase = Phase1.Phase1(20) #start Phase 1 with 30 trials
-        self.disableStartButtons()
-        self.btnHead.setEnabled(True)
-        self.btnResp.setEnabled(True)
-    
-    def startPhase3(self):
-        self.startSession()
-        self.bPhase3 = True
-        self.curPhase = Phase3.Phase3(1)
-        self.disableStartButtons()
-        self.btnHead.setEnabled(True)
-        self.btnResp.setEnabled(True)
-        
-    def startDisc2(self):
-        self.startSession()
-        self.curPhase = Discrimination2.Discrimination2()
-        self.bDisc2 = True
-
-
-    def startBoxTest(self):
-        self.startSession()
-        self.bBoxTest = True
-        self.curPhase = Box_Test.Box_Test()
-        self.btnHead.setEnabled(True)
-        self.btnResp.setEnabled(True)
-        self.btnDeliverR.setEnabled(True)   
-
-    def startSession(self):
-        self.DataFile = OutputData()
-        self.timingInit()
-        print('ses start')   
-
-    def deliveryReinf(self):
-        self.curPhase.reinforceOn()        
-
-    def updateDisplay(self):
-        if self.bPhase1 == True:
-            self.ectDisplay1 = 'Hits: ' + str(self.hits) #these should be changed to come in line with the 'cur phase' bit that minimizes the need for returns
-            self.ectDisplay2 = 'Misses: ' + str(self.misses)
-            self.ectDisplay3 = 'Phase1 On: ' + str(self.bPhase1)            
-            self.lblEct1.setText(self.ectDisplay1)
-            self.lblEct2.setText(self.ectDisplay2)
-            self.lblEct3.setText(self.ectDisplay3)
-        
-        if self.bPhase3 == True:
-            self.ectDisplay1 = 'Head In: ' + str(self.curPhase.bHeadIn)
-            self.ectDisplay2 = 'ITI On: ' + str(self.curPhase.bITI) 
-            self.ectDisplay3 = 'Waiting for Lick to Reinforce: ' + str(self.curPhase.bReinforcementAvailable)
-            self.ectDisplay4 = 'Current Block Number:' + str(self.curPhase.curBlock)
-            self.ectDisplay5 = 'Current Block Misses: '  + str(self.curPhase.curBlockMisses)    
-            self.ectDisplay6 = 'Current Block Abstains: ' + str(self.curPhase.curBlockAbstain)    
-            self.ectDisplay7 = 'Current Block Hits: ' + str(self.curPhase.curBlockHits)
-            self.ectDisplay8 = 'Current Block Hits Criterion: ' + str(self.curPhase.hitsCriterion)
-            self.ectDisplay9 = 'bTrialStart: ' + str(self.curPhase.bTrialStart)
-            self.ectDisplay10 = 'bTrialFinished: ' + str(self.curPhase.bTrialFinished)
-            self.ectDisplay11 = 'bContinuePhase: ' + str(self.curPhase.bContinuePhase)
-            self.ectDisplay12 = 'Response Path: ' + str(self.curPhase.binRespList)
-            self.ectDisplay13 = 'Current Response Criterion: ' + str(self.curPhase.trialLengthByBlock[self.curPhase.curBlock -1])
-            self.ectDisplay14 = 'Current ITI: ' + str(self.curPhase.itiTime[self.curPhase.curBlock -1])
-            self.ectDisplay15 = 'Current Time in ITI ' + str(self.curPhase.ItiTimerRun.countDownTime())
-            self.ectDisplay16 = 'States Started: ' + str(self.curPhase.statesStarted)
-            self.ectDisplay17 = ''
-            self.ectDisplay18 = ''
-            self.ectDisplay19 = ''
-            
-            
-            for i in range(19):
-                label = getattr(self,'lblEct%d' % (i+1))
-                labelText = getattr(self,'ectDisplay%d' % (i+1) )
-                label.setText(labelText)
-                
-        if self.bDisc2 == True:
-            self.ectDisplay1 = 'Head In: ' + str(self.curPhase.bHeadIn)
-            self.ectDisplay2 = 'ITI On: ' + str(self.curPhase.bITI) 
-            self.ectDisplay3 = 'Waiting for Lick to Reinforce: ' + str(self.curPhase.bReinforcementAvailable)
-            self.ectDisplay4 = 'Current Block Number: ' + str(self.curPhase.curBlock + 1)
-            self.ectDisplay5 = 'Current Trial Type (CS+ = 1, CS- = 0): ' + str(self.curPhase.curTrialType)
-            self.ectDisplay6 = 'Current Trial In Block: ' + str(self.curPhase.curTrialInBlock)
-            self.ectDisplay7 = 'Current Block Hits: ' + str(self.curPhase.curBlockHits)
-            self.ectDisplay8 = 'Current Block Correct Rejections: ' + str(self.curPhase.curBlockCorRejs)
-            self.ectDisplay9 = 'Current Block Misses: '  + str(self.curPhase.curBlockMisses)   
-            self.ectDisplay10 = 'Current Block False Alarms: ' + str(self.curPhase.curBlockFalseAlarms) 
-            self.ectDisplay11 = 'bContinuePhase: ' + str(self.curPhase.bContinuePhase)
-            self.ectDisplay12 = 'CS+ Valve: ' + str(self.curPhase.csPlusValve)
-            self.ectDisplay13 = 'CS- Valve: ' + str(self.curPhase.csMinusValve)
-            self.ectDisplay14 = ''
-            self.ectDisplay15 = ''
-            self.ectDisplay16 = ''
-            self.ectDisplay17 = ''
-            self.ectDisplay18 = 'Binned Resps on Trial: ' + str(self.curPhase.binRespList)
-            self.ectDisplay19 = 'States Started: ' + str(self.curPhase.statesStarted)
-            
-            for i in range(19):
-                label = getattr(self,'lblEct%d' % (i+1))
-                labelText = getattr(self,'ectDisplay%d' % (i+1) )
-                label.setText(labelText)
-            
-        self.ectDisplay20 = 'Phase 3 On: ' + str(self.bPhase3)
-        self.lblEct20.setText(self.ectDisplay20)   
-        
-    def timerEvent(self,event):
-        '''
-        Main Loop. Runs the 'update' methods of Phase1/Phase3/ect
-        '''
-        self.curSestime = self.iTime.timeSince()
-        self.lcdTimeCnt.display(round(self.curSestime,2))       
-        ###
-        
-        if self.bPhase1 == True:
-            self.bPhase1, self.hits, self.misses = self.curPhase.update()
-            if self.bPhase1 == False:
-                self.startPhase3(self)
-        if self.bPhase3 == True:
-            self.bPhase3 = self.curPhase.update()
-        if self.bBoxTest == True:
-            self.bBoxTest == self.curPhase.update()            
-        if self.bDisc2 == True:
-            self.bDisc2 == self.curPhase.update()
-        self.updateDisplay()
-            
-def main():
-    """The entry point to the application"""
-    app = QtGui.QApplication(sys.argv)
-    if USE_QT_DESIGNER:
-        #ui = My_MainWindow()
-        MainWindow = QtGui.QMainWindow()
-        ui = Ui_MainWindow()
-        ui.setupUi(MainWindow)
-    else:
-        MainWindow = My_MainWindow()
-    MainWindow.show()
-    sys.exit(app.exec_())
-
-if __name__ == '__main__':
-    main()