Extract Point from Line

Overview

This transform extracts a specific point from a line at a given fractional position. This is useful for isolating a single point of interest along a tracked object, such as the tip, base, or midpoint of a whisker or limb.

Detailed Description

This operation pinpoints and extracts the coordinates of a single point along a line for each time step. The position of the point is determined by a fractional value from 0.0 (the start of the line) to 1.0 (the end of the line). Two different methods are available for extracting the point:

  • Direct Method: This method calculates the cumulative length of the line’s segments and finds the point that lies at the specified fractional distance along this length. If use_interpolation is enabled, it will linearly interpolate between two adjacent vertices of the line to find the exact position. If disabled, it will select the nearest vertex.
  • Parametric Method: This method fits a polynomial to the line’s x and y coordinates separately as a function of the parametric distance along the line. It then evaluates the polynomial at the specified fractional position to determine the point’s coordinates. This can be useful for smoothing out irregularities in the line.

The output is a PointData object containing the extracted point for each time step.

Neuroscience Use Cases

This transformation is particularly useful for detailed analysis of movement and morphology:

  • Whisker Analysis: Researchers can extract the tip (position 1.0), base (position 0.0), or any other consistent point along a tracked whisker. This allows for precise analysis of whisker contact, bending, or movement relative to other objects or whiskers.
  • Limb Tracking: In studies of locomotion or reaching, this transform can isolate specific points on a limb, such as the endpoint (e.g., a hand or paw) or a joint (e.g., an elbow), to analyze trajectories and kinematics.
  • Morphological Measurement: For organisms that change shape, like larvae or worms, this transform can be used to track specific points on the body midline to quantify bending or undulation.

Parameters

This transform has the following parameters:

  • position (float): The fractional distance along the line where the point should be extracted. Must be between 0.0 (start) and 1.0 (end).
  • method (string): The method to use for point extraction. Can be either "Direct" or "Parametric".
  • polynomial_order (integer, optional): The order of the polynomial to fit to the line if using the Parametric method. Defaults to 3.
  • use_interpolation (boolean, optional): Whether to use linear interpolation to find the exact point when using the Direct method. If false, the nearest vertex on the line is returned. Defaults to true.

Example Configuration

Here is a complete example of a JSON configuration file that could be used to run this transformation. This example extracts the point at the 75% position along a line stored with the key whisker_1.

[
{
    "transformations": {
        "metadata": {
            "name": "Whisker Tip Extraction Pipeline",
            "description": "Extracts the tip of a whisker from line data.",
            "version": "1.0"
        },
        "steps": [
            {
                "step_id": "1",
                "transform_name": "Extract Point from Line",
                "phase": "analysis",
                "input_key": "whisker_1",
                "output_key": "whisker_1_tip",
                "parameters": {
                    "position": 0.75,
                    "method": "Direct",
                    "use_interpolation": true
                }
            }
        ]
    }
}
]