-
How to get the pupil diameter using the long axis 'a' and short axis 'b' after using the ellipse to fit the pupil? I'm confused about it and want to know how PupilEXT defined pupil diameter and is it in the same way that 6 ways(Starburst, Swirski2D, ExCuSe, ElSe, PuRe and PuReST ) in PupilEXT defined pupil diameter. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The code of the applied pupil detection procedures are provided (see here), so you can directly verify how the ellipse parameters are determined from the raw contour data. For example, the ElSe method (see line 249 in this file) uses the elipsefit method (see here) from the OpenCV library, which returns the centre coordinates, angle and size (height and width) of the ellipse. In pupillometry, the longer axis (major axis) is always used as the pupil diameter to minimise pupil foreshortening error. Thus, in PupilEXT, we check which size is greater (height or width) and set the major axis as pupil diameter (see here). Note that all ellipse parameters are provided in the recorded CSV log file of PupilEXT, so you are free to use the height or width (also other parameters) of the ellipse for your custom analysis. If you want to refit the recorded ellipse on an image using the provided parameters in the CSV file, you could do something like this in Python, for example: import cv2
angle = pupil.angle
if pupil.width() < pupil.height():
angle = angle - 90
# The pupil.* parameters are the provided values in the csv file
img_plot = cv2.ellipse(img_plot,
(int(pupil.center[0]) + rect_array[0], int(pupil.center[1]) + rect_array[1]),
(int(pupil.majorAxis()/2), int(pupil.minorAxis()/2)), angle,
0, 360, (0, 0, 255), 2) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help, the answer is so clear. |
Beta Was this translation helpful? Give feedback.
The code of the applied pupil detection procedures are provided (see here), so you can directly verify how the ellipse parameters are determined from the raw contour data.
For example, the ElSe method (see line 249 in this file) uses the elipsefit method (see here) from the OpenCV library, which returns the centre coordinates, angle and size (height and width) of the ellipse.
In pupillometry, the longer axis (major axis) is always used as the pupil diameter to minimise pupil foreshortening error. Thus, in PupilEXT, we check which size is greater (height or width) and set the major axis as pupil diameter (see here). Note that all ellipse parameters are provided in the recorded CSV log file…