• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python monitorunittools.deg2pix函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中psychopy.tools.monitorunittools.deg2pix函数的典型用法代码示例。如果您正苦于以下问题:Python deg2pix函数的具体用法?Python deg2pix怎么用?Python deg2pix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了deg2pix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _calcFieldCoordsRendered

 def _calcFieldCoordsRendered(self):
     if self.units in ['norm', 'pix','height']:
         self._fieldSizeRendered=self.fieldSize
         self._fieldPosRendered=self.fieldPos
     elif self.units in ['deg', 'degs']:
         self._fieldSizeRendered=deg2pix(self.fieldSize, self.win.monitor)
         self._fieldPosRendered=deg2pix(self.fieldPos, self.win.monitor)
     elif self.units=='cm':
         self._fieldSizeRendered=cm2pix(self.fieldSize, self.win.monitor)
         self._fieldPosRendered=cm2pix(self.fieldPos, self.win.monitor)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:10,代码来源:elementarray.py


示例2: _calcVerticesRendered

 def _calcVerticesRendered(self):
     self.needVertexUpdate=False
     if self.units in ['norm', 'pix', 'height']:
         self._verticesRendered=self.vertices
         self._posRendered=self.pos
     elif self.units in ['deg', 'degs']:
         self._verticesRendered=deg2pix(self.vertices, self.win.monitor)
         self._posRendered=deg2pix(self.pos, self.win.monitor)
     elif self.units=='cm':
         self._verticesRendered=cm2pix(self.vertices, self.win.monitor)
         self._posRendered=cm2pix(self.pos, self.win.monitor)
     self._verticesRendered = self._verticesRendered * self.size
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:12,代码来源:shape.py


示例3: setHeight

 def setHeight(self,height, log=True):
     """Set the height of the letters (including the entire box that surrounds the letters
     in the font). The width of the letters is then defined by the font.
     """
     #height in pix (needs to be done after units)
     if self.units=='cm':
         if height==None: self.height = 1.0#default text height
         else: self.height = height
         self.heightPix = cm2pix(self.height, self.win.monitor)
     elif self.units in ['deg', 'degs']:
         if height==None: self.height = 1.0
         else: self.height = height
         self.heightPix = deg2pix(self.height, self.win.monitor)
     elif self.units=='norm':
         if height==None: self.height = 0.1
         else: self.height = height
         self.heightPix = self.height*self.win.size[1]/2
     elif self.units=='height':
         if height==None: self.height = 0.2
         else: self.height = height
         self.heightPix = self.height*self.win.size[1]
     else: #treat units as pix
         if height==None: self.height = 20
         else: self.height = height
         self.heightPix = self.height
     #need to update the font to reflect the change
     self.setFont(self.fontname, log=False)
     if log and self.autoLog:
         self.win.logOnFlip("Set %s height=%.2f" %(self.name, height),
             level=logging.EXP,obj=self)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:30,代码来源:text.py


示例4: _calcSizeRendered

 def _calcSizeRendered(self):
     """Calculate the size of the stimulus in coords of the :class:`~psychopy.visual.Window` (normalised or pixels)"""
     if self.units in ['norm','pix', 'height']: self._sizeRendered=self.size
     elif self.units in ['deg', 'degs']: self._sizeRendered=deg2pix(self.size, self.win.monitor)
     elif self.units=='cm': self._sizeRendered=cm2pix(self.size, self.win.monitor)
     else:
         logging.ERROR("Stimulus units should be 'height', 'norm', 'deg', 'cm' or 'pix', not '%s'" %self.units)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:7,代码来源:aperture.py


示例5: contains

    def contains(self, x, y=None):
        """Determines if a point x,y is inside the extent of the stimulus.

        Can accept: a) two args, x and y; b) one arg, as a point (x,y) that is
        list-like; or c) an object with a getPos() method that returns x,y, such
        as a mouse. Returns True if the point is within the area defined by `vertices`.
        This handles complex shapes, including concavities and self-crossings.

        Note that, if your stimulus uses a mask (such as a Gaussian blob) then
        this is not accounted for by the `contains` method; the extent of the
        stmulus is determined purely by the size, pos and orientation settings
        (and by the vertices for shape stimuli).

        See coder demo, shapeContains.py
        """
        if self.needVertexUpdate:
            self._calcVerticesRendered()
        if hasattr(x, 'getPos'):
            x, y = x.getPos()
        elif type(x) in [list, tuple, numpy.ndarray]:
            x, y = x[0], x[1]
        if self.units in ['deg','degs']:
            x, y = deg2pix(numpy.array((x, y)), self.win.monitor)
        elif self.units == 'cm':
            x, y = cm2pix(numpy.array((x, y)), self.win.monitor)
        if self.ori:
            oriRadians = numpy.radians(self.ori)
            sinOri = numpy.sin(oriRadians)
            cosOri = numpy.cos(oriRadians)
            x0, y0 = x-self._posRendered[0], y-self._posRendered[1]
            x = x0 * cosOri - y0 * sinOri + self._posRendered[0]
            y = x0 * sinOri + y0 * cosOri + self._posRendered[1]

        return pointInPolygon(x, y, self)
开发者ID:Gianluigi,项目名称:psychopy,代码行数:34,代码来源:basevisual.py


示例6: _calcSizeRendered

 def _calcSizeRendered(self):
     """DEPRECATED in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"""
     #raise DeprecationWarning, "_calcSizeRendered() was deprecated in 1.80.00. This funtionality is nowhanded by _updateVertices() and verticesPix"
     if self.units in ['norm','pix', 'height']: self._sizeRendered=copy.copy(self.size)
     elif self.units in ['deg', 'degs']: self._sizeRendered=deg2pix(self.size, self.win.monitor)
     elif self.units=='cm': self._sizeRendered=cm2pix(self.size, self.win.monitor)
     else:
         logging.ERROR("Stimulus units should be 'height', 'norm', 'deg', 'cm' or 'pix', not '%s'" %self.units)
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:8,代码来源:basevisual.py


示例7: __init__

 def __init__(self, win, actors, duration_frames, attn_video_size):
     """
     Initialize class
     :param win: window to use
     :param actors: actors to show
     :param duration_frames: how long to show (in frames)
     """
     self.win = win
     self.actors = actors
     self.duration_frames = duration_frames
     self.left_roi=visual.Rect(self.win, width=550, height=750, units='pix')
     self.left_roi.pos=[deg2pix(-12,win.monitor),deg2pix(0,win.monitor)]
     self.left_roi.lineColor = [1, -1, -1]
     self.left_roi.lineWidth = 10
     self.right_roi=visual.Rect(self.win, width=550, height=750, units='pix')
     self.right_roi.pos=[deg2pix(12,win.monitor),deg2pix(0,win.monitor)]
     self.right_roi.lineColor = [1, -1, -1]
     self.right_roi.lineWidth = 10
     self.attn_video=MovieStimulus(self.win, '', '', 'attn.mpg', attn_video_size)
开发者ID:jbonaiuto,项目名称:infant_eeg,代码行数:19,代码来源:gaze_following_exp.py


示例8: _windowUnits2pix

 def _windowUnits2pix(self, pos):
     if self.win.units == "pix":
         return pos
     elif self.win.units == "norm":
         return pos * self.win.size / 2.0
     elif self.win.units == "cm":
         return cm2pix(pos, self.win.monitor)
     elif self.win.units == "deg":
         return deg2pix(pos, self.win.monitor)
     elif self.win.units == "height":
         return pos * float(self.win.size[1])
开发者ID:arokem,项目名称:psychopy,代码行数:11,代码来源:event.py


示例9: _calcPosRendered

 def _calcPosRendered(self):
     """Calculate the pos of the stimulus in pixels"""
     if self.units == 'pix':
         self._posRendered = self.pos
     elif self.units == 'cm':
         self._posRendered = cm2pix(self.pos, self.win.monitor)
     elif self.units =='deg':
         self._posRendered = deg2pix(self.pos, self.win.monitor)
     elif self.units == 'norm':
         self._posRendered = self.pos * self.win.size/2.0
     elif self.units == 'height':
         self._posRendered = self.pos * self.win.size[1]
开发者ID:PieterMoors,项目名称:psychopy,代码行数:12,代码来源:simpleimage.py


示例10: _addRuntimeInfoToDisplayConfig

    def _addRuntimeInfoToDisplayConfig(self):

        if self not in Display._enabled_display_instances:
            Display._enabled_display_instances.append(self)

        display_config = self.getConfiguration()

        runtime_info = display_config.get("runtime_info", None)
        if runtime_info is None:
            runtime_info = self._getRuntimeInfoByIndex(self.device_number)
            display_config["runtime_info"] = runtime_info

            self._createPsychopyCalibrationFile()

            pixel_width = runtime_info["pixel_width"]
            pixel_height = runtime_info["pixel_height"]

            phys_width = display_config["physical_dimensions"]["width"]
            phys_height = display_config["physical_dimensions"]["height"]
            phys_unit_type = display_config["physical_dimensions"]["unit_type"]

            # add pixels_per_degree to runtime info
            ppd_x = deg2pix(
                1.0, self._psychopy_monitor
            )  # math.tan(math.radians(0.5))*2.0*viewing_distance*pixel_width/phys_width
            ppd_y = deg2pix(
                1.0, self._psychopy_monitor
            )  # math.tan(math.radians(0.5))*2.0*viewing_distance*pixel_height/phys_height
            runtime_info["pixels_per_degree"] = ppd_x, ppd_y

            self._calculateCoordMappingFunctions(pixel_width, pixel_height, phys_unit_type, phys_width, phys_height)

            left, top, right, bottom = runtime_info["bounds"]
            coord_left, coord_top = self._pixel2DisplayCoord(left, top, self.device_number)
            coord_right, coord_bottom = self._pixel2DisplayCoord(right, bottom, self.device_number)
            runtime_info["coordinate_bounds"] = coord_left, coord_top, coord_right, coord_bottom
开发者ID:smathot,项目名称:psychopy,代码行数:36,代码来源:__init__.py


示例11: drawIA

    def drawIA(self, x, y, size, index, color, name):
        """
        Draws square interest area in EDF and a corresponding filled box on
        eye-tracker display.

        :param x: X coordinate in degrees visual angle for center of check area.
        :type x: float or int
        :param y: Y coordinate in degrees visual angle for center of check area.
        :type y: float or int
        :param size: length of one edge of square in degrees visual angle.
        :type size: float or int
        :param index: number to assign interest area in EDF
        :type index: int
        :param color: color of box drawn on eye-tracker display (0 - 15)
        :type color: int
        :param name: Name interest area in EDF
        :type name: str
        """

        # Convert units to eyelink space
        elx = deg2pix(x, self.win.monitor) + (self.sres[0] / 2.0)
        ely = -(deg2pix(y, self.win.monitor) - (self.sres[1] / 2.0))
        elsz = deg2pix(size, self.win.monitor) / 2.0
    
        # Make top left / bottom right coordinates for square
        tplf = map(round, [elx - elsz, ely - elsz])
        btrh = map(round, [elx + elsz, ely + elsz])
    
        # Construct command strings
        flist = [index, name, color] + tplf + btrh
        iamsg = '!V IAREA RECTANGLE {0} {3} {4} {5} {6} {1}'.format(*flist)
        bxmsg = 'draw_filled_box {3} {4} {5} {6} {2}'.format(*flist)

        # Send commands
        self.tracker.sendMessage(iamsg)
        self.tracker.sendCommand(bxmsg)
开发者ID:tahmoor123,项目名称:pylinkwrapper,代码行数:36,代码来源:connector.py


示例12: __init__

    def __init__(self, win, balloonID, color, maxPumps, gainpoints, initsize, gainsize, mon):
        self.win = win
        self.balloonID = balloonID
        self.color = color
        self.maxPumps = maxPumps
        self.points = gainsize
        self.initSize = initsize  # units 'deg'
        self.initSizeX = 3.5
        self.initSizeY = 5
        self.gainSize = gainsize  # units 'deg'
        self.mon = mon
        self.pump = visual.ImageStim(win, image="assets/pump.png", pos=[0, 0], size=[10, 10])
        self.explosionSound = sound.Sound(value='assets\explode.wav')
        self.explosionSound.setVolume(1.0)
        self.pumpSound = sound.Sound(value='assets\pump4.wav')
        self.pumpSound.setVolume(1.0)

        self.pump.pos = [0, pix2deg(-690 + (deg2pix(self.pump.size[1], mon) / 2), mon)]
        self.stimuli = visual.ImageStim(win, image="assets/bal_blue.png", pos=[0,pix2deg(-400+(deg2pix(self.initSizeY,mon)/2),mon)],size=[self.initSizeX,self.initSizeY])
开发者ID:immergo,项目名称:psychoBART_MAESTRO,代码行数:19,代码来源:BARTBalloon.py


示例13: doCalibration


#.........这里部分代码省略.........

            # Reset the radius of the large circle
            self.calout.radius = caloutRadius

        # After calibration, make sure the stimuli aren't drawn
        self.calout.autoDraw = False
        self.calout = None

        # The following two will be set by the tobii SDK
        self.computeCalibration_completed = False
        self.computeCalibration_succeeded = False
        # Do the computation
        self.eyetracker.ComputeCalibration(self.on_calib_compute)
        while not self.computeCalibration_completed:
            psychopy.core.wait(0.1)
            if psychopy.event.getKeys(keyList=['escape']):
                raise KeyboardInterrupt("You interrupted the script.")
        self.eyetracker.StopCalibration(None)

        self.win.flip()

        # Now we retrieve the calibration data
        self.getcalibration_completed = False
        self.calib = self.eyetracker.GetCalibration(self.on_calib_response)
        while not self.getcalibration_completed:
            psychopy.core.wait(0.1)
            if psychopy.event.getKeys(keyList=['escape']):
                raise KeyboardInterrupt("You interrupted the script.")

        if not self.computeCalibration_succeeded:
            # computeCalibration failed.
            self.calmsg.text = ("Not enough data was collected "
                                "(Retry:[r] Abort:[ESC])")
        elif self.calib is None:
            # no calibration data
            self.calmsg.text = ("No calibration data "
                                "(Retry:[r] Abort:[ESC])")
        else:
            # calibration seems to have worked out
            points = {}
            for data in self.calib.plot_data:
                points[data.true_point] = {'left': data.left,
                                           'right': data.right}

            if len(points) == 0:
                # no points in the calibration results
                self.calmsg.text = ("No calibration data "
                                    "(Retry:[r] Abort:[ESC])")
            else:
                # draw the calibration result
                for p, d in points.iteritems():
                    psychopy.visual.Circle(self.win, radius=calinRadius,
                                           fillColor=(1, 1, 1),
                                           units='pix',
                                           pos=(p.x - 0.5, 0.5 - p.y)).draw()
                    if d['left'].status == 1:
                        psychopy.visual.Line(self.win, units='pix',
                                             lineColor='yellow',
                                             start=(self.acsd2pix((p.x, p.y))),
                                             end=(self.acsd2pix((d['left'].
                                                                 map_point.x,
                                                                 d['left'].
                                                                 map_point.y)))
                                             ).draw()
                    if d['right'].status == 1:
                        psychopy.visual.Line(self.win, units='pix',
                                             lineColor='blue',
                                             start=(self.acsd2pix((p.x, p.y))),
                                             end=(self.acsd2pix((d['right'].
                                                                 map_point.x,
                                                                 d['right'].
                                                                 map_point.y)))
                                             ).draw()
                for p in self.points:
                    psychopy.visual.Circle(self.win, radius=calinRadius,
                                           fillColor=1,
                                           units='pix',
                                           pos=self.acsd2pix(p),
                                           ).draw()
                    psychopy.visual.Circle(self.win, units='pix',
                                           lineColor=-0.5,
                                           radius=deg2pix(0.9,
                                                          self.win.monitor),
                                           pos=self.acsd2pix(p),
                                           ).draw()
                self.calmsg.text = ("Accept calibration results\n"
                                    "(Accept:[a] Retry:[r] Abort:[ESC])")

        # Update the screen, then wait for response
        self.calmsg.draw()
        self.win.flip()
        self.response = psychopy.event.waitKeys(keyList=['a', 'r', 'escape'])
        if 'a' in self.response:
            retval = 'accept'
        elif 'r' in self.response:
            retval = 'retry'
        elif 'escape' in self.response:
            retval = 'abort'

        return retval
开发者ID:janfreyberg,项目名称:tobii-psychopy,代码行数:101,代码来源:tobiicontroller.py


示例14: _calcPosRendered

 def _calcPosRendered(self):
     """Calculate the pos of the stimulus in coords of the :class:`~psychopy.visual.Window` (normalised or pixels)"""
     if self.units in ['pix', 'pixels', 'height', 'norm']: self._posRendered=self.pos
     elif self.units in ['deg', 'degs']: self._posRendered=deg2pix(self.pos, self.win.monitor)
     elif self.units=='cm': self._posRendered=cm2pix(self.pos, self.win.monitor)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:5,代码来源:simpleimage.py


示例15: _calcPosRendered

 def _calcPosRendered(self):
     """DEPRECATED in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"""
     #raise DeprecationWarning, "_calcSizeRendered() was deprecated in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"
     if self.units in ['norm','pix', 'height']: self._posRendered= copy.copy(self.pos)
     elif self.units in ['deg', 'degs']: self._posRendered=deg2pix(self.pos, self.win.monitor)
     elif self.units=='cm': self._posRendered=cm2pix(self.pos, self.win.monitor)
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:6,代码来源:basevisual.py


示例16: fixCheck

    def fixCheck(self, size, ftime, button):
        """
        Checks that fixation is maintained for certain time.

        :param size: Length of one side of box in degrees visual angle.
        :type size: float or int
        :param ftime: Length of time to check for fixation in seconds.
        :type ftime: int
        :param button: Key to press to recalibrate eye-tracker.
        :type button: char
        """

        # Calculate Fix check borders
        cenX = self.sres[0] / 2.0
        cenY = self.sres[1] / 2.0
        size = deg2pix(size, self.win.monitor) / 2.0

        xbdr = [cenX - size, cenX + size]
        ybdr = [cenY - size, cenY + size]

        # Set status message & Draw box
        self.setStatus('Fixation Check')
        bxmsg = 'draw_box {} {} {} {} 1'.format(xbdr[0], ybdr[0], xbdr[1],
                                                ybdr[1])
        self.tracker.sendCommand(bxmsg)
        
        # Begin recording
        self.tracker.startRecording(0, 0, 1, 1)
        
        # Check which eye is being recorded
        eye_used = self.tracker.eyeAvailable()
        RIGHT_EYE = 1
        LEFT_EYE = 0
        
        # Begin polling
        keys = []
        fixtime = time.clock()
        while self.realconnect:  # only start check loop if real connection

            # Check for recalibration button
            keys = event.getKeys(button)
            if keys:
                self.tracker.stopRecording()
                self.calibrate()
                break 
            
            # Grab latest sample
            sample = self.tracker.getNewestSample()
            
            # Extract gaze coordinates
            if eye_used == RIGHT_EYE:
                gaze = sample.getRightEye().getGaze()
            else:
                gaze = sample.getLeftEye().getGaze()
                
            # Are we in the box?
            if xbdr[0] < gaze[0] < xbdr[1] and ybdr[0] < gaze[1] < ybdr[1]:
                # Have we been in the box long enough?
                if (time.clock() - fixtime) > ftime:
                    self.tracker.stopRecording()
                    break
            else:
                # Reset clock if not in box
                fixtime = time.clock()
开发者ID:tahmoor123,项目名称:pylinkwrapper,代码行数:64,代码来源:connector.py


示例17: _calcXYsRendered

 def _calcXYsRendered(self):
     if self.units in ['norm','pix','height']: self._XYsRendered=self.xys
     elif self.units in ['deg', 'degs']: self._XYsRendered=deg2pix(self.xys, self.win.monitor)
     elif self.units=='cm': self._XYsRendered=cm2pix(self.xys, self.win.monitor)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:4,代码来源:elementarray.py


示例18: degcoord2pix

 def degcoord2pix(self, degx, degy, display_index=None):
     if display_index == self.getIndex():
         return psychopy2displayPix(
             deg2pix(degx, self._psychopy_monitor), cm2pix(degy, self._psychopy_monitor)
         )
     return degx, degy
开发者ID:smathot,项目名称:psychopy,代码行数:6,代码来源:__init__.py


示例19: updateBalloonPos

 def updateBalloonPos(self):
     return [0, pix2deg(-400 + (deg2pix(self.stimuli.size[1], self.mon) / 2), self.mon)]
开发者ID:immergo,项目名称:psychoBART_MAESTRO,代码行数:2,代码来源:BARTBalloon.py


示例20: _calcDotsXYRendered

 def _calcDotsXYRendered(self):
     if self.units in ['norm','pix', 'height']: self._dotsXYRendered=self._dotsXY
     elif self.units in ['deg','degs']: self._dotsXYRendered=deg2pix(self._dotsXY, self.win.monitor)
     elif self.units=='cm': self._dotsXYRendered=cm2pix(self._dotsXY, self.win.monitor)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:4,代码来源:dot.py



注:本文中的psychopy.tools.monitorunittools.deg2pix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python visual.getMsPerFrame函数代码示例发布时间:2022-05-25
下一篇:
Python monitorunittools.convertToPix函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap