This shows you the differences between two versions of the page.
biac:analysis:roi_et [2011/04/25 19:47] petty |
biac:analysis:roi_et [2023/02/23 18:43] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Region of Interest Based Eyetracking Analysis ====== | ||
- | These steps were created to gather eyetracking information based on specific regions of interest drawn on stimuli from the experimental task. The following assumes your task was image based, ( or images can be created to mimic the task ), there is XML behavioral output from the task, and your eyetracking was collected through Cigal or Viewpoint. | ||
- | |||
- | ===== Behavioral XML ===== | ||
- | |||
- | The first step is to create behavioral XML files using the [[http:// | ||
- | Please see the documentation for eprime2xml, showplay2xml, | ||
- | |||
- | Your resulting event nodes should include (at minimum): | ||
- | * the image name | ||
- | * onset | ||
- | * duration | ||
- | |||
- | For example: | ||
- | < | ||
- | <event type=" | ||
- | < | ||
- | < | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | </ | ||
- | </ | ||
- | |||
- | |||
- | ===== ROI Drawing ===== | ||
- | |||
- | Next, ROIs should be drawn for each image that you wish to calculate eyetracking data. These ROIs should be saved in an XML based format. | ||
- | |||
- | All of the following steps are based on this type of ROI. | ||
- | |||
- | - The first thing you need is a text file with all the image paths ( the full path to the image is recommended ). | ||
- | |||
- | <file txt file_names.txt> | ||
- | / | ||
- | / | ||
- | </ | ||
- | |||
- | - Also, either add the path to the actual drawing function **" | ||
- | | ||
- | - Screen resolution is the resolution of the display that the task was run on. The drawing function creates a representation based on that size. | ||
- | |||
- | Here is a sample script to run the drawing function: | ||
- | <file matlab drawer_sample.m> | ||
- | %% add path to functions | ||
- | %addpath \\Munin\Data\Programs\User_Scripts\petty\matlab\ | ||
- | addpath ~/ | ||
- | |||
- | %% full path to your text file, which contains images ( also full path ) | ||
- | fileList = textread(' | ||
- | XML.rois = {}; %create empty XML | ||
- | outName = ' | ||
- | |||
- | %screen resolution of task display | ||
- | xRes = 1024; | ||
- | yRes = 768; | ||
- | scrSize = [ xRes yRes ]; | ||
- | |||
- | imgIDX = 0; %leave 0 to start at first image | ||
- | |||
- | figUD = struct(' | ||
- | %loop that finds images | ||
- | imgs = {}; | ||
- | for file=1: | ||
- | [path name ext] = fileparts(fileList{file}); | ||
- | imgs{file} = struct(' | ||
- | end | ||
- | |||
- | %% this opens the drawing window and runs functions: do not edit %% | ||
- | fscreen = repmat(uint8(0), | ||
- | axes_h = axes; | ||
- | imshow(fscreen,' | ||
- | text(10, | ||
- | figH = gcf; | ||
- | set(figH,' | ||
- | set(figH,' | ||
- | hold on; | ||
- | |||
- | % calls the functions | ||
- | set(figH,' | ||
- | </ | ||
- | |||
- | |||
- | Once the text file is create with full paths to each image, save/run your version of the above script. | ||
- | |||
- | The current keyboard options are (these appear inside of the drawer) : | ||
- | < | ||
- | i - load the next image | ||
- | e - draw an ellipse/ | ||
- | r - draw a rectangle/ | ||
- | s - save the XML | ||
- | q - quit | ||
- | </ | ||
- | |||
- | Once the image is loaded, press **" | ||
- | |||
- | Here's an example of a drawn/ | ||
- | |||
- | {{: | ||
- | |||
- | Once finished with the image, press **" | ||
- | |||
- | Here's an example of the output: | ||
- | |||
- | < | ||
- | < | ||
- | <roi type=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | <value name=" | ||
- | </ | ||
- | <roi type=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | <value name=" | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | ===== Merge Behavioral XML and ROI XML Data ===== | ||
- | |||
- | Now its necesary to merge the two sets of XML data together using **" | ||
- | |||
- | <file sh merge_rois_into_behav.sh> | ||
- | #!/bin/sh | ||
- | |||
- | bxh_eventmerge \ | ||
- | --grabexcludeset ' | ||
- | --mergeeventpath '// | ||
- | ' | ||
- | ' | ||
- | BEHAVIORAL_run.xml \ | ||
- | my_drawn_ET_ROI.xml | ||
- | | ||
- | ## comments | ||
- | # grabexcludeset ignores any matches | ||
- | # mergeeventpath is the path to the XML nodes from the ROI.xml, the example above represents | ||
- | # < | ||
- | # < | ||
- | # </ | ||
- | # ' | ||
- | # my GRABQUERY is just ' | ||
- | |||
- | </ | ||
- | |||
- | The above script assumes that the behavioral XML and ROI XML have the images have the same name attribute: | ||
- | < | ||
- | |||
- | The script grabs everything except this node, and merges it into your behavioral xml. By default it writes to a new file with " | ||
- | |||
- | Because the ROI XML has all <roi> nodes inside of the < | ||
- | |||
- | |||
- | For example, the following image has 2 associated ROIs that have been merged over: | ||
- | |||
- | < | ||
- | <event type=" | ||
- | < | ||
- | < | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | <value name=" | ||
- | <roi type=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | <roi type=" | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | |||
- | ===== Preprocess Eyetracking Data ===== | ||
- | |||
- | This will convert either Cigal or Viewpoint wks files into CSV ( comma-separated values ), with distinct headers for each column. | ||
- | |||
- | Cigal files will already be in pixel resolution. | ||
- | |||
- | Chris Petty has written a perl script (**preprocess_eyetracking.pl**) to handle the preprocessing with various input flags. | ||
- | |||
- | <code perl> | ||
- | USAGE: preprocess_eyetracking.pl [options] --input FILE --output FILENAME --type TYPE | ||
- | |||
- | where [OPTIONS] may be the following: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | < | ||
- | |||
- | *--input: is your eyetracking data ( either .wks or cigal eyepos file ) | ||
- | * --output: is the name to output your csv file ( .txt, .csv, .wks are all file ) | ||
- | * --type: represents " | ||
- | |||
- | if **wks** input, --onsetMarker is required if the data is not time-locked to your zero point. | ||
- | |||
- | if **wks** input is not in pixel dimensions as mentioned above, --convertpix with tell the script to convert the normalized space into pixel dimensions using the X and Y values ( --xres, --yres ) | ||
- | |||
- | This output will be used in all future steps. | ||
- | |||
- | For example: | ||
- | <file csv> | ||
- | VP_Code, | ||
- | 12,0,M | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | 10, | ||
- | </ | ||
- | |||
- | |||
- | ===== Calculate Eyetracking Hits ===== | ||
- | |||
- | Hits are considered eyetracking points where gaze was within ROIs defined in step 1. | ||
- | |||
- | Chris written a perl script (**merge_eyetracking.pl**), | ||
- | The script can be copied from: \\Munin\Data\Programs\User_Scripts\petty, | ||
- | |||
- | < | ||
- | USAGE: merge_eyetracking.pl [options] --eyetracking FILE --behavioral XML --output XML --type | ||
- | |||
- | where [OPTIONS] may be the following: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | * --eyetracking: | ||
- | * --behavioral : behavioral XML ( with ROIs merged ) | ||
- | * --ouput | ||
- | * --type | ||
- | |||
- | < |