User Tools

Site Tools


biac:analysis:roi_et

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

biac:analysis:roi_et [2011/04/25 18:26]
petty [ROI Drawing]
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://www.biac.duke.edu/home/gadde/xmlheader-docs/|BXH/XCEDE tools]]. 
-Please see the documentation for eprime2xml, showplay2xml, eventstable2xml to create the files.   
- 
-Your resulting event nodes should include (at minimum): 
-  * the image name 
-  * onset 
-  * duration 
- 
-For example:  
-<HTML> 
-  <event type="image" units="sec"> 
-    <onset>425.894</onset> 
-    <duration>4</duration> 
-    <value name="imgName">12F_CA_C.bmp</value> 
-    <value name="regType">positive</value> 
-    <value name="trialType">FACE</value> 
-    <value name="response">1</value> 
-    <value name="RT">244</value> 
-  </event> 
-</HTML> 
- 
- 
-===== 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.  Chris Petty has written a matlab based function that will let you draw circles/ellipses or squares/rectangles on input images.  The result is an XML which can be merged into your behavioral XML using the bxh tool **bxh_eventmerge** . 
- 
-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> 
-/home/petty/eyetracking/sys_service/37M_CA_C.bmp 
-/home/petty/eyetracking/sys_service/HAI_31.bmp 
-</file> 
- 
-- Also, either add the path to the actual drawing function **"imgROI_keyfcn"**, or make a copy of it to your own directory ( the most current copy is \\Munin\Data\Programs\User_Scripts\petty\matlab\ ) 
-   
-- 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 ~/net/munin/data/Programs/User_Scripts/petty/matlab/ 
- 
-%% full path to your text file, which contains images ( also full path ) 
-fileList = textread('file_names.txt','%s'); %read in list 
-XML.rois = {}; %create empty XML 
-outName = 'my_output.xml'; %name of output .xml with all ROIs ( file will overwrite on each save ) 
- 
-%screen resolution of task display 
-xRes = 1024; 
-yRes = 768; 
-scrSize = [ xRes yRes ]; 
- 
-imgIDX = 0; %leave 0 to start at first image 
- 
-figUD = struct('imgIDX',imgIDX,'XML',XML); 
-    %loop that finds images 
-    imgs = {}; 
-    for file=1:length(fileList) 
-        [path name ext] = fileparts(fileList{file}); 
-        imgs{file} = struct('fname',[name ext],'fpath',fileList{file}); 
-    end 
- 
-%% this opens the drawing window and runs functions: do not edit %% 
-fscreen = repmat(uint8(0),[scrSize(2),scrSize(1),3]); 
-axes_h = axes; 
-imshow(fscreen,'Parent',axes_h,'InitialMagnification',100,'Border','tight'); 
-text(10,60,{'i - image','e - ellipse','r - rectangle','s - save','q - quit' },'HorizontalAlignment','left','BackgroundColor',[.5 .5 .5],'Color',[1 1 1]); 
-figH = gcf; 
-set(figH,'Toolbar','none','Resize','off'); 
-set(figH,'UserData',figUD); 
-hold on; 
- 
-% calls the functions 
-set(figH,'KeyPressFcn','imgROI_keyfcn(gcbo,axes_h,imgs,scrSize,outName)'); 
-</file> 
- 
- 
-Once the text file is create with full paths to each image, save/run your version of the above script.  You should just need to edit the path, screen size, file names.  The script will open a representation of the stimulis screen, press **"i"** to load the first image. 
- 
-The current keyboard options are (these appear inside of the drawer) : 
-<file> 
-i - load the next image 
-e - draw an ellipse/circle 
-r - draw a rectangle/square 
-s - save the XML 
-q - quit 
-</file> 
- 
-Once the image is loaded, press **"e"** or **"r"** to start your first ROI.  There will be a small circle or square depending on the shape you selected.  Drag the whole ROI to your desired location, then drag the sides or corners to form your desired shape.  Once satisfied double-click on the ROI to name it. The name will appear inside the XML node associated with this ROI as well on the screen inside the associated ROI.  You can draw multiple ROIs on each image, but be aware that if they overlap it will affect your final "hit" percentage. 
- 
-Here's an example of a drawn/labled elliptical roi: 
- 
-{{:biac:analysis:drawer_example.png?800|}} 
- 
-Once finished with the image, press **"s"** to save the current progress. This will add to the output file on each save, so feel free to save after each region.  Just make sure you aren't initially overwritting a previous file!  Press **"i"** to move on to the next image in your list, or **"q"** to quit if you are finished. 
- 
-Here's an example of the output: 
- 
-<HTML> 
-<rois> 
-  <roi type="block"> 
-    <name>chin</name> 
-    <origin>695 529</origin> 
-    <size>100 100</size> 
-    <units>pixels</units> 
-    <value name="imgName">oscar.jpg</value> 
-  </roi> 
-  <roi type="block"> 
-    <name>chest</name> 
-    <origin>447 387</origin> 
-    <size>100 100</size> 
-    <units>pixels</units> 
-    <value name="imgName">oscar.jpg</value> 
-  </roi> 
-</rois> 
-</HTML> 
biac/analysis/roi_et.txt · Last modified: 2023/02/23 18:43 (external edit)