Module gonioanalysis.drosom.optic_flow

Estimating optic flow field

Functions

def field_error(points_A, vectors_A, points_B, vectors_B, direction=False, colinear=False)

Relieved version where points dont have to overlap

Put to A the eye vecotrs

vectors_X list of vector vector (x,y,z)

direction Try to get the direction also (neg/pos)

colinear : bool

Returns the errors at points_A

def field_pvals(points_A, vectors_A, points_B, vectors_B, direction=False, colinear=False)

Assuming

def flow_direction(point, xrot=0)

Estimates optic flow at the given point by placing the optic flow vector to the point, and forcing it to the tangent plane of the sphere.

The optic flow vector is a unit vector -j (ie. pointing to negative y-axis), unless rotated. This should be okay since we are interested only in the direction of the flow field, not magnitude.

INPUT ARGUMENTS DESCRIPTION point (x0,y0,z0) xrot Rotation about x-axis

RETURNS xi,yj,zk Flow direction vector at origo

def flow_vectors(points, xrot=0)

Returns optic flow vectors (from flow_direction) as a numpy array.

Classes

class FAnalyser (*args, **kwargs)

Sham analyser to just output optic flow vectors with the same api as MAnalyer does.

Initialize the MAnalyser object.

Arguments

no_data_load : bool
If True, skips loading data at constructing the object (use if needing many short lived objects.
active_analysis : string
Name of the activated analysis
Expand source code
class FAnalyser(MAnalyser):
    '''
    Sham analyser to just output optic flow vectors with the same
    api as MAnalyer does.
    '''
    
    def __init__(self, *args, **kwargs):
            
        print('inited')
        
        self.manalysers = [self]
        self.folder = 'optic_flow'
        self.eyes = ['left', 'right']
        self.vector_rotation = 0
        

        # FAnalyser specific
        self.pitch_rot = 0
        self.roll_rot = 0
        self.yaw_rot = 0
        self.points = {'right': coordinates.optimal_sampling(np.arange(0, 60, 5), np.arange(-100, 100, 5)),
                'left': coordinates.optimal_sampling(np.arange(-60, 0, 5), np.arange(-100, 100, 5))}
        
        self.constant_points = False
        

        self.ui_options = {
                'pitch_rot': {'help': 'Pitch rotation', 'type': float},
                'roll_rot': {'help': 'Roll rotation', 'type': float},
                'yaw_rot': {'help': 'Yaw rotation', 'type': float},
                }


    def get_3d_vectors(self, eye, constant_points=None, *args, **kwargs):
        '''
        
        constant_points : bool
            If true, points stay the same and only vectors get rotated.
            If false, smooth rotation of the whole optic flow sphere.
        '''

        if constant_points is None:
            constant_points = self.constant_points

        if constant_points:
            # Rotate points, calculate vectors, rotate back
            points = coordinates.rotate_points(self.points[eye],
                    radians(self.yaw_rot),
                    radians(self.pitch_rot),
                    radians(self.roll_rot))
            
            points, vectors = coordinates.rotate_vectors(points, flow_vectors(points, xrot=0),
                    -radians(self.yaw_rot),
                    -radians(self.pitch_rot),
                    -radians(self.roll_rot))
        else:
            points = coordinates.optimal_sampling(np.arange(-90,90,5), np.arange(-180,180,5))
            points, vectors = coordinates.rotate_vectors(points, flow_vectors(points, xrot=0),
                    -radians(self.yaw_rot),
                    -radians(self.pitch_rot),
                    -radians(self.roll_rot))
            
            # Fixme. Make me with numpy, not list comprehension
            if eye == 'left':
                indices = [i for i, point in enumerate(points) if point[0] <= 0]
            elif eye == 'right':
                indices = [i for i, point in enumerate(points) if point[0] >= 0]

            points = [points[i] for i in indices]
            vectors = [vectors[i] for i in indices]
        
        return np.array(points), np.array(vectors)

    
    def is_measured(self, *args, **kwargs):
        return True

    def are_rois_selected(self, *args, **kwargs):
        return True

    def load_analysed_movements(self, *args, **kwargs):
        return None

Ancestors

Methods

def get_3d_vectors(self, eye, constant_points=None, *args, **kwargs)

constant_points : bool If true, points stay the same and only vectors get rotated. If false, smooth rotation of the whole optic flow sphere.

def load_analysed_movements(self, *args, **kwargs)

Inherited members