Created
May 18, 2020 14:24
-
-
Save pfaion/605004058db6336203b2ebd6b9c82d61 to your computer and use it in GitHub Desktop.
Deduplicate Gaze Timestamps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from plugin import Plugin | |
from player_methods import Bisector | |
class DeduplicateGaze(Plugin): | |
@classmethod | |
def parse_pretty_class_name(cls) -> str: | |
return "(Custom) Deduplicate Gaze Timestamps" | |
def __init__(self, g_pool): | |
super().__init__(g_pool) | |
self.remove_duplicate_gaze() | |
def on_notify(self, notification): | |
if notification["subject"] == "gaze_positions_changed": | |
if notification.get("from_custom_deduplicator", False): | |
return | |
self.remove_duplicate_gaze() | |
def remove_duplicate_gaze(self): | |
data = self.g_pool.gaze_positions.data | |
ts = self.g_pool.gaze_positions.data_ts | |
unique_ts, unique_idxs = np.unique(ts, return_index=True) | |
if len(unique_ts) == len(ts): | |
return | |
unique_data = [data[i] for i in unique_idxs] | |
self.g_pool.gaze_positions = Bisector(unique_data, unique_ts) | |
self.notify_all( | |
{"subject": "gaze_positions_changed", "from_custom_deduplicator": True} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment