您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > Psychtoolbox教程
win_bk_color=[125,125,125];[winPt,winRect]=Screen('OpenWindow',0,win_bk_color);a=imread('imgname.jpg');b=Screen('MakeTexture',winPt,a);Screen('DrawTexture',winPt,b);Screen('Flip',winPt);WaitSecs(2);Screen('CloseAll');return以上脚本可以呈现一张图片,它用红色虚线框框起的部分可以用右边红色虚线框的内容进行替换。通过改变红色虚线框的内容,一般刺激呈现都可以实现。如果需要计时,使用toc和tic如果需要记录按键,可以使用KbCheck扫描键盘开始OpenWindows得到WinPt句柄图片矩阵图片Texture写入缓存正式呈现imreadMakeTextureDrawTextureFlipTextSize设置字体大小DrawText字体写入缓存获取字显示区块大小TextBounds计算显示位置获取图片区块大小Rect计算显示位置DrawLine线条写入缓存CloseAll实验结束函数大全%%%%打开窗口或打开窗口或打开窗口或打开窗口或TextureTextureTextureTexture[windowPtr,rect]=Screen('OpenWindow',windowPtrOrScreenNumber);详细[windowPtr,rect]=Screen('OpenOffscreenWindow',windowPtrOrScreenNumber);详细textureIndex=Screen('MakeTexture',WindowIndex,imageMatrix);详细Screen('Close');详细Screen('CloseAll');详细%%%%画线或者填充的形状画线或者填充的形状画线或者填充的形状画线或者填充的形状currentbuffer=Screen('SelectStereoDrawBuffer',windowPtr);详细Screen('DrawLine',windowPtr[,color],fromH,fromV,toH,toV);详细Screen('DrawArc',windowPtr,[color],[rect],startAngle,arcAngle)详细Screen('FrameArc',windowPtr,[color],[rect],startAngle,arcAngle)详细Screen('FillArc',windowPtr,[color],[rect],startAngle,arcAngle)详细Screen('FillRect',windowPtr);详细Screen('FrameRect',windowPtr);详细Screen('FillOval',windowPtr);详细Screen('FrameOval',windowPtr);详细Screen('FramePoly',windowPtr);详细Screen('FillPoly',windowPtr);详细%%%%在窗口中输出字在窗口中输出字在窗口中输出字在窗口中输出字textModes=Screen('TextModes');详细oldCopyMode=Screen('TextMode',windowPtr);详细oldTextSize=Screen('TextSize',windowPtr);详细oldStyle=Screen('TextStyle',windowPtr);详细[oldFontName,oldFontNumber]=Screen(windowPtr,'TextFont');详细[normBoundsRect,offsetBoundsRect]=Screen('TextBounds',windowPtr,text);详细[newX,newY]=Screen('DrawText',windowPtr,text);详细oldTextColor=Screen('TextColor',windowPtr);详细oldTextBackgroundColor=Screen('TextBackgroundColor',windowPtr);详细%%%%复制图像,快,在复制图像,快,在复制图像,快,在复制图像,快,在TextureTextureTextureTexture、幕后屏幕和当前的窗口中、幕后屏幕和当前的窗口中、幕后屏幕和当前的窗口中、幕后屏幕和当前的窗口中A=IMREAD(FILENAME,FMT)读入图片,详细[resident[texidresident]]=Screen('PreloadTextures',windowPtr[,texids]);详细Screen('DrawTexture',windowPointer,texturePointer);详细Screen('DrawTextures',windowPointer,texturePointer(s));详细Screen('CopyWindow',srcWindowPtr,dstWindowPtr)详细%%%%复制图像,慢,在矩阵与窗口中复制图像,慢,在矩阵与窗口中复制图像,慢,在矩阵与窗口中复制图像,慢,在矩阵与窗口中imageArray=Screen('GetImage',windowPtr);详细%%%%刷新当前窗口刷新当前窗口刷新当前窗口刷新当前窗口Screen('Flip',windowPtr);详细Screen('AsyncFlipBegin',windowPtr);详细Screen('AsyncFlipEnd',windowPtr);详细Screen('AsyncFlipCheckEnd',windowPtr);详细Screen('WaitUntilAsyncFlipCertain',windowPtr);详细Screen('GetFlipInfo',windowPtr);详细Screen('DrawingFinished',windowPtr);详细Screen('WaitBlanking',windowPtr);详细%%%%获取鼠标和键盘输入获取鼠标和键盘输入获取鼠标和键盘输入获取鼠标和键盘输入[x,y,buttons,focus,valuators,valinfo]=GetMouse()详细[keyIsDown,secs,keyCode,deltaSecs]=KbCheck()详细%%%%时间时间时间时间wakeup=WaitSecs(s)详细TSTART=TIC详细T=TOC详细%%%%文件操作文件操作文件操作文件操作FID=FOPEN(FILENAME,PERMISSION)详细[A,COUNT]=FSCANF(FID,FORMAT,SIZE)详细FPRINTF(FID,FORMAT,A,...)详细ST=FCLOSE(FID)详细详细介绍详细介绍详细介绍详细介绍[windowPtr,rect]=Screen('OpenWindow',windowPtrOrScreenNumber[,color][,rect][,pixelSize][,numberOfBuffers][,stereomode][,multisample][,imagingmode][,specialFlags]);返回作用:作用:作用:作用:打开一个显示屏幕。参数:参数:参数:参数:WindowRtrOrScreenNumber:窗口句柄,指定屏幕,0代表带菜单栏的主屏幕。Color:像素的颜色(标量或[rgb]),默认为白色。Rect:矩形,至少含有一个像素。若窗口句柄为WindowRtr,rect在窗口坐标中(初始点为左上),默认为整个窗口;若为ScreenNumber,rect在屏幕坐标中,默认为整个屏幕。PixelSize:每个像素的深度(bits),默认深度不变。NumberOfBuffers:使用缓冲数,设置为大于2有助于PTB的发展与调试,但会破坏实际实验。Stereomode:使用的立体显示算法类型,0(默认)表示单视场观察。Multisample:启用显卡的自动抗锯齿化处理,颜色采样,数字越大,显示质量越高,但消耗更多的内存且由于更高的计算需求使得帧数率的减少。Imagingmode:启用PTB内部的图像处理通道,默认为关闭。SpecialFlags:木有。返回[windowPtr,rect]=Screen('OpenOffscreenWindow',windowPtrOrScreenNumber[,color][,rect][,pixelSize][,specialFlags][,multiSample]);返回功能:功能:功能:功能:打开一个幕后(offscreen)窗口。参数:参数:参数:参数:WindowRtrOrScreenNumber:窗口句柄,指定屏幕,0代表带菜单栏的主屏幕。Color:每个像素初始背景颜色(标量或[rgb]或[rgba]),默认为白色。Rect:幕后屏幕的尺寸,至少包含一个像素。如果是windowPtr,那么该参数指整个窗口;若是screenNumber,该参数指整个屏幕;若screenNumber=-1,参数指主屏幕的尺寸。PixelSize:每个像素的深度(bits)。SpecialFlags:特殊性能,默认为0。若设为2,幕后窗口精度较高。Multisample:用以抗锯齿绘制的采样数,默认为0。返回textureIndex=Screen('MakeTexture',WindowIndex,imageMatrix[,optimizeForDrawAngle=0][,specialFlags=0][,floatprecision=0][,textureOrientation=0][,textureShader=0]);返回功能:功能:功能:功能:将二维或三维的模型'imageMatrix'转换为开放图形语言(OpenGL)结构,并返回一个指针(index),用于'DrawTexture',表示此结构。参数:参数:参数:参数:imageMatrix:由单色平面(plane),图层平面,RGB三色平面或RGBA平面构成。optimizeForDrawAngle=0:请求psychtoolbox优化结构,尤其是在某个特定的旋转角度快速绘制。默认为0,表示垂直绘制的优化。specialFlags=0:系统默认算法,2为PTB的高质量的滤波算法,4为更快的结构创作方法。floatprecision=0:定义了结构被储存和执行的精度。默认值为0,储存精度为每个颜色成分8bit,通过imread()读取。textureOrientation=0:给结构打上特殊的orientation。textureShader=0:可选,默认关闭GLSLshader程序。返回Screen('Close',[windowOrTextureIndexorlistoftextureIndices/offscreenWindowIndices]);返回作用:作用:作用:作用:关闭一个幕前(onscreen)或幕后(offscreen)的窗口或一个结构。若不提供windowOrTextureIndex,所有的幕后的窗口都将关闭,只留下幕前的窗口。如果你想关闭部分幕后的窗口或结构,可以将想关闭的窗口handles放入一个vector中。返回Screen('CloseAll');返回作用:作用:作用:作用:关闭所有打开的屏幕前、屏幕后的窗口、结构、电影和视频资源。释放几乎所有资源。返回currentbuffer=Screen('SelectStereoDrawBuffer',windowPtr[,bufferid][,param1]);返回作用:作用:作用:作用:在立体声显示模式下选择绘制命令的缓冲区,或者返回当
本文标题:Psychtoolbox教程
链接地址:https://www.777doc.com/doc-1719062 .html