Commit bd91fc5b authored by Voogd, H.F.J.M. (Hubert)'s avatar Voogd, H.F.J.M. (Hubert)
Browse files

An example on how to use SMI Eyetracking in NBS Presentation.

It contains lots of comments on why and how eyetracking is implemented.
parents
<ver>17.2</ver>
<efn>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-Example.exp</efn>
<author></author>
<con>
<pause>P</pause>
<pause_code></pause_code>
<port1>1</port1>
<quit>Q</quit>
<quit2>0</quit2>
<quit_code></quit_code>
<resume>R</resume>
<resume_code></resume_code>
<send_output>0</send_output>
<start_code></start_code>
</con>
<dbi></dbi>
<dbs>button</dbs>
<ddi>0</ddi>
<dds>
<icm_profile></icm_profile>
<use_icm>0</use_icm>
</dds>
<ddv>Primary Display Driver</ddv>
<depchg>1</depchg>
<discard_windows_messages>0</discard_windows_messages>
<display_status_window>1</display_status_window>
<dmd>32</dmd>
<dmh>1080</dmh>
<dmr>100</dmr>
<dmw>1920</dmw>
<docs>
<args></args>
<exfl></exfl>
<lfn></lfn>
</docs>
<dp_list></dp_list>
<dsd>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\Stimuli</dsd>
<dxv>8</dxv>
<efs>
<filename>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-Example.sce</filename>
<filename>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-ExampleSUBS.pcl</filename>
<filename>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-ExampleINFO.pcl</filename>
<filename>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-ExamplePCL.pcl</filename>
</efs>
<exclusive_mouse>1</exclusive_mouse>
<exp_version></exp_version>
<exparam>
<man>
<cfg>
<dcfg>
<name>Default configuration</name>
<ss>
<sd></sd>
<sid>-1</sid>
</ss>
</dcfg>
</cfg>
<cs>-1</cs>
<dl>
<grps>
<grp>
<gn></gn>
<pl></pl>
</grp>
</grps>
</dl>
<parms>
<parms></parms>
<ssl></ssl>
</parms>
<pass></pass>
<ssa>
<asn>
<sid>-1</sid>
</asn>
</ssa>
</man>
</exparam>
<experiment_id>{6CBE7C00-257F-4536-8473-6B760D8DE78E}</experiment_id>
<font_settings>
<dpi>96</dpi>
<font_smooth>1</font_smooth>
<use_dpi>1</use_dpi>
<use_font_smooth>1</use_font_smooth>
</font_settings>
<ftp>
<ccc>0</ccc>
<do_upload>
<sce>1</sce>
</do_upload>
<host></host>
<id>{7F4B28C6-63E4-41B9-9BB0-568EB7C3350A}</id>
<idle_timeout>0</idle_timeout>
<login_timeout>0</login_timeout>
<mode>0</mode>
<no_upload></no_upload>
<password></password>
<pasv>0</pasv>
<port>21</port>
<remote_dir></remote_dir>
<sync>1</sync>
<testing>0</testing>
<type>0</type>
<upload>0</upload>
<username></username>
</ftp>
<idc>0</idc>
<idt>0</idt>
<ip_chans></ip_chans>
<isb>10000</isb>
<lfd>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\Logfiles</lfd>
<lnb>2</lnb>
<lno>0</lno>
<log>
<append_counter>1</append_counter>
<delimiter>9</delimiter>
<general_list>1</general_list>
<pien>0</pien>
<set_def_file></set_def_file>
<stimulus_list>0</stimulus_list>
<subject_id></subject_id>
<subject_id_pol>0</subject_id_pol>
<video_list>0</video_list>
<warnings>1</warnings>
</log>
<lol>1</lol>
<lpr></lpr>
<maxpv></maxpv>
<minpv></minpv>
<mss>4</mss>
<nam></nam>
<one_processor>2</one_processor>
<oports></oports>
<out_encrypt_key></out_encrypt_key>
<pi_list></pi_list>
<port_devices>
<device>
<parameters>
<cts>0</cts>
<dsrin>0</dsrin>
<dsrout>0</dsrout>
<dtr>disable</dtr>
<rts>disable</rts>
<set_fifo>1</set_fifo>
<spd></spd>
<spp></spp>
<spr></spr>
<sps></sps>
</parameters>
<piai>COM1</piai>
<pian>Serial Port</pian>
<pihpn>COM1</pihpn>
</device>
<device>
<parameters>
<cts>0</cts>
<dsrin>0</dsrin>
<dsrout>0</dsrout>
<dtr>enable</dtr>
<rts>disable</rts>
<set_fifo>0</set_fifo>
<spd>8</spd>
<spp>none</spp>
<spr>115200</spr>
<sps>1</sps>
</parameters>
<piai>COM2</piai>
<pian>Serial Port</pian>
<pihpn>COM2</pihpn>
</device>
</port_devices>
<rdl>
<device>
<abs_axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>X-axis</name>
<saturation>1</saturation>
</abs_axis>
<abs_axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>Y-axis</name>
<saturation>1</saturation>
</abs_axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>X-axis</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>Y-axis</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>Wheel</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<device_type>2</device_type>
<dx_device_type>18</dx_device_type>
<max_raw_pos>65535</max_raw_pos>
<min_raw_pos>0</min_raw_pos>
<name>Mouse</name>
</device>
<device>
<device_type>3</device_type>
<dx_device_type>19</dx_device_type>
<name>Keyboard</name>
</device>
<device>
<device_type>3</device_type>
<dx_device_type>0</dx_device_type>
<name>HID Keyboard Device</name>
</device>
<device>
<abs_axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>X-axis</name>
<saturation>1</saturation>
</abs_axis>
<abs_axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>Y-axis</name>
<saturation>1</saturation>
</abs_axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>X-axis</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>Y-axis</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>Wheel</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<device_type>2</device_type>
<dx_device_type>0</dx_device_type>
<max_raw_pos>65535</max_raw_pos>
<min_raw_pos>0</min_raw_pos>
<name>HID-compliant mouse</name>
</device>
<device>
<device_type>9</device_type>
<dx_device_type>0</dx_device_type>
<name>sound device</name>
</device>
<device>
<axis>
<max>1000</max>
<min>-1000</min>
<name>x</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<axis>
<max>1000</max>
<min>-1000</min>
<name>y</name>
<restricted>1</restricted>
<scale>1</scale>
</axis>
<device_type>5</device_type>
<dx_device_type>0</dx_device_type>
<inpc>1</inpc>
<name>pointing device</name>
<uoh>1</uoh>
<upc>0</upc>
<uvt>1</uvt>
</device>
<device>
<axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>X-axis</name>
<saturation>1</saturation>
</axis>
<axis>
<dead_zone>0</dead_zone>
<max>1000</max>
<min>-1000</min>
<name>Y-axis</name>
<saturation>1</saturation>
</axis>
<device_type>6</device_type>
<dx_device_type>0</dx_device_type>
<name>gameport device</name>
</device>
</rdl>
<refchg>1</refchg>
<rep>1</rep>
<require_name_match>0</require_name_match>
<reschg>1</reschg>
<rng>0</rng>
<rts>0</rts>
<sbs>100000</sbs>
<sce>
<sfn>all_scenarios</sfn>
</sce>
<sce>
<idv>
<device_type>3</device_type>
<dx_device_type>19</dx_device_type>
<ibn>ENTER</ibn>
<ibn>SPACE</ibn>
<ibn>N</ibn>
<ibn>Y</ibn>
<idn>Keyboard</idn>
<offset>28</offset>
<offset>57</offset>
<offset>49</offset>
<offset>21</offset>
</idv>
<sfn>F:\PresentationProjects\Annemiek Bergman\VoorbeeldscriptVoorOpDeTSG-Wiki\SMI-Eyetracker-Example\SMI-Eyetracker-Example.sce</sfn>
</sce>
<sct>
<capture_device>
<abort_on_max_drops>0</abort_on_max_drops>
<bps></bps>
<chan></chan>
<do_rec_vol>0</do_rec_vol>
<freq></freq>
<ignore_drops>1</ignore_drops>
<max_drops>250</max_drops>
<name>None</name>
<rec_vol>1</rec_vol>
<show_drops>1</show_drops>
</capture_device>
<resp_dev>
<combine>0</combine>
<ignore>1000</ignore>
<off_inter>200</off_inter>
<off_thresh>0.02</off_thresh>
<onset_mode>0</onset_mode>
<rec_dur>1000</rec_dur>
<save>0</save>
<thresh>0.2</thresh>
</resp_dev>
</sct>
<sde>
<buffer_length>1000</buffer_length>
<custom_buf>sec_sw</custom_buf>
<dup_channels>0</dup_channels>
<halt_on_underrun>1</halt_on_underrun>
<hw_buffer>0</hw_buffer>
<max_mix_length>50</max_mix_length>
<min_mix_length>25</min_mix_length>
<mixer>dx_software</mixer>
<rewind_distance>10</rewind_distance>
<side_speakers>1</side_speakers>
</sde>
<sdv>Primary Sound Driver</sdv>
<show_dis>0</show_dis>
<show_parm>0</show_parm>
<show_term>0</show_term>
<smc>2</smc>
<smd>16</smd>
<smr>44100</smr>
<srs>0</srs>
<ssb>2000</ssb>
<sse>
<s>
<a></a>
<ce>1</ce>
<ep>1</ep>
<p>0</p>
</s>
</sse>
<svl>
<attenuation>0</attenuation>
<do_attenuation>0</do_attenuation>
<do_volume>0</do_volume>
<volume>1</volume>
</svl>
<swp>1</swp>
<text_encoding>utf8</text_encoding>
<trigger_mode>
<cn></cn>
<m>0</m>
<v></v>
<vt>0</vt>
</trigger_mode>
<udt>0</udt>
<unc></unc>
<upb>0</upb>
<urp>0</urp>
## SMI iViewX Eyetracker Example SCE file
#
# Example made by Hubert F.J.M. Voogd (h.voogd@socsci.ru.nl)
scenario = "SMI-Eyetracker-Example";
pcl_file = "SMI-Eyetracker-ExamplePCL.pcl";
active_buttons = 4;
button_codes = 1,2,3,4;
$width_screen = 1920; # width of screen. The default SMI screen has a width of 1680. In our labs, the default is 1920.
$height_screen = 1080; # height of screen. The default SMI screen has a height of 1050. In our labs, the default is 1080.
begin;
picture {
} p_Default; ## black screen
#calibration bitmap
picture
{
background_color = 128, 128, 128; # background color should more or less match with the mean luminance of the screen during the experiment.
bitmap
{
filename = "white circle.bmp";
trans_src_color = 0,0,0;
};
x = 0;
y = 0;
} et_calibration;
picture { text { caption =
"A white circle with a black dot at the center will appear on screen.
Please look at the black dot in the center of the white circle.\n
[ Press Y to start ]"; font_size = 20;}
t_Calibration; x = 0; y = 0; } p_Calibration; ##calibration instructions
picture { text { caption =
"Validation Results: \n\n Accuracy X: - \n Accuracy Y: -\n \n"; } t_Accuracy; x = 0; y = 0; } p_Accuracy; ## calibration accuracy picture
box { height = 1; width = 30; color = 255,255,255; } Horz;
box { height = 30; width = 1; color = 255,255,255; } Vert;
picture {
box { height = 1; width = 30; color = 255,255,255; } b_Horz;x = 0; y = 0;
box { height = 30; width = 1; color = 255,255,255; } b_Vert;x = 0; y = 0;
} p_Fixation; ## fixation cross
picture{
text{caption = "Participant number?";font_size = 20;} t_Response1; x=0; y=0;
text{caption = " ";font_size = 20;} t_Response2; x=0; y=-40;
}p_InfoOutput;
picture { text { caption = "Welcome!"; font_size = 20; } t_Begin1; x = 0; y = 70;
text { caption = "In this experiment two images are presented on screen."; font_size = 20; } t_Begin2; x = 0; y = 35;
text { caption = "The computer will calibrate the eyetracker first."; font_size = 20; } t_Begin4; x = 0; y = -140;
text { caption = "[ Press ENTER to start the experiment ]"; font_size = 20; } t_Begin5; x = 0; y = -210;
} p_Begin; ## welcome screen
picture { text { caption = "This is the end of this task."; font_size = 20; } t_End1; x = 0; y = 0;
text { caption = "Thanks for your participation!"; font_size = 20; } t_End2; x = 0; y = -35;
} p_End; ## end screen
picture {
text { caption = "Press ENTER to continue to the next block."; font_size = 20; } t_Text1; x = 0; y = 0;
} p_Text;
picture{
bitmap{filename = "Penguins.jpg"; width = 650; height = 400;} PictureLeft; x = -420; y = 0;
bitmap{filename = "Koala.jpg"; width = 650; height = 400;} PictureRight;x = 420; y = 0;
} p_Stimulus;
\ No newline at end of file
## SMI iViewX Eyetracker Example SUBS PCL file
#
#
# Example made by Hubert F.J.M. Voogd (h.voogd@socsci.ru.nl)
# --------------------- EYETRACKER VARIABLES INITIATION ----------------------------;
bool useEyetracker = true; #false; # true or false toggles the use of the eyetracker.
bool makeScreenshot = false; #true; # true or false toggles the production of screenshots.
bool AcceptCalibration = false; # must initially be false, becomes true when the calibration is accepted by the experimenter.
double accuracy_x, accuracy_y;
int NumberOfCalibrationTries;
#Choose one of the following for the number of points used in the calibration:
#double calibration_method = 2.0; # 2-points calibration, not recommended because it is better to calibrate points in a plane.
#double calibration_method = 5.0; # 5 points calibration: the middle of the screen and the four corners
double calibration_method = 9.0; # 9 points calibration
#double calibration_method = 13.0; # 13 points calibration: This should give the best accuracy. But not in all subjects.
#Choose one of the following:
#double calibration_auto_accept = 0.0; # Do not auto accept. Every next point is reached by a press on the space bar. Check manually if the participant looks at the dot.
double calibration_auto_accept = 1.0; # Auto accept. The next dot is presented automatically. This option is recommended.
#Choose one of the following:
double calibration_speed = 0.0;
#double calibration_speed = 1.1;
# IP of the iView laptop.
# On the iViewX computer:
# Hold Windows-key and press the r-key. type cmd and press enter.
# This will open a command window. type ipconfig and press enter to see the IP-address of the computer.
string iViewX_IP = "192.168.1.2";
# IP of the Presentation computer.
# On the Presentation computer:
# Hold Windows-key and press the r-key. type cmd and press enter.
# This will open a command window. type ipconfig and press enter to see the IP-address of the computer.
string Local_IP = "192.168.1.1"; # local IP
# Port settings. Must match with the port settings in the IViewX software.
# Default is 4444 for sending to IViewX (IViewX listens on that port)and 5555 for receiving from IViewX (IViewX sends through that port).
# To see the port settings in the IViewX software, from the setup menu choose Hardware, then the communications-tab.
# One of the communication channels that are shown is configured as an Ethernet connection.
# Press configure and be carefull not to change anything.
int Send_Port = 4444; # see the iView software, this is the portnumber listed in the upper field, the Listen port in IViewX. Default is 4444.
int Recv_Port = 5555; # see the iView software, this is the portnumber listed in the lower field, the 'Send UDP packets to' port. Default is 5555.
eye_tracker tracker; # define tracker object
iViewXAPI::eye_tracker2 tracker2;# define IViewX eyetracker;
# ------------------ END OF EYETRACKER VARIABLES INITIATION ------------------------;
int iCountOld;
int iDurWait;
int iTimeStamp;
int iTrialCount;
int iTotalTrialCount;
int iNumberOfTrials;
string sKeyboardInput;
int iRowCount;
int iColumnCount;
# output_file ofile1 = new output_file;
# -------------------------- FILES -----------------------------
string sStimFilename;
string sOutputFilename;
# --------------------- INPUT FILE VARIABLES INITIATION ----------------------------;
int iMaxColumns = 16;
int iMaxTrials = 1024;## Aanpassen wanneer er meer trials (=rijen in stimuli text file) zijn
array <string> asHeader[iMaxColumns];
array <string> asTrialInputData[iMaxTrials][iMaxColumns];
## SMI iViewX Eyetracker Example main PCL file
#
# Example made by Hubert F.J.M. Voogd (h.voogd@socsci.ru.nl)
include "SMI-Eyetracker-ExampleSUBS.pcl";
int ret = 1;
if useEyetracker then
# Create a tracker object.
tracker2 = new iViewXAPI::eye_tracker2( "{B7A4A7F7-7879-4C95-A3BA-6CCB355AECF6}" );
# Connect to the IViewX program
ret = tracker2.connect(iViewX_IP, Send_Port, Local_IP, Recv_Port);
end;
if ret == 1 then # Succes! we have a connection with the IViewX program.
if useEyetracker then
tracker = new eye_tracker( "{FDC35980-7480-4761-859F-4DCCFA93BA57}" ); # create an instance of the actual tracker
tracker.start_tracking();
# start the recording, so that we can see that there is communication with the IViewX software: The timecounter of the recording
# in the IViewX program becomes red until the recording is paused.
tracker.set_recording(true);
wait_interval(1010); # make sure we have the time counter in tyhe IViuewX program set to 1 second,
# so that we can see that there is communication with the IViewX program.
# but put the recording on pause, because we don't need the data yet.
# The ET_PSE puts the recording of eyedata by IViewX on pause. The recording can be continued by the ET_CNT command.
# Note that IViewX and the Presentation plugin will report an error if an ET_PSE command is issued on a recording that
# has not been started, or that already is on pause. An error is also reported when an ET_CNT command is issued on a
# recording that is not started or that is not put on pause. ET_PSE and ET_CNT commands need to be matched.
tracker.send_command("ET_PSE ");
end;
GetKeyboardInput("What is your participant number?"); ##Subjectnummer
GetStimulusInputFile("Stimuluslist.txt"); # read input file. In this example we use a fixed input file, because this is an example about eyetracking.
# Create an output file here. In this example we do not collect data, other than iViewX eyetracker data.
# sOutputFilename = sKeyboardInput + "_logfile.dat";
# CreateOutput(sOutputFilename); # Write header things of logfile
p_Begin.present();
WaitForAllButtonpress();
p_Default.present();
wait_interval(1000);
RunBlock();
p_End.present();
wait_interval(2000);
if useEyetracker then
# post-experiment cleanup and saving ---- add this to the end of the experiment!
tracker.send_message("END_EXP ");
wait_interval(250);
# Tracker is paused, but somehow it cannot stop the recording when it is in pause mode; the Presentation plugin will report an error.
# Therefore we continue the recording before setting recording to false.
tracker.send_command("ET_CNT ");
# Stop the recording
tracker.set_recording(false);
wait_interval(250);
#Stop the eyetracker
tracker.stop_tracking();
# save the eyedata on the IViewX computer. Note that the path is a path on the IViewX computer, not on
# the Presentation computer. Also note that the path must exist! Otherwise no data is written to a file. Data can then be
# saved manually in the IViewX software by clicking the diskette icon.
# If the path is omitted, the .idf file will be written in the same folder as the exe of the IViewX software.
# save_data has four arguments:
# 1: filename (string). Ends with '.idf', if it starts with a path, the path must exist on the IViewX computer.