Preprocessing Functions
Import preprocessing functions from the preprocessing
module:
radburst.utils.preprocessing
BinaryMaskRegion
Represents a bounding box (bbox) for a connected component in a binary mask.
ATTRIBUTE | DESCRIPTION |
---|---|
min_row |
The minimum row index of the bounding box.
TYPE:
|
min_col |
The minimum column index of the bounding box.
TYPE:
|
max_row |
The maximum row index of the bounding box.
TYPE:
|
max_col |
The maximum column index of the bounding box.
TYPE:
|
height |
The height of the bounding box.
TYPE:
|
width |
The width of the bounding box.
TYPE:
|
hw_ratio |
The height-to-width ratio of the bounding box.
TYPE:
|
area |
The area of the bounding box.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
bbox
|
A tuple containing the bounding box coordinates in the format (min_row, min_col, max_row, max_col).
TYPE:
|
Source code in radburst/utils/preprocessing.py
RegionManager
Manages a collection of regions and provides methods to analyze/filter them.
This class allows adding regions, finding the two largest regions and filtering based on specific criteria such as row difference and size ratio.
ATTRIBUTE | DESCRIPTION |
---|---|
regions |
A list of
TYPE:
|
add_region
filter_largest_2_regions
Filters the two largest regions based on criteria.
Checks the difference in max row indices and area ratio of the largest regions to determine which regions to keep.
PARAMETER | DESCRIPTION |
---|---|
row_diff_threshold
|
TYPE:
|
size_ratio_threshold
|
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list
|
A list containing the filtered |
Source code in radburst/utils/preprocessing.py
standardize_rows
Standardize each row by subtracting the mean and dividing by the standard deviation.
PARAMETER | DESCRIPTION |
---|---|
arr
|
Array to standardize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Row-standardized 2D array. |
Source code in radburst/utils/preprocessing.py
remove_vertical_lines
Remove columns with high variance (vertical lines) with other columns some distance away.
The default value of 5 seems to be a value based on a few random samples but this could be further verified. For the dist, we can see that these vertical lines are always just a few columns so 10 is far enough away to get a replacement column.
PARAMETER | DESCRIPTION |
---|---|
arr
|
Array to process.
TYPE:
|
num_std
|
Number of standard deviations above the mean to use as threshold for vertical lines.
TYPE:
|
dist
|
Distance away from vertical line column to get replacement column.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Processed array with vertical lines removed. |
Source code in radburst/utils/preprocessing.py
stan_rows_remove_verts
Standardize rows and remove vertical lines from spectrogram array.
PARAMETER | DESCRIPTION |
---|---|
arr
|
Array to process.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Processed array - standardized rows and vertical lines removed. |
Source code in radburst/utils/preprocessing.py
create_binary_mask
Create a binary mask of an array.
PARAMETER | DESCRIPTION |
---|---|
arr
|
Array to create mask.
TYPE:
|
pct_threshold
|
Percentile threshold for setting mask values to 1. For example, if this value is 95, the top 95% of array values will be 1, the rest 0.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Binary mask where values above threshold are 1 and others are 0 |
Source code in radburst/utils/preprocessing.py
morph_ops
Apply morphological operations to a binary mask to refine components/structures.
The goal is to remove small structures and enhance larger structures (potential bursts).
PARAMETER | DESCRIPTION |
---|---|
binary_arr
|
Input binary array (mask) to be processed.
TYPE:
|
dilation_1_struct_size
|
Structure element size for first dilation step.
TYPE:
|
erosion_struct_size
|
Structure element size for erosion step.
TYPE:
|
dilation_2_struct_size
|
Structure element size for second dilation step.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Refined binary mask with morphological operations applied. |
Source code in radburst/utils/preprocessing.py
filtered_components
filtered_components(mask, min_hw_ratio=0.14, min_area=600, min_h_wide_tall=30, min_area_wide_tall=1000)
Filter connected components (regions) in a binary mask based on size and shape criteria.
First, filter out regions by two sets of criteria (main and secondary) that evaluate height-to-width ratio and area. Then, keep upto the two largest remaining regions and apply two additional criteria from the RegionManager class: area ratio and max row difference to reduce false positive detections of a second burst.
The secondary criteria (keep_wide_tall_bursts
) was added to include type 2 bursts, which
the main criteria exclude due to the restrictive height-to-width ratio.
PARAMETER | DESCRIPTION |
---|---|
mask
|
Binary mask of connected components to filter.
TYPE:
|
min_hw_ratio
|
Minimum height-to-width ratio for main filter criteria.
TYPE:
|
min_area
|
Minimum area for main filter criteria.
TYPE:
|
min_h_wide_tall
|
Minimum height-to-widt ratio for keep_wide_tall_bursts filter criteria.
TYPE:
|
min_area_wide_tall
|
Minimum area for keep_wide_tall_bursts filter criteria.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple
|
A tuple containing: - filtered_largest_largest_2_regions (list): List of BinaryMaskRegion objects - regions that passed additional criteria found in RegionManager class. - filtered_mask (np.ndarray): Mask with only regions that passed main and secondary criteria. |
Source code in radburst/utils/preprocessing.py
blur
Blur array using a Gaussian kernel to enhance potential bursts.
PARAMETER | DESCRIPTION |
---|---|
arr
|
Input array to blur.
TYPE:
|
blur_filter_shape
|
Gaussian kernel size (width, height).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.ndarray: Blurred array. |