Commits

Anonymous committed c98cbe9

Writing a more flexible,
modified version of D2
called Discrimination2_2.py

Comments (0)

Files changed (6)

Discrimination2_2.py

+from __init__ import *
+import random
+
+class Discrimination2(InternalEvent):
+    '''
+    Basic replication of the D2 program in BBC basic
+    '''
+
+    def __init__(self, startBlock = 0, sessionType = 'D2', listExperimentInfo = ['default','mouse','experiment','tech']): #add something to allow the starting block to be differnet
+        super(Discrimination2, self).__init__() 
+
+        self.curBlock = startBlock -1
+        self.initVars()
+        self.sessionType = sessionType
+        
+        self.strExperimentInfo = listExperimentInfo
+        self.dataFile = OutputData(self.strExperimentInfo[0], self.strExperimentInfo[1],self.strExperimentInfo[2], self.strExperimentInfo[3])
+        #self.startIti(self.itiTime)    
+        self.newBlock()
+    def initVars(self):
+        self.statesStarted = 8*[0]
+        self.curState = 0
+
+        self.curBlockHits = self.totalBlocks*[0] #met the interval threshold
+        self.curBlockMisses = self.totalBlocks*[0] #missed the interval threshold
+        self.curBlockFalseAlarms = self.totalBlocks*[0] #made the interval but didn't lick
+        self.curBlockCorRejs = self.totalBlocks*[0]
+        self.bTrialFinished = False
+        self.binRespList = -999
+        self.bReinforcement = False
+        self.bReinforcementAvailable = False
+        self.bItiReady = True
+        self.csPlusValve = 1
+        self.csMinusValve = 2
+        self.curTrialType = 'nan'
+        self.bContinuePhase = True
+        #self.trialsPerBlock = 20
+        
+        if self.sessionType == 'D2':
+            #simple semi-random alternation between S+ and S-
+            self.totalBlocks = 10
+            self.blockTypes = ['Warmup'] + 9*['D2']
+            self.itiTime = self.totalBlocks*[5]
+            
+        if self.sessionType == 'Int1':
+            self.blockTypes = 'N+'
+            self.itiTime = self.totalBlocks*[5]
+
+    def update(self):
+        self.updateInputs()
+        
+        curStateUpdate = getattr(self,'updateState%d' % self.curState)
+        curStateUpdate()
+        return self.bContinuePhase
+
+    
+    def updateState0(self):
+        #ITI Component
+        if self.statesStarted[self.curState] == False and self.bHeadIn == False:
+            self.statesStarted[self.curState] = True
+            self.curTrialType = self.curTrialBlockList[self.curTrialInBlock]
+#            if self.curBlock == 0 and self.curTrialInBlock < 10:
+#                self.curTrialType = 1
+                
+            if self.curTrialType == 1:
+                self.curValve =self.csPlusValve
+            elif self.curTrialType == 0:
+                self.curValve = self.csMinusValve
+            
+            print(self.curState)
+            print(self.statesStarted)
+            self.startIti(self.itiTime[self.curBlock])
+            
+            
+        if self.ItiTimerRun.countDownComplete() and self.bHeadIn == False:
+            self.endIti()
+            self.curState = 1
+            
+
+            
+    def updateState1(self):
+        #start of trial, wait for a head entry
+        #print('state1 start')
+        if self.statesStarted[self.curState] == False and self.bHeadIn == False:
+            self.statesStarted[self.curState] = True
+            self.lightOn()
+            
+        if self.statesStarted[self.curState] == True and self.bHeadIn == True:
+            self.curState = 2
+
+
+    def updateState2(self):
+        #turn on final valve and CS valve for 1 sec
+        if self.statesStarted[self.curState] == False:
+            self.statesStarted[self.curState] = True
+
+            self.finalValveOn()
+            self.valveOn(self.curValve)
+            self.valveTimer = RunInternalTimer(1)
+        if self.valveTimer.countDownComplete():
+            self.finalValveOff()
+            del self.valveTimer
+            self.curState = 3
+            
+    
+    def updateState3(self):
+        #after 2.5 s, turn off the CS valve
+        if self.statesStarted[self.curState] == False:
+            self.statesStarted[self.curState] = True
+            self.valveTimer = RunInternalTimer(2.5)
+        if self.valveTimer.countDownComplete():
+            self.valveOff(self.curValve)
+            self.curState = 4
+            
+    def updateState4(self):
+        #wait for 0.5 s, then start recording responses
+        if self.statesStarted[self.curState] == False:
+            self.statesStarted[self.curState] = True
+            self.samplingTimer = RunInternalTimer(0.5)
+        
+        if self.samplingTimer.countDownComplete():
+            del self.samplingTimer
+            
+            self.curState = 5
+            
+    def updateState5(self):
+        #discrimination trial record
+        if self.statesStarted[self.curState] == False:
+            self.statesStarted[self.curState] = True
+            self.curTrialRun = BinnedIntervalCount(2,0.2,0.6)
+        self.bTrialFinished, self.bReinforcementAvailable, self.binRespList \
+            = self.curTrialRun.update(self.bLickOn)
+        
+        if self.bTrialFinished == True:
+            self.curState = 6
+            
+    def updateState6(self):
+        self.statesStarted[self.curState] = True
+        if self.curTrialType == '+':
+            if self.bReinforcementAvailable == True:
+                self.curBlockHits[self.curBlock] += 1
+                self.curState = 7            
+            else:
+                self.curBlockMisses[self.curBlock] += 1
+                self.curState = 8
+        elif self.curTrialType == '-':
+            if self.bReinforcementAvailable == True:
+                self.curBlockFalseAlarms[self.curBlock] +=1
+            else:
+                self.curBlockCorRejs[self.curBlock] +=1
+            self.curState = 8
+        else:
+            print 'Unknown Trial Type'
+                
+            
+    def updateState7(self):
+        #reinforcement state
+        if self.statesStarted[self.curState] == False:
+            self.statesStarted[self.curState] = True
+            self.bReinforcement = True
+            self.reinforceOn()
+            print 'reinforcer'
+        self.bReinforcement = self.reinforceUpdate()
+        if self.bReinforcement == False:
+            self.curState = 8            
+        
+    def updateState8(self):
+        #end of trial state
+        print 'end trial'
+        self.lightOff()
+        self.checkBlockCount()
+        del self.curTrialRun    
+        if self.bContinuePhase == True:
+            self.statesStarted = 8*[0]
+            self.curState = 0
+        
+        
+    def checkBlockCount(self):
+        self.curTrialInBlock += 1
+        if self.curTrialInBlock > self.trialsPerBlock - 1: #-
+            self.newBlock()            
+            
+            print 'end of block'
+        if self.curBlock > self.totalBlocks:
+            self.reinforcerShutDown()
+            self.bContinuePhase = False
+            print'end of Phase'
+            
+        
+    def newBlock(self):
+        self.curBlock += 1
+        self.curTrialInBlock = 0
+        self.curTrialBlockList = self.determineTrialOrderWithinBlock()
+        self.trialsPerBlock = self.curTrialBlockList.__len__()
+        self.writeData()
+        
+    def writeData(self):
+        strWriteHits = 'SUMMARY, HITS, ' + str(self.curBlockHits)
+        strWriteMisses = 'SUMMARY, MISS, ' + str(self.curBlockMisses)
+        strWriteFA = 'SUMMARY, FALS, ' + str(self.curBlockFalseAlarms)
+        strWriteCR = 'SUMMARY, CORJ, ' + str(self.curBlockCorRejs)
+        self.dataFile.writeData(strWriteHits)
+        self.dataFile.writeData(strWriteMisses)
+        self.dataFile.writeData(strWriteFA)
+        self.dataFile.writeData(strWriteCR)
+        
+    def determineTrialOrderWithinBlock(self, blockType):
+        '''
+        Trials here are divided into '1' and '0', where 
+        '+' trials are S+
+        '-' trials are S-
+        'N+' trials are reinforced Neutral Trials
+        'N-' trials are unreinforced Neutral Trials
+        
+        trialBlockLength should be a multiple of 4 for D2
+        '''
+        
+        if blockType == 'D2':
+            #20 trials
+            basicList = ['+','+','-','-']
+            trialListInBlock = []
+           # repeatingOfBasicList = round(trialBlockLength / basicList.__len__())
+            
+            for i in range(5):
+                randomList = random.sample(basicList,4)
+                trialListInBlock = trialListInBlock + randomList
+        elif blockType == 'Warmup':
+            #Ten Trials of Normal
+            trialListInBlock = 10*['+']
+            
+        elif blockType == 'N1.0':
+            trialListInBlock = 10*['N+']
+            
+        elif blockType == 'N8.0':
+            trialListInBlock = 8*['N+'] + 2*['N-']
+
+        elif blockType == 'N6.0':
+            trialListInBlock = 6*['N+'] + 4*['N-']
+            
+            
+        else:
+            trialListInBlock = -9999
+            print('WRONG blockType INPUT')    
+        return trialListInBlock
+        
         #self.trialLengthByBlock = [0.2,0.2,0.4,0.4,0.6,0.6,0.8,1.0,1.2,1.2]
         #self.itiTime = [0.5,1,1,2,2,3,3,4,4,5]
         #self.hitsCriterion = [10,10,20,20,20,20,20,20,20,60]
-        self.trialLengthByBlock = [0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.2,1.2,1.2,1.2]
-        self.hitsCriterion = 15*[9]
-        self.itiTime = 11*[1] + [1.5,2,3,4]
+        self.trialLengthByBlock = [0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0]
+        self.hitsCriterion = 20*[9]
+        self.itiTime = 16*[1] + [1.5,2,3,4,5]
         #self.trialLengthByBlock = [1.2]
         self.blockCount = self.trialLengthByBlock.__len__()
               #this should start short and get longer first
             boolean = True
             b =  getattr(self, offFun)      
             b()
-            return boolean                 
-    
+            return boolean
+              
+    def writeData():
+        pass
 
 
 
 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.  
         self.c = Communicate()
         self.initVars()
         
+        
     def initVars(self):
         """Initialize all variables here."""
         self.bSesStart = False
         self.bDisc2 = False
         #self.bCurPhase = False
         self.setWaterTime()
+        self.curPhase = InternalEvent()
         
     def commitTextFile(self):
         subjName = self.teSubjectName.toPlainText()
         
     def quitApp(self):
         self.turnAllOff()
+        self.curPhase.writeData()
         QtCore.QCoreApplication.instance().quit()
         
     def turnAllOff(self):
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>801</width>
+    <width>989</width>
     <height>780</height>
    </rect>
   </property>
      <rect>
       <x>10</x>
       <y>10</y>
-      <width>671</width>
+      <width>741</width>
       <height>711</height>
      </rect>
     </property>
         <height>31</height>
        </rect>
       </property>
+      <property name="tabChangesFocus">
+       <bool>true</bool>
+      </property>
      </widget>
      <widget class="QPlainTextEdit" name="teFileName">
       <property name="geometry">
         <height>31</height>
        </rect>
       </property>
+      <property name="tabChangesFocus">
+       <bool>true</bool>
+      </property>
      </widget>
      <widget class="QPlainTextEdit" name="teTechName">
       <property name="geometry">
         <height>31</height>
        </rect>
       </property>
+      <property name="tabChangesFocus">
+       <bool>true</bool>
+      </property>
      </widget>
      <widget class="QPlainTextEdit" name="teExperimentName">
       <property name="geometry">
         <height>31</height>
        </rect>
       </property>
+      <property name="tabChangesFocus">
+       <bool>true</bool>
+      </property>
      </widget>
      <widget class="QPushButton" name="btnSesInfoCommit">
       <property name="geometry">
        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
       </property>
      </widget>
+     <widget class="QSpinBox" name="sbCSplus">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>350</y>
+        <width>42</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <number>4</number>
+      </property>
+     </widget>
+     <widget class="QLabel" name="lblWaterTime">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>610</y>
+        <width>151</width>
+        <height>31</height>
+       </rect>
+      </property>
+      <property name="font">
+       <font>
+        <pointsize>10</pointsize>
+       </font>
+      </property>
+      <property name="text">
+       <string>Water Activation Time:</string>
+      </property>
+      <property name="wordWrap">
+       <bool>true</bool>
+      </property>
+     </widget>
+     <widget class="QDoubleSpinBox" name="dsbWaterTime">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>640</y>
+        <width>62</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <double>0.010000000000000</double>
+      </property>
+      <property name="maximum">
+       <double>0.500000000000000</double>
+      </property>
+      <property name="singleStep">
+       <double>0.050000000000000</double>
+      </property>
+      <property name="value">
+       <double>0.100000000000000</double>
+      </property>
+     </widget>
+     <widget class="QSpinBox" name="sbCSminus">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>380</y>
+        <width>42</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <number>4</number>
+      </property>
+      <property name="value">
+       <number>2</number>
+      </property>
+     </widget>
+     <widget class="QSpinBox" name="sbGen_1">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>410</y>
+        <width>42</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <number>4</number>
+      </property>
+      <property name="value">
+       <number>3</number>
+      </property>
+     </widget>
+     <widget class="QSpinBox" name="sbGen_2">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>440</y>
+        <width>42</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <number>4</number>
+      </property>
+      <property name="value">
+       <number>4</number>
+      </property>
+     </widget>
+     <widget class="QSpinBox" name="sbNeutral">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>470</y>
+        <width>42</width>
+        <height>22</height>
+       </rect>
+      </property>
+      <property name="minimum">
+       <number>1</number>
+      </property>
+      <property name="maximum">
+       <number>4</number>
+      </property>
+      <property name="value">
+       <number>3</number>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_3">
+      <property name="geometry">
+       <rect>
+        <x>80</x>
+        <y>330</y>
+        <width>71</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>Valve Number</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_4">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>350</y>
+        <width>41</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="text">
+       <string>CS+:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_5">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>380</y>
+        <width>41</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="text">
+       <string>CS- :</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_6">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>410</y>
+        <width>41</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="text">
+       <string>Gen S1:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_7">
+      <property name="geometry">
+       <rect>
+        <x>30</x>
+        <y>440</y>
+        <width>41</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="text">
+       <string>Gen S2:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_8">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>470</y>
+        <width>61</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="text">
+       <string>Neutral S:</string>
+      </property>
+      <property name="alignment">
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
+     </widget>
     </widget>
     <widget class="QWidget" name="tabInSes">
      <attribute name="title">
      <widget class="QWidget" name="gridLayoutWidget_2">
       <property name="geometry">
        <rect>
-        <x>190</x>
-        <y>50</y>
+        <x>270</x>
+        <y>40</y>
         <width>451</width>
         <height>576</height>
        </rect>
        <item row="10" column="0">
         <widget class="QLabel" name="lblEct11">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="17" column="0">
         <widget class="QLabel" name="lblEct18">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="13" column="0">
         <widget class="QLabel" name="lblEct14">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="15" column="0">
         <widget class="QLabel" name="lblEct16">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="5" column="0">
         <widget class="QLabel" name="lblEct6">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="18" column="0">
         <widget class="QLabel" name="lblEct19">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="4" column="0">
         <widget class="QLabel" name="lblEct5">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="12" column="0">
         <widget class="QLabel" name="lblEct13">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="9" column="0">
         <widget class="QLabel" name="lblEct10">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="8" column="0">
         <widget class="QLabel" name="lblEct9">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="14" column="0">
         <widget class="QLabel" name="lblEct15">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="11" column="0">
         <widget class="QLabel" name="lblEct12">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="3" column="0">
         <widget class="QLabel" name="lblEct4">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="1" column="0">
         <widget class="QLabel" name="lblEct2">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="16" column="0">
         <widget class="QLabel" name="lblEct17">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="7" column="0">
         <widget class="QLabel" name="lblEct8">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="6" column="0">
         <widget class="QLabel" name="lblEct7">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="2" column="0">
         <widget class="QLabel" name="lblEct3">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
        <item row="0" column="0">
         <widget class="QLabel" name="lblEct1">
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
           </font>
          </property>
          <property name="text">
-          <string> </string>
+          <string/>
          </property>
         </widget>
        </item>
       <property name="geometry">
        <rect>
         <x>10</x>
-        <y>210</y>
+        <y>250</y>
         <width>141</width>
         <height>41</height>
        </rect>
       <property name="geometry">
        <rect>
         <x>10</x>
-        <y>260</y>
+        <y>300</y>
         <width>141</width>
         <height>41</height>
        </rect>
      <widget class="QLabel" name="label_2">
       <property name="geometry">
        <rect>
-        <x>330</x>
-        <y>30</y>
+        <x>410</x>
+        <y>20</y>
         <width>141</width>
         <height>16</height>
        </rect>
      <widget class="QLCDNumber" name="lcdTimeCnt">
       <property name="geometry">
        <rect>
-        <x>590</x>
+        <x>180</x>
         <y>650</y>
         <width>71</width>
         <height>31</height>
      <widget class="QLabel" name="lblTimeLabel">
       <property name="geometry">
        <rect>
-        <x>420</x>
+        <x>10</x>
         <y>660</y>
         <width>191</width>
         <height>16</height>
        <string>Time in Session (min):</string>
       </property>
      </widget>
-     <widget class="QDoubleSpinBox" name="dsbWaterTime">
+     <widget class="QPushButton" name="btnStartDisc2Initial">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
       <property name="geometry">
        <rect>
         <x>10</x>
-        <y>550</y>
-        <width>62</width>
-        <height>22</height>
+        <y>200</y>
+        <width>141</width>
+        <height>41</height>
        </rect>
       </property>
-      <property name="minimum">
-       <double>0.010000000000000</double>
-      </property>
-      <property name="maximum">
-       <double>0.500000000000000</double>
-      </property>
-      <property name="singleStep">
-       <double>0.050000000000000</double>
-      </property>
-      <property name="value">
-       <double>0.100000000000000</double>
-      </property>
-     </widget>
-     <widget class="QLabel" name="lblWaterTime">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>520</y>
-        <width>151</width>
-        <height>31</height>
-       </rect>
-      </property>
-      <property name="font">
-       <font>
-        <pointsize>10</pointsize>
-       </font>
-      </property>
       <property name="text">
-       <string>Water Activation Time:</string>
-      </property>
-      <property name="wordWrap">
-       <bool>true</bool>
+       <string>Start D2 Initial Training</string>
       </property>
      </widget>
     </widget>
    <widget class="QPushButton" name="btnClose">
     <property name="geometry">
      <rect>
-      <x>710</x>
-      <y>10</y>
+      <x>790</x>
+      <y>0</y>
       <width>81</width>
       <height>31</height>
      </rect>
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>801</width>
+     <width>989</width>
      <height>21</height>
     </rect>
    </property>
-"""
-Created on Sat Jun 22 14:04:17 2013
 
-@author: Ryan Brackney
+import numpy
 
-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)
+self.totalBlocks = 10
+self.itiTime #list by block
+self.trialsPerBlock 
 
-"""
 
-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
-from PyQt4 import QtCore, QtGui
-from __init__ import *
-import Phase1,Phase3
-
-USE_QT_DESIGNER = True
-
-class Communicate(QtCore.QObject):
-    '''
-    not used at the moment
-    '''
-    lickOn = QtCore.pyqtSignal()
-    headEntry = QtCore.pyqtSignal()
-    reinforce = QtCore.pyqtSignal()
-    
-class Master(object):
-    def __init__(self,main_window):
-        self.main_window = main_window
-        self.central_widget = main_window.centralWidget()
-        self.c = Communicate()
-        self.initVars()
-        
-    def initVars(self):
-        """Initialize all variables here."""
-        self.bSesStart = False
-        self.bPhase1 = False    
-        self.bPhase3 = 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 respBtnClicked(self):
-        self.curPhase.lickOn()  
-    
-    def headEntryBtnClicked(self):
-        self.curPhase.toggleHeadEntry()
-    
-    def disableStartButtons(self):
-        self.central_widget.btnStartPhase3.setEnabled(False)
-        self.central_widget.btnStartPhase1.setEnabled(False)        
-    
-    def startPhase1(self):
-        self.startSession()
-        self.bPhase1 = True
-        self.curPhase = Phase1.Phase1(30) #start Phase 1 with 30 trials
-        self.disableStartButtons()
-        self.central_widget.btnHead.setEnabled(True)
-        self.central_widget.btnResp.setEnabled(True)
-    
-    def startPhase3(self):
-        self.startSession()
-        self.bPhase3 = True
-        self.curPhase = Phase3.Phase3()
-        self.disableStartButtons()
-        self.central_widget.btnHead.setEnabled(True)
-        self.central_widget.btnResp.setEnabled(True)
-
-    def startSession(self):
-        self.DataFile = OutputData()
-        self.timingInit()
-        print('Session start')   
-
-    def updateDisplay(self): 
-        """This should be text and numeric controls in Qt Designer."""     
-        if self.bPhase3 == True:
-            ect1Display = 'Head In: ' + str(self.curPhase.bHeadIn)
-            ect2Display = 'ITI On: ' + str(self.curPhase.bITI) 
-            ect3Display = 'Waiting for Lick to Reinforce: ' + str(self.curPhase.bReinforcementAvailable)
-            ect4Display = 'Current Block Number:' + str(self.curPhase.curBlock)
-            ect5Display = 'Current Block Misses: '  + str(self.curPhase.curBlockMisses)    
-            ect6Display = 'Current Block Abstains: ' + str(self.curPhase.curBlockAbstain)    
-            ect7Display = 'Current Block Hits: ' + str(self.curPhase.curBlockHits)
-            ect8Display = 'Current Block Hits Criterion' + str(self.curPhase.hitCriterion)
-            ect9Display = 'bTrialStart: ' + str(self.curPhase.bTrialStart)
-            ect10Display = 'bTrialFinished: ' + str(self.curPhase.bTrialFinished)
-            ect11Display = 'bContinuePhase: ' + str(self.curPhase.bContinuePhase)
-            ect12Display = 'Response Path: ' + str(self.curPhase.binRespList)
-            ect13Display = 'Current Response Criterion: ' + str(self.curPhase.trialLengthByBlock[self.curPhase.curBlock -1])
-            ect14Display = 'Current ITI: ' + str(self.curPhase.itiTime[self.curPhase.curBlock -1])
-            ect15Display = ''
-            ect16Display = ''
-            ect17Display = ''
-            ect18Display = ''
-            ect19Display = ''
-
-            
-            for i in range(19):
-                label = getattr(self.central_widget,'lblEct%d' % (i+1))
-                label.setText(ect1Display) 
-            
-        self.ect20Display = 'Phase 3 On: ' + str(self.bPhase3)
-        self.central_widget.lblEct20.setText(self.ect20Display)   
-        
-    def timerEvent(self,event):
-        """Main Loop. Runs the 'update' methods of Phase1/Phase3/etc."""
-        self.curSestime = self.iTime.timeSince()
-        self.central_widget.lcdTimeCnt.display(round(self.curSestime,2))       
-        ###
-        
-        if self.bPhase1 == True:
-            self.bPhase1, self.hits, self.misses = self.curPhase.update()
-        if self.bPhase3 == True:
-            self.bPhase3 = self.curPhase.update()
-        self.updateDisplay()
-
-def initUI(widget):
-    """All of this should be moved into Qt Designer and auto generated."""
-    widget.btnHead = QtGui.QPushButton('Sim Head Entry', widget)
-    widget.btnResp = QtGui.QPushButton('Sim Lick', widget)
-    widget.btnClose = QtGui.QPushButton('Close', widget)
-    
-    widget.btnStartPhase1 = QtGui.QPushButton('Start Phase 1')
-    widget.btnStartPhase3 = QtGui.QPushButton('Start Phase 3')
-#     
-    widget.lblTimeLabel = QtGui.QLabel(widget)
-    widget.lcdTimeCnt = QtGui.QLCDNumber(widget)
-    for i in range(20):
-        setattr(widget,'lblEct%d' % (i+1),QtGui.QLabel(widget))
-    
-    vbox = QtGui.QVBoxLayout()
-    vbox.addWidget(widget.lblTimeLabel)
-    vbox.addWidget(widget.lcdTimeCnt)
-    vbox.addWidget(widget.btnResp)
-    vbox.addWidget(widget.btnHead)
-    vbox.addWidget(widget.btnStartPhase1)
-    vbox.addWidget(widget.btnStartPhase3)
-
-    for i in range(20):
-        vbox.addWidget(getattr(widget,'lblEct%d' % (i+1)))
-    vbox.addWidget(widget.btnClose)
-
-    widget.lblTimeLabel.setText('Session Time (s)')
-    
-    widget.btnHead.setEnabled(False)
-    widget.btnResp.setEnabled(False)
-
-    #widget.btnStartPhase1.setEnabled(False)
-    widget.setLayout(vbox)
-    widget.setGeometry(300, 300, 300, 300)
-    widget.setWindowTitle('Main')
-
-def initConnect(widget,master):
-    widget.btnResp.clicked.connect(master.respBtnClicked)
-    widget.btnClose.clicked.connect(QtCore.QCoreApplication.instance().quit)
-    widget.btnHead.clicked.connect(master.headEntryBtnClicked)
-    widget.btnStartPhase1.clicked.connect(master.startPhase1)
-    widget.btnStartPhase3.clicked.connect(master.startPhase3)
-            
-def main():
-    """The entry point to the application"""
-    app = QtGui.QApplication(sys.argv)
-    main_window = QtGui.QMainWindow()
-    ui = Ui_MainWindow()
-    ui.setupUi(main_window)
-    central_widget = main_window.centralWidget()
-    initUI(central_widget)
-    master = Master(main_window)
-    initConnect(central_widget,master)    
-    main_window.show()
-    sys.exit(app.exec_())
-
-if __name__ == '__main__':
-    main()