```{index} single: Filters; Compute Feature Clustering
```
# Compute Feature Clustering

## Group (Subgroup)

Statistics (Morphological)

## Description

This Filter determines the radial distribution function (RDF), as a histogram, of a given set of **Features**. Currently, the **Features** need to be of the same **Ensemble** (specified by the user), and the resulting RDF is stored as **Ensemble** data. This Filter also returns the clustering list (the list of all the inter-**Feature** distances) and the minimum and maximum separation distances. The algorithm proceeds as follows:

1. Find the Euclidean distance from the current **Feature** centroid to all other **Feature** centroids of the same specified phase
2. Put all caclulated distances in a clustering list
3. Repeat 1-2 for all **Features**
4. Sort the data into the specified number of bins, all equally sized in distance from the minimum distance to the maximum distance between **Features**. For example, if the user chooses 10 bins, and the minimum distance between **Features** is 10 units and the maximum distance is 80 units, each bin will be 8 units
5. Normalize the RDF by the probability of finding the **Features** if distributed randomly in the given box

*Note:* Because the algorithm iterates over all the **Features**, each distance will be double counted. For example, the distance from **Feature** 1 to **Feature** 2 will be counted along with the distance from **Feature** 2 to **Feature** 1, which will be identical.


### Input Parameter(s)

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Selected Image Geometry | Geometry Selection | Image | The target geometry |
| Number of Bins for RDF | Scalar Value |Int32 | Number of bins to split the RDF |
| Phase Index | Scalar Value |Int32 | Ensemble number for which to calculate the RDF and clustering list |
| Remove Biased Features | Bool |  | Remove the biased features |

### Random Number Seed Parameters

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Set Random Seed | Bool |  | When checked, allows the user to set the seed value used to randomly generate the points in the RDF |
| Seed Value | Scalar Value |UInt64 | The seed value used to randomly generate the points in the RDF |
| Stored Seed Value Array Name | DataObjectName |  | Name of array holding the seed value |

### Input Feature Data

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Phases | Array Selection | Allowed Types: int32 Comp. Shape: 1 | Specifies to which Ensemble each Feature belongs |
| Centroids | Array Selection | Allowed Types: float32 Comp. Shape: 3 | X, Y, Z coordinates of Feature center of mass |
| Biased Features | Array Selection | Allowed Types: uint8, boolean Comp. Shape: 1 | Specifies which features are biased and therefor should be removed if the Remove Biased Features option is on; True values removed |

### Input Ensemble Data

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Cell Ensemble Attribute Matrix | AttributeMatrixSelection |  | The path to the cell ensemble attribute matrix where the RDF and RDF min and max distance arrays will be stored |

### Output Feature Data

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Clustering List | DataObjectName |  | Distance of each Feature's centroid to every other Feature's centroid |

### Output Ensemble Data

| Parameter Name | Parameter Type | Parameter Notes | Description |
|----------------|----------------|-----------------|-------------|
| Radial Distribution Function | DataObjectName |  | A histogram of the normalized frequency at each bin |
| Max and Min Separation Distances | DataObjectName |  | The max and min distance found between Features |

## Example Pipelines

+ PorosityAnalysis

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues/discussions) GitHub site where the community of DREAM3D-NX users can help answer your questions.
