Add kinematics functions for eye/cursor - #301
Conversation
| def get_average_eye_position(eye_pos): | ||
| ''' | ||
| Get the average x,y position data between left and right eyes | ||
|
|
||
| Args: | ||
| eye_pos (nt, 4): array of eye position data for one trial, as output by exp_data | ||
|
|
||
| Returns: | ||
| (nt, 2): array of x,y position data averaged between both eyes | ||
| ''' | ||
|
|
||
| return np.stack([(eye_pos[:,0]+eye_pos[:,2])/2, (eye_pos[:,1]+eye_pos[:,3])/2], axis=1) |
There was a problem hiding this comment.
could we incorporate the eye_labels into the input of this function so it knows exactly what indices to average?
|
|
||
| return np.stack([(eye_pos[:,0]+eye_pos[:,2])/2, (eye_pos[:,1]+eye_pos[:,3])/2], axis=1) | ||
|
|
||
| def plot_hist_and_get_threshold(data, num_sd = 0, xlabel=''): |
There was a problem hiding this comment.
it's slightly weird to have a function that computes something and also plots something. maybe you can make an optional argument to plot the histogram, but by default this function only computes the threshold?
|
|
||
| return threshold | ||
|
|
||
| def downsample_timestamps(old_event_timestamps, new_samplerate, in_samples = True): |
There was a problem hiding this comment.
this can be simplified to
new_event_timestamps = np.round(old_event_timestamps * new_samplerate, 0) / new_samplerate
or something like that. i would change the name to get_nearest_timestamps or similar
| else: | ||
| return new_event_timestamps / new_samplerate # in seconds | ||
|
|
||
| def assign_zone(pos, target, target_radius): |
There was a problem hiding this comment.
| def assign_zone(pos, target, target_radius): | |
| def assign_zone(pos, target, target_radius): |
| def assign_zone(pos, target, target_radius): | |
| def assign_ja_zone(pos, target, target_radius): |
|
|
||
| return cursor_dists, cursor_vels, dist_slope, dist_avg, vel_slope, vel_avg | ||
|
|
||
| def compute_directional_error(pos, target, use_initial_direction = False): |
There was a problem hiding this comment.
There’s an existing function get_inst_target_dir which I think does the same thing as this. Maybe take a look before writing any tests for this one.
Functions added to postproc, visualizations, analysis, utils
Tests haven't yet been made