Calculate Mask Centroid
Overview
This transform calculates the centroid (geometric center) for each mask in a dataset.
Detailed Description
This transformation processes mask data, which represents regions of interest, and for each individual mask at each point in time, it computes the center of mass. The output is a series of points, where each point represents the calculated centroid of a corresponding mask. This is a common operation for summarizing a spatial distribution of pixels with a single representative point.
The calculation is purely geometric; it finds the average of the x and y coordinates of all the points within the mask. This means that for some non-convex (hollow or U-shaped) masks, the centroid can fall outside the mask itself, as shown in the examples below.
Neuroscience Use Cases
- Tracking Cell Bodies: If a mask outlines a neuron’s soma, its centroid provides a consistent point for tracking the cell’s position over time, even if the cell’s shape changes slightly.
- Analyzing Animal Behavior: When tracking an animal in a video, a mask might be generated around the animal’s body. The centroid of this mask can serve as a simplified representation of the animal’s location for trajectory analysis.
- Quantifying Limb Position: For masks drawn around an animal’s limbs, the centroid can be used to approximate the position of the limb for kinematic studies.
Parameters
This transform does not have any configurable parameters. It calculates the standard geometric centroid for each mask.
Example Configuration
Here is a complete example of a JSON configuration file that could be used to run this transformation.
[
{
"transformations": {
"metadata": {
"name": "Mask Centroid Pipeline",
"description": "Test mask centroid calculation on mask data",
"version": "1.0"
},
"steps": [
{
"step_id": "1",
"transform_name": "Calculate Mask Centroid",
"phase": "analysis",
"input_key": "test_masks",
"output_key": "mask_centroids",
"parameters": {}
}
]
}
}
]