Exemple #1
0
 def saveManbar(self, n):
     """Save the state of the current manual bar as Manbar n in dimstim config file"""
     mbn = 'Manbar' + str(n)
     dc.set(mbn, 'xorigDeg', roundec(pix2deg(self.x - I.SCREENWIDTH / 2), ndec=6))
     dc.set(mbn, 'yorigDeg', roundec(pix2deg(self.y - I.SCREENHEIGHT / 2), ndec=6))
     dc.set(mbn, 'widthDeg', roundec(self.widthDeg, ndec=6))
     dc.set(mbn, 'heightDeg', roundec(self.heightDeg, ndec=6))
     dc.set(mbn, 'orioff', intround(self.ori))
     dc.update()
     self.fp.position = self.x, self.y
     self.brightenText = mbn # brighten the text for feedback
Exemple #2
0
 def updatestimuli(self):
     """Update stimuli"""
     # Update target params
     width = deg2pix(self.widthDeg) # convenience
     height = deg2pix(self.heightDeg)
     self.tp.position = self.x, self.y
     self.tp.size = width, height # convert to pix
     self.tp.orientation = self.ori
     self.tp.color = (self.brightness, self.brightness, self.brightness, 1.0)
     self.bgp.color = (self.bgbrightness, self.bgbrightness, self.bgbrightness, 1.0)
     self.cp.position = self.x, self.y # update center spot position
     self.wlp.position = I.SCREENWIDTH/2 - self.terrain.windowwidth, self.y #DW
     self.wrp.position = I.SCREENWIDTH/2 + self.terrain.windowwidth, self.y #DW
     
     # Update grating parms if grating is turned on
     if self.gp.on:
         self.gp.position = I.SCREENWIDTH/2,I.SCREENHEIGHT/2
         self.gp.orientation = self.gratingori
         sfreq = cycDeg2cycPix(self.sfreqCycDeg)
         try:
             self.phase
         except AttributeError: # phase hasn't been init'd yet
             """phaseoffset is req'd to make phase0 the initial phase at the centre of the grating, instead of at the edge of the grating as VE does. Take the distance from the centre to the edge along the axis of the sinusoid (which in this case is the height), multiply by spatial freq to get numcycles between centre and edge, multiply by 360 deg per cycle to get req'd phaseoffset. THE EXTRA 180 DEG IS NECESSARY FOR SOME REASON, DON'T REALLY UNDERSTAND WHY, BUT IT WORKS!!!"""
             phaseoffset = self.gratingHeight / 2 * sfreq * 360 + 180
             self.phase = -self.phase0 - phaseoffset
         phasestep = cycSec2cycVsync(self.tfreqCycSec * self.nscreens) * 360 # delta cycles per vsync, in degrees of sinusoid, adjust for buffer flips on multiple screens
         self.phase = self.phase - phasestep # update phase
         self.gp.spatial_freq = sfreq
         self.gp.phase_at_t0 = self.phase
         self.gp.contrast = self.contrast
         self.bgp.color = (self.bgbrightness, self.bgbrightness, self.bgbrightness, 1.0)
         self.cp.position = I.SCREENWIDTH/2, I.SCREENHEIGHT/2 # update center spot position
     
     # Update text params
     self.mbtp.text = 'x, y = (%5.1f, %5.1f) deg  |  size = (%.1f, %.1f) deg  |  ori = %5.1f deg' \
                      % ( pix2deg(self.x - I.SCREENWIDTH / 2), pix2deg(self.y - I.SCREENHEIGHT / 2),
                          self.widthDeg, self.heightDeg, self.ori)
     self.dtp.text = "%i Rewards | %.1f Rewards/minute " \
                     % (self.reward.rewardcount, 
                        self.reward.rewardcount/(self.sc.secondselapsed()+0.001)*60) #reward counter
     self.ttp.text = "Session time : %s" % str(self.sc.elapsed())[:10]  #shows session time
     
     if self.brightenText == 'Manbar0':
         self.mbtp.color = (1.0, 1.0, 0.0, 1.0) # set to yellow
     elif self.brightenText == 'Manbar1':
         self.mbtp.color = (1.0, 0.0, 0.0, 1.0) # set to red
     elif self.brightenText == 'Eye':
         self.stp.color = (1.0, 0.0, 0.0, 1.0) # set to red
     else:
         self.mbtp.color = (0.0, 1.0, 0.0, 1.0) # set it back to green
Exemple #3
0
    def updatestimuli(self):
        """Update stimuli"""
        # Update target params
        width = deg2pix(self.widthDeg)  # convenience
        height = deg2pix(self.heightDeg)
        self.tp.position = self.x, self.y
        self.tp.size = width, height  # convert to pix
        self.tp.orientation = self.ori
        self.tp.color = (self.brightness, self.brightness, self.brightness, 1.0)
        self.bgp.color = (self.bgbrightness, self.bgbrightness, self.bgbrightness, 1.0)
        self.tipp.position = (
            self.x + width / 2 * math.cos(math.pi / 180 * self.ori),
            self.y + width / 2 * math.sin(math.pi / 180 * self.ori),
        )
        self.tipp.orientation = self.ori
        self.cp.position = self.x, self.y  # update center spot position
        # Update text params
        self.mbtp.text = "x, y = (%5.1f, %5.1f) deg  |  size = (%.1f, %.1f) deg  |  ori = %5.1f deg" % (
            pix2deg(self.x - I.SCREENWIDTH / 2),
            pix2deg(self.y - I.SCREENHEIGHT / 2),
            self.widthDeg,
            self.heightDeg,
            self.ori,
        )
        self.stp.text = "Eye open: %s  |  " % C.EYESTATES[self.eyei] + self.screenstring

        if self.brightenText == "Manbar0":
            self.mbtp.color = (1.0, 1.0, 0.0, 1.0)  # set to yellow
        elif self.brightenText == "Manbar1":
            self.mbtp.color = (1.0, 0.0, 0.0, 1.0)  # set to red
        elif self.brightenText == "Eye":
            self.stp.color = (1.0, 0.0, 0.0, 1.0)  # set to red
        else:
            self.mbtp.color = (0.0, 1.0, 0.0, 1.0)  # set it back to green
            self.stp.color = (0.0, 1.0, 1.0, 1.0)  # set it back to cyan

        if self.squarelock:
            self.sltp.on = True
        else:
            self.sltp.on = False