Statistics
Calculate statistics on grain volumes and aggregate and summarise the data.
Functions:
| Name | Description |
|---|---|
area_pores |
Extract area of objects in each layer. |
calculate_pdf |
Calculate the scaled probability density function for an array. |
centroid_pores |
Extract centroid of objects in each layer. |
classify_pore_size |
Classify pore sizes in a dataframe into colors. |
count_pores |
Count the number of |
create_statistics_dictionary |
Extract statistics of objects from each layer. |
feret_diameter_maximum_pores |
Extract the maximum feret diameter of objects in each layer. |
full_width_half_max |
Calculate the full-width half max. |
sum_area_by_layer |
Sum the area of pores on each layer. |
summarise_pores |
Summarise pore types by image, layer and color. |
area_pores
area_pores(sliced_region_properties)
Extract area of objects in each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Any]
|
A list (one for each layer) of lists which contain the |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
A list with the same length as the number of layers, each item is a list of the area of objects within that layer. |
calculate_pdf
Calculate the scaled probability density function for an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[float]
|
Array of data points to be summarised. |
required |
|
int | float
|
Minimum value. |
None
|
|
int | float
|
Maximum value. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, NDArray]
|
Dictionary of x and y values for the PDF. |
centroid_pores
centroid_pores(sliced_region_properties)
Extract centroid of objects in each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Any]
|
A list (one for each layer) of lists which contain the |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
A list with the same length as the number of layers, each item is a list of the centroid of objects within that layer. |
classify_pore_size
classify_pore_size(
df, area_thresholds, pore_colors, area_val="area"
)
Classify pore sizes in a dataframe into colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DataFrame
|
Dataframe with areas to be classified. |
required |
|
dict[str, int]
|
Dictionary of thresholds, there should be three values for low, medium and high thresholds resulting in four categories. |
required |
|
list[str]
|
Colors to use for the four categories. |
required |
|
str
|
Column name containing the area data, default is |
'area'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with additional column with text categorisation of pore area. |
count_pores
count_pores(sliced_region_properties)
Count the number of region_properties, each of which represents a pore for all layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Any]
|
A list of region properties found on each layer. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int32]
|
A list of the number of region properties detected in each layer. |
create_statistics_dictionary
create_statistics_dictionary(
sliced_region_properties,
feret_maximum=False,
centroid=False,
)
Extract statistics of objects from each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[list[Any]]
|
List of lists of region properties, the top level is layer, the nesting within it is each of the objects within the layer. |
required |
|
bool
|
Whether to extract the maximum feret distance. |
False
|
|
bool
|
Whether to extract the centroid coordinates of the region. |
False
|
Returns:
| Type | Description |
|---|---|
dict[int, dict[int, Any]]
|
Dictionary of statistics, top-level is the layer/slice through the image, and nested within are statistics for each pore. |
feret_diameter_maximum_pores
feret_diameter_maximum_pores(sliced_region_properties)
Extract the maximum feret diameter of objects in each layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Any]
|
A list (one for each layer) of lists which contain the |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
A list with the same length as the number of layers, each item is a list of the maximum feret diameter of objects within that layer. |
full_width_half_max
full_width_half_max(pdf)
Calculate the full-width half max.
We are interested in the layers that cover the full-width half-max of the number of pores in an image. And therefore
extract the indices the calculated PDF (y_pdf)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
NDArray
|
Array probability density function for which peak and full-width half-max are to be calculated. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Dictionary of the lower and upper layers for the full-width half-max range. |
sum_area_by_layer
summarise_pores
summarise_pores(df, pore_colors)
Summarise pore types by image, layer and color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DataFrame
|
Pandas dataframe to aggregate, typically will be |
required |
|
list[str]
|
List of pore color columns that should be present in the resulting dataframe. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Aggregated data frame of counts of |