Introduction: The story behind the data
Have you ever wondered how we can understand where people are looking? In my recent project, I explored gaze data from an eye-tracking study designed using a Random Saccade Task (RAN). This experiment tracked participants’ eye movements following a randomly displaced bull’s eye target across a monitor. The goal? is to uncover meaningful patterns in gaze behaviour using k-nearest Neighbours (k-NN) clustering.
Understanding the Dataset
The dataset came from visually-guided oblique saccades, with target positions varying within a ±15° and ±9° range horizontally and vertically, respectively. Each gaze point represented a target position held for one second, ensuring uniform coverage. This randomized trajectory ensured the gaze data was robust across sessions and participants, while the black background provided visual contrast.
Key characteristics:
- Spatial Range: Targets displaced with a minimum of 2° between positions.
- Temporal Component: 1-second fixation intervals per target.
- Volume: The analysis focused on a dummy dataset of 1000 points for initial exploration
Why k-NN for Gaze Data?
k-NN is a simple yet powerful algorithm for clustering spatial data. Analyzing the proximity of gaze points to pre-defined centers helps identify regions of interest where participants’ focus converged during the task. The method works seamlessly for tasks like gaze pattern analysis because:
- Clustering Behaviour: it highlights natural groupings in gaze points.
- Flexibility: No assumptions about data distributions are required.
- Interpretability: Results are intuitive and visually meaningful.
Implementation in Python
For this project, I implemented k-NN using Python. The workflow included:
- Data Preprocessing: cleaning and structuring gaze points for analysis
- Clustering: Applying k-NN to identify regions of interest.
- Visualizations: Using libraries like
matplotlib
to map clusters onto the display space for easy interpretation.
Here’s a snippet of the process:
from sklearn.neighbors import NearestNeighbors
import numpy as np
import matplotlib.pyplot as plt
# Simulate dummy gaze data
np.random.seed(42)
gaze_data = np.random.uniform(low=-15, high=15, size=(1000, 2))
# Apply k-NN
knn = NearestNeighbors(n_neighbors=5)
knn.fit(gaze_data)
distances, indices = knn.kneighbors(gaze_data)
# Visualize
plt.scatter(gaze_data[:, 0], gaze_data[:, 1], s=5, alpha=0.6)
plt.title("Gaze Data Clustering using k-NN")
plt.xlabel("Horizontal Angle (°)")
plt.ylabel("Vertical Angle (°)")
plt.show()
Results and Key Takeaways
The k-NN algorithm revealed fascinating insights into gaze behaviour, such as clusters forming around key target regions. These clusters suggest areas of visual interest or attention consistency, valuable for understanding participants’ focus during randomized tasks.
Challenges
- High dimensionality: Real-world gaze data might include more dimensions, such as time and velocity, which require advanced techniques.
- Parameter Tuning: Choosing the right
k
is critical for meaningful clusters.
Future Directions
This work sets the stage for more complex analyses, such as:
- Incorporating patterns to study gaze shifts.
- Apply density-based methods like DBSCAN to irregularly shaped clusters.
- Real-world applications like UX design or neurological research.
Conclusion: Where the Eyes Lead, Insight Follow
Exploring gaze data using k-NN was an eye-opener (pun intended!). The simplicity of k-NN combined with the richness of gaze data offers a gateway to understanding visual behavior. This journey taught me the power of machine learning in making sense of complex datasets–and I can’t wait to take it further.