DMDX Help.


ExpireIf Keyword

<ExpireIf signal>


    Switch introduced in version 6.1.2.0 of DMDX to expire a given frame's duration when a given signal is received to facilitate interfacing with eye trackerssignal must exist on some input device and begin with a + or a - as per usual DMDX input button names and only one <expireif> can be used per item.  While the abort item keywords will terminate digital video and sound related tasks this keyword only advances the display queue, it doesn't terminate anything.  Note signal does not have to be mapped to any response and if signal is not received as the item is being displayed the frame <ExpireIf> occurs in will be displayed for whatever duration it has been set to (either the default or some specific duration).  Also note that the job has to either be displaying frames prior to a clock on or waiting for a response, once a response has been received <expireif> will not do anything.

    Usual usage of this keyword would be to trigger a change in a display based upon the point of gaze of an eye tracker where one is using the tcpip input device and defining a region of the screen with <2Did tcpipreply> however it probably has other uses and one that just occurred to me is terminating a display once a response is received where you want the display to disappear once a response is received or simply stay on the screen for a specified time and then be erased regardless of whether the subject has responded or not.  This used to take abort item logic and extra items to do the erasing when the the response item was aborted by a response, here you can feed <expireif> the name of the response key (usually the +DigitalVOX signal as this sort of paradigm comes up there more than anywhere else).  So here we want our target to stay on the screen for 10 seconds and then be erased but the subject can take 100 seconds to respond and if the subject responds in less than 10 seconds the item should be erased and not leave the subject hanging around waiting for the 10 seconds to expire:

<id digitalvox> <msfd 10000> <t 100000> <cr>
+1 "naming task target" * <expireif +digitalvox> / ;
+2 "another naming task target" * <expireif +digitalvox> / ;

 
    The other major use of <expireif> is in an eye tracking paradigm where our task is going to be to present a sentence on the screen and have the subject decide if there are misspellings in it but when they look at the word mouse it will change to moose.  We'll detect when the point of gaze hits a target on the screen and when it does redisplay the sentence with the target word modified in the next tick of the display.  Similar to the example in the <send> documentation that parses a given field out of the reply from the host we've connected to here I've gussied up the Debug Monitor build to send Best Point Of Gaze fields (so <ACK number="1" BPOGV="1" BPOGX="0.6655" BPOGY="0.8477"> for example) that sweep across the screen and we're going to set up a <2Did tcpipreply> device to trigger a response when the gaze hits our targets bounding box.
 
    So we set up our tcpipreply 2Did device passing it the names of the X and Y POG fields and we also pass it the validated field BPOGV=''1'' so we only process valid data (two single quotes here get collapsed to a double quote), if your eye tracker didn't provide anything like that you'd feed it a string guaranteed to be in the TCP/IP reply.  We also set up a signal (or "button") named word with some dummy coordinates as we won't know where that target will be till later.  Once we've defined the macros we'll be using to capture the target coordinates we display our target sentence in white on white broken up into individual frames so we can see where the target is displayed with <storecoords> and then we set the button rectangle for our word button to those coordinates with <setbuttonrect>.  Then we set the emulated eye tracker going (here we're asking for 600 total ACKs 16 milliseconds apart) and display our pre-test target sentence.  At some time DMDX will get a reply that matches the target's location and DMDX will expire the first frame before it reaches it's 10 second maximum duration and then we draw the post-test sentence with the target modified and turn the subject response clock on:

<ep> <safemode 1> <fd 600>
<2did tcpipreply,BPOGX,BPOGY,BPOGV=''1'' word,1,2,3,4>
<id keyboard> <id tcpip>
<eop>
 
0 "test 2did expireif" m.l.++ m.t.++ m.r.++ m.b.++;
 
1 d2 <px .2> <dwc 255,255,255 stat> "Hickory ", "dickory ", "dock, ", "the ", <storecoords .l., .t., .r., .b.> "mouse ", "ran ", "up ", "the ", "clock " c ; 
~1 <dwc 0,0,0> <sbr +word,~.l., ~.t.,~.r., ~.b.> <! note that's a separate item from the storecoords one otherwise those macros won't contain the right data>; 

1 <SEND "<requestack num=600 delay=1000 subsequentdelay=16>">
  "send <requestack num=600 delay=1000 subsequentdelay=16>" <fd 30> / c;

+702 <x .2> "Hickory dickory dock, the mouse ran up the clock" <expireif +word> /
     <x .2> "Hickory dickory dock, the moose ran up the clock" * ;
 
0 "end" <SEND "<requestack num=0>">;

    Unlike a lot of other examples in here we're not continuously running so you'll notice several frames use the legacy continue switch C.  Note you could test this sort of script without needing to have the eye tracker set up by simply commenting out the <SEND>, <id tcpip> and <2Did> keywords and replace the <2Did> one with a mouse invocation like this <2Did mouse noclick word,1,2,3,4> and then the mouse becomes your point of gaze.




DMDX Index