allensdk.internal.brain_observatory.eye_calibration module

class allensdk.internal.brain_observatory.eye_calibration.EyeCalibration(monitor_position=array([11.86, 8.62, 3.16]), monitor_rotations=array([0., 0., 0.]), led_position=array([25.89, -6.12, 3.21]), camera_position=array([13., 0., 0.]), camera_rotations=array([0., 0., 0.22863813]), eye_radius=0.1682, cm_per_pixel=0.0010199999999999999)[source]

Bases: object

Class for performing eye-tracking calibration.

Provides methods for estimating the position of the pupil in 3D space and projecting the gaze onto the monitor in both 3D space and monitor space given the experimental geometry.

Parameters:
monitor_position : numpy.ndarray

[x,y,z] position of monitor in cm.

monitor_rotations : numpy.ndarray

[x,y,z] rotations of monitor in radians.

led_position : numpy.ndarray

[x,y,z] position of LED in cm.

camera_position : numpy.ndarray

[x,y,z] position of camera in cm.

camera_rotations : numpy.ndarray

[x,y,z] rotations for camera in radians. X and Y must be 0.

eye_radius : float

Radius of the eye in cm.

cm_per_pixel : float

Pixel size of eye-tracking camera.

compute_area(self, pupil_parameters)[source]

Compute the area of the pupil.

Assume the pupil is a circle, and that as it moves off-axis with the camera the observed ellipse major axis remains the diameter of the circle.

Parameters:
pupil_parameters : numpy.ndarray

[nx5] array of pupil parameters.

Returns:
numpy.ndarray

[nx1] array of pupil areas in estimated pixels.

static cr_position_in_mouse_eye_coordinates(led_position, eye_radius)[source]

Determine the 3D position of the corneal reflection.

The eye is modeled as a spherical mirror, so the reflection appears to be half the radius of the eye from the origin along the eye-LED axis.

Parameters:
led_position : numpy.ndarray

[x,y,z] position of the LED in eye coordinates.

eye_radius : float

Radius of the eye in centimeters.

Returns:
numpy.ndarray

[x,y,z] location of the corneal reflection in eye coordinates.

pupil_position_in_mouse_eye_coordinates(self, pupil_parameters, cr_parameters)[source]

Compute the 3D pupil position in mouse eye coordinates.

Parameters:
pupil_parameters : numpy.ndarray

Array of pupil parameters for each eye tracking frame.

cr_paramaeters : numpy.ndarray

Array of corneal reflection parameters for each eye tracking frame.

Returns:
numpy.ndarray

Pupil position estimates in eye coordinates.

pupil_position_on_monitor_in_cm(self, pupil_parameters, cr_parameters)[source]

Compute the pupil position on the monitor in cm.

Parameters:
pupil_parameters : numpy.ndarray

Array of pupil parameters for each eye tracking frame.

cr_paramaeters : numpy.ndarray

Array of corneal reflection parameters for each eye tracking frame.

Returns:
numpy.ndarray

Pupil position estimates in eye coordinates.

pupil_position_on_monitor_in_degrees(self, pupil_parameters, cr_parameters)[source]

Get pupil position on monitor measured in visual degrees.

Parameters:
pupil_parameters : numpy.ndarray

Array of pupil parameters for each eye tracking frame.

cr_paramaeters : numpy.ndarray

Array of corneal reflection parameters for each eye tracking frame.

Returns:
numpy.ndarray

Pupil position estimate in visual degrees.

allensdk.internal.brain_observatory.eye_calibration.base_object_to_eye_rotation_matrix(object_position)[source]

Rotation matrix to rotate base object frame to eye coordinates.

By convention, any other object’s coordinate frame before rotations is set with positive Z pointing from the object’s position back to the origin of the eye coordinate system, with X parallel to the eye X-Y plane.

Parameters:
object_position : np.ndarray

[x, y, z] position of object in eye coordinates.

Returns:
numpy.ndarray

[3x3] rotation matrix.

allensdk.internal.brain_observatory.eye_calibration.object_norm_eye_coordinates(object_position, x_rotation, y_rotation, z_rotation)[source]

Get the normal vector for the object plane in eye coordinates.

Parameters:
object_position : numpy.ndarray

[x, y, z] location of the object in eye coordinates.

x_rotation : float

Rotation about the x-axis in radians.

y_rotation : float

Rotation about the y-axis in radians.

z_rotation : float

Rotation about the z-axis in radians.

Returns:
numpy.ndarray

Endpoint of the object plane vector in eye coordinates.

allensdk.internal.brain_observatory.eye_calibration.object_rotation_matrix(x_rotation, y_rotation, z_rotation)[source]

Rotation matrix in object coordinate frame.

The rotation matrix for rotating the object coordinate frame from the initial position. This is done by rotating around x, then around y’, then around z’’.

Parameters:
x_rotation : float

Rotation about x axis in radians.

y_rotation : float

Rotation about y axis in radians.

z_rotation : float

Rotation about z axis in radians.

Returns:
numpy.ndarray

[3x3] rotation matrix.

allensdk.internal.brain_observatory.eye_calibration.project_to_plane(plane_normal, plane_point, points)[source]

Project from the origin through points onto a plane.

Parameters:
plane_normal : numpy.ndarray

[x, y, z] normal unit vector to the plane.

plane_point : numpy.ndarray

[x, y, z] point on the plane.

points : numpy.ndarray

[nx3] points in space through which to project.

Returns:
numpy.ndarray

[nx3] points projected on the plane.