PsyScriptIcon.png PsyScript: getting experiments done

$query\n"; } $result = mysql_query($database, $query, $connection) or die("ack! query failed: " ."
  • errorno=".mysql_errno() ."
  • error=".mysql_error() ."
  • query=".$query ); return $result; } $Base = "http://www.maccs.mq.edu.au"; $URL= $PHP_SELF; $connection = mysql_connect('localhost', 'tim', 'connect2'); if (!$connection) { print("Cannot connect to database. Call Tim.
    "); exit(); } $result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection); while ($row = mysql_fetch_row($result)) { $ChkBase=$row[0]; $ChkURL=$row[1]; $ChkCount=$row[2]; $Count=$ChkCount; } if ($ChkURL == ""){ safe_db_query("Counters","INSERT INTO Count VALUES ('$Base','$URL','0')", $connection); $Count=0; } $Count++; safe_db_query("Counters","UPDATE Count SET Number='$Count' WHERE Base='$Base' AND URL='$URL'"); $result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection); while ($row = mysql_fetch_row($result)) { $Base=$row[0]; $URL=$row[1]; $Count=$row[2]; } echo $Count; */ ?>hits
  • PsyScriptIcon.png PsyScript: getting experiments done

    $query\n"; } $result = mysql_db_query($database, $query, $connection) or die("ack! query failed: " ."
  • errorno=".mysql_errno() ."
  • error=".mysql_error() ."
  • query=".$query ); return $result; } $Base = "http://www.maccs.mq.edu.au"; $URL= $PHP_SELF; $connection = mysql_connect('localhost', 'tim', 'connect2'); if (!$connection) { print("Cannot connect to database. Call Tim.
    "); exit(); } $result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection); while ($row = mysql_fetch_row($result)) { $ChkBase=$row[0]; $ChkURL=$row[1]; $ChkCount=$row[2]; $Count=$ChkCount; } if ($ChkURL == ""){ safe_db_query("Counters","INSERT INTO Count VALUES ('$Base','$URL','0')", $connection); $Count=0; } $Count++; safe_db_query("Counters","UPDATE Count SET Number='$Count' WHERE Base='$Base' AND URL='$URL'"); $result=safe_db_query("Counters","SELECT * FROM Count WHERE Base='$Base' AND URL='$URL'", $connection); while ($row = mysql_fetch_row($result)) { $Base=$row[0]; $URL=$row[1]; $Count=$row[2]; } echo $Count; */ ?>hits
  • Eyelink.lib

    This script object has a group of handlers which essentially wrap the command and message functions in a series of try handlers to make them more reliable for you to use by enforcing orderly commands and error recovery.

    Contents:

    Using the Library

    An example

    The Library Handlers


    Using the Library

    The handlers available in this library assist with designing and running Eyelink experiments. These are the Handlers:
    open_data_file ( fileName , preambleText )
    add_file_preamble_text ( theText )
    set_calibration_type ( calType )
    recordAndEchoTrialID ( TrialID , trialVariables )
    display_status_message ( TrialID )
    drawText ( xyPoint , colorInt , theText )
    set_saccade_velocity_threshold ( theValue )
    set_saccade_acceleration_threshold ( theValue )
    set_file_event_filter ( theValue )
    set_link_event_filter ( theValue )
    set_link_sample_data ( theValue )

     

    To run an Eyelink experiment, you would use some of PsyScripts build in commands directly - these include:

    initialize eyelink [dummy open boolean] -- whether to open the Eyelink library in dummy mode (default is false).

    send eyelink command string -- the command string to send

    send eyelink message string -- the command string to send

    do tracker setup

    do drift correct

    [at point] -- where the fixation is (default is centre of the screen).

    [drawing boolean] -- whether to draw the drift stimulus (default is false).

    start eyelink recording

    [file samples boolean] -- whether to record file samples (default is false).

    [file events boolean] -- whether to record file events (default is false).

    [link samples boolean] -- whether to record link samples (default is false).

    [link events boolean] -- whether to record link events (default is false).

    stop eyelink recording

    set eyelink offline

    eyelink replay



    An example:

    OK. A complete experiment might look like

    initialize eyelink

    do tracker setup

    do drift correct at {0,0} without drawing

    start eyelink recording with file samples file events without link samples link events

    do trial " 'look around the screen please'"

    stop eyelink recording

    set eyelink offline

    eyelink replay


    The Library Handlers

    -- >> Cmd strings
    property cmd_open_data_file : " open_data_file "

    -- >> Filter and threshold properties
    property defSaccadeVelThreshold : 35
    property defSaccadeAccThreshold : 9500
    property defFileEventFilter : " LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON "
    property defLinkEventFilter : " LEFT, RIGHT, FIXATION, BUTTON "
    property defLinkSampleData : " LEFT, RIGHT, GAZE, AREA "

    -- > In-trial command strings
    property pGazeOnInTrial : " !ic(link_event_filter = LEFT,RIGHT,FIXUPDATE) !ic(fixation_update_interval = 50) !ic(fixation_update_accumulate = 50) "
    property pGazeOffInTrial : " !ic(link_event_filter = LEFT,RIGHT,FIXATION) !ic(fixation_update_interval = 0) !ic(fixation_update_accumulate = 0) "

    -- >> Experiment properties: drift stimulus, link boolean
    property pDriftStimulusName : ""
    property pLinkPresent : false -- boolean

    property pBlack : 0
    property p1 : 1
    property p2Int : 2
    property p3Int : 3
    property p4Int : 4
    property p5Int : 5
    property p6Int : 6
    property pMedGray : 7
    property p8Int : 8
    property p9Int : 9
    property p10Int : 10
    property pI11nt : 11
    property pIn12t : 12
    property p13Int : 13
    property p14Int : 14
    property pWhite : 15

    -- property pDefaultFiltersThresholds : {saccadeVelocityThreshold:defSaccadeVelThreshold, saccadeAccelerationThreshold:defSaccadeAccThreshold, fileEventFilter:defFileEventFilter, linkEventFilter:defLinkEventFilter, linkSampleData:defLinkSampleData}

    to initLinkAndSetup ( calType , bLinked , DriftStimulusName , screenParameters , fileHelper , screen )

    tell screen to setDistanceScreenXAndScreenY ( screenParameters ) -- physical properties
    set pLinkPresent to bLinked
    set pDriftStimulusName to DriftStimulusName
    tell application " PsyScript "
    load permanent stimulus pDriftStimulusName as masked picture stimulus -- load tracking stimulus
    if pLinkPresent then -- setup Eyetracking Stuff
    set oldSpace to ( noticed of key space )
    set noticed of key space to true
    do trial " !w(200 200) To check the cameras press the enter key. !t(0) "
    do trial " !w(200 230) \"C\" for calibration. !t(0) "
    do trial " !w(200 260) When done, press \"O\" to run the experiment.
    !t(0) "
    do trial " !w(200 290) Press SPACE BAR to begin. ''(0) !t "
    set noticed of key space to oldSpace
    initialize eyelink
    my initDisplayCoordinates ()
    my set_calibration_type ( calType )
    my setFixationUpdatesOFF ()
    do tracker setup
    else
    do trial " 'dummy stimulus' "
    initialize eyelink with dummy open
    end if
    end tell
    end initLinkAndSetup

    to checkLink ()
    tell application " PsyScript "
    if pLinkPresent then
    if not ( eyelink connected ) then
    error " link lost "
    end if
    end if
    end tell
    end checkLink


    -- >> file open and close
    on open_data_file ( fileName , preambleText ) -- (psubjectID of fileHelper & fileSuffix)
    if ( count of fileName ) > 8 then
    error " filename " & fileName & " too long " & return & " (must be 8 characters or less) "
    else
    my close_data_file ()
    tell application " PsyScript " to send eyelink command " open_data_file " & fileName
    my add_file_preamble_text ( preambleText )
    end if
    end open_data_file

    to close_data_file ()
    tell application " PsyScript " to send eyelink command " close_data_file "
    end close_data_file

    on add_file_preamble_text ( theText )
    tell application " PsyScript " to send eyelink command " add_file_preamble_text ' " & theText & " ' "
    end add_file_preamble_text

    to initDisplayCoordinates () -- expects items separated by spaces in order: left, top, right, bottom
    tell application " PsyScript "
    set { l , t , r , b } to { 0 , 0 } & screen size
    send eyelink command " screen_pixel_coordinates = " & l & " " & t & " " & r & " " & b
    send eyelink message " DISPLAY_COORDS " & l & " " & t & " " & r & " " & b
    end tell
    end initDisplayCoordinates

    on set_calibration_type ( calType ) -- HV9 = regular, H3 = horizontal
    tell application " PsyScript " to send eyelink command " calibration_type = " & calType
    end set_calibration_type

    on recordAndEchoTrialID ( TrialID , trialVariables )
    (* if eyelink connected then *)
    tell application " PsyScript "
    send eyelink message " TRIALID " & TrialID & " " & trialVariables
    send eyelink command " record_status_message = TRIALID= " & TrialID & " " & trialVariables
    end tell
    end recordAndEchoTrialID

    to doDriftCorrect () -- assumes centre of screen and a preloaded stimulus
    -- you should set the trialid before calling this.
    tell application " PsyScript "
    -- try
    if pDriftStimulusName is "" then -- not using a specific graphic
    set trialString to " + ?1 !w(10 10) push space when fixating ''(0) "
    else if (( every permanent stimulus whose name is pDriftStimulusName ) is not {}) then
    if ( type of ( every permanent stimulus whose name is pDriftStimulusName ) is masked picture stimulus ) then -- masked needs old and new pos
    set trialString to " ë?1(0)(0) !w(10 10) push space when fixating ''(0) "
    else -- plain stimulus
    set trialString to " ë?1(0) !w(10 10) push space when fixating ''(0) "
    end if
    else -- not a permanent stimulus
    set trialString to " @?1(0) !w(10 10) push space when fixating ''(0) "
    end if
    -- set theResult to 27
    -- repeat while theResult is 27 --escape pressed (calibration invoked). Repeat the drift correction
    do trial trialString given { pDriftStimulusName }
    if pLinkPresent then do drift correct without drawing -- how does this workl???
    -- set theResult to do drift correct --without drawing --how does this workl???
    -- do trial "!e !t(0)"
    -- end repeat
    -- end try
    end tell
    end doDriftCorrect

    on display_status_message ( TrialID )
    tell application " PsyScript " to send eyelink command " record_status_message = TRIAL " & TrialID
    end display_status_message

    on drawText ( xyPoint , colorInt , theText )
    tell application " PsyScript "
    if ( class of xyPoint is list or class of xyPoint is record ) then
    set xyPoint to xyPoint as list
    set textMsg to item 1 of xyPoint & " " & item 2 of xyPoint & colorInt & " ' " & theText & " ' "
    else
    set textMsg to xyPoint & colorInt & " ' " & theText & " ' "
    end if
    try
    send eyelink command " draw_text " & textMsg -- e.g. draw_text 100 100 1 'hi there'
    on error errMsg number errNum
    error errMsg & " from draw text " number errNum
    end try
    end tell
    end drawText

    -- >>filter and threshold handlers

    to setDefaults ()
    tell application " PsyScript " (* SET UP TRACKER CONFIGURATION *)
    (* set parser (conservative saccade thresholds) *)
    send eyelink command " recording_parse_type = GAZE "
    send eyelink command " saccade_velocity_threshold = 35 "
    send eyelink command " saccade_acceleration_threshold = 9500 "

    (* set EDF file contents *)
    send eyelink command " file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON "

    (* set link data (used for gaze cursor) *)
    send eyelink command " link_event_filter = LEFT,RIGHT,FIXATION,BUTTON "
    send eyelink command " link_sample_data = LEFT,RIGHT,GAZE,AREA "
    end tell
    end setDefaults

    to setParserToCognitive () -- pg 105 section 11.10
    tell application " PsyScript "
    send eyelink command " recording_parse_type = GAZE "
    send eyelink command " saccade_velocity_threshold = 30 "
    send eyelink command " saccade_acceleration_threshold = 9500 "
    send eyelink command " saccade_motion_threshold = 0.15 "
    send eyelink command " saccade_pursuit_fixup = 60 "
    send eyelink command " fixation_update_interval = 0 "
    end tell
    end setParserToCognitive

    to setParserToPursuitOrNeurology () -- pg 105 section 11.10
    tell application " PsyScript "
    send eyelink command " recording_parse_type = GAZE "
    send eyelink command " saccade_velocity_threshold = 22 "
    send eyelink command " saccade_acceleration_threshold = 5000 "
    send eyelink command " saccade_motion_threshold = 0.0 "
    send eyelink command " saccade_pursuit_fixup = 60 "
    send eyelink command " fixation_update_interval = 0 "
    end tell
    end setParserToPursuitOrNeurology

    to setFilterList ({ saccadeVelocityThreshold : SVT , saccadeAccelerationThreshold : SAT , fileEventFilter : FEF , linkEventFilter : LEF , linkSampleData : LSD })
    tell application " PsyScript " (* SET UP TRACKER CONFIGURATION *)
    (* set parser (conservative saccade thresholds) *)
    send eyelink command " saccade_velocity_threshold = " & SVT -- default = 35
    send eyelink command " saccade_acceleration_threshold = " & SAT -- default = 9500
    (* set EDF file contents *)
    send eyelink command " file_event_filter = " & FEF -- default = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON
    (* set link data (used for gaze cursor) *)
    send eyelink command " link_event_filter = " & LEF -- defaults = LEFT,RIGHT,FIXATION,BUTTON"
    send eyelink command " link_sample_data = " & LSD -- defaults = LEFT,RIGHT,GAZE,AREA"
    -- message these parameters?
    end tell
    end setFilterList

    to setFixationUpdatesON () -- for GazeContingentDisplay
    tell application " PsyScript " (* SET UP TRACKER CONFIGURATION *)
    send eyelink command " link_event_filter = LEFT,RIGHT,FIXUPDATE "
    send eyelink command " fixation_update_interval = 50 "
    send eyelink command " fixation_update_accumulate = 50 "
    end tell
    end setFixationUpdatesON

    to setFixationUpdatesOFF () -- after GazeContingentDisplay is not needed
    tell application " PsyScript " (* SET UP TRACKER CONFIGURATION *)
    send eyelink command " link_event_filter = LEFT,RIGHT,FIXATION "
    send eyelink command " fixation_update_interval = 0 "
    send eyelink command " fixation_update_accumulate = 0 "
    end tell
    end setFixationUpdatesOFF

    on set_saccade_velocity_threshold ( theValue )
    tell application " PsyScript " to send eyelink command " saccade_velocity_threshold = " & theValue -- default =35
    end set_saccade_velocity_threshold

    on set_saccade_acceleration_threshold ( theValue )
    tell application " PsyScript " to send eyelink command " saccade_acceleration_threshold = " & theValue -- default = 9500
    end set_saccade_acceleration_threshold

    on set_file_event_filter ( theValue ) (* set EDF file contents *)
    tell application " PsyScript " to send eyelink command " file_event_filter = " & theValue -- LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON
    end set_file_event_filter

    on set_link_event_filter ( theValue ) (* set link data (used for gaze cursor) *)
    tell application " PsyScript " to send eyelink command " link_event_filter = " & theValue -- LEFT,RIGHT,FIXATION,BUTTON
    end set_link_event_filter

    on set_link_sample_data ( theValue )
    tell application " PsyScript " to send eyelink command " link_sample_data = LEFT,RIGHT,GAZE,AREA "
    end set_link_sample_data

     
    MACCS PsyScriptIcon.png Documentation Downloads FAQ Mailing List
    Last change:
    Advanced Search

    Applescript in a Nutshell : A Desktop Quick Reference

    AppleScript for Applications: Visual QuickStart Guide

    AppleScript For Dummies

    Applescript for the Internet Visual Quickstart Guide

    Applescript Language Guide; English Dialect

    Danny Goodman's Applescript Handbook
    MACCS PsyScriptIcon.png Documentation Downloads FAQ Mailing List
    Last change:
    Advanced Search

    Applescript in a Nutshell : A Desktop Quick Reference

    AppleScript for Applications: Visual QuickStart Guide

    AppleScript For Dummies

    Applescript for the Internet Visual Quickstart Guide

    Applescript Language Guide; English Dialect

    Danny Goodman's Applescript Handbook