Calculate Line to Point Distance

Overview

This transform calculates the minimum distance from a set of points to a line for each moment in time, which is useful for quantifying the spatial relationship between different tracked objects.

Detailed Description

This operation computes the shortest Euclidean distance between a line (composed of connected segments) and one or more points at each corresponding timestamp. If multiple points are present at a single timestamp, the transform identifies the minimum distance among all points to the line. The calculation finds the closest point on any segment of the line to each of the provided points and returns the smallest distance found.

If the line and points are associated with different spatial scales (i.e., different image sizes), the points will be automatically scaled to the line’s coordinate system before the distance is computed. The output is an analog time series where the value at each time point is the calculated minimum distance.

Neuroscience Use Cases

This transformation is valuable for analyzing the interaction between different elements in behavioral or physiological experiments:

  • Whisker Tracking: In studies of rodent behavior, one might track the position of a whisker (as a line) and the location of an object (as a point). This transform can precisely measure the distance from the whisker to the object at each frame of a video, helping to identify moments of contact or near-contact.
  • Limb and Body Coordination: When tracking the movement of an animal’s limb (represented as a line) relative to a target or another body part (represented as a point), this transform can quantify their spatial relationship over time. This is useful for studies of motor control and coordination.
  • Neural Prosthetics and Brain-Computer Interfaces: In experiments where an animal controls a cursor or robotic arm, this transform could be used to measure the distance from the effector (the line) to a target (the point), providing a continuous measure of performance.

Parameters

This transform has the following parameter:

  • point_data: The key of the PointData object in the DataManager. This object contains the set of points from which the minimum distance to the line will be calculated at each timestamp.

Example Configuration

Here is a complete example of a JSON configuration file that could be used to run this transformation. This example calculates the distance between a line stored with the key test_line and a set of points stored with the key test_points.

[
{
    "transformations": {
        "metadata": {
            "name": "Line to Point Distance Pipeline",
            "description": "Test line to point minimum distance calculation",
            "version": "1.0"
        },
        "steps": [
            {
                "step_id": "1",
                "transform_name": "Calculate Line to Point Distance",
                "phase": "analysis",
                "input_key": "test_line",
                "output_key": "line_point_distances",
                "parameters": {
                    "point_data": "test_points"
                }
            }
        ]
    }
}
]