rotor_detection
ConvolutionDetection
Bases: RotorDetection
KERNELS = {'nabla_2x2': np.array([[-1, 1], [0, 0]]), 'nabla_3x3': np.array([[-1, 0, 1], [-1, 0, 1], [0, 0, 0]]), 'sobel_3x3': np.array([[-1 / 2, 0, 1 / 2], [-1, 0, 1], [-1 / 2, 0, 1 / 2]]), 'sobel_5x5': np.array([[-1 / 4, -1 / 5, 0, 1 / 5, 1 / 4], [-2 / 5, -1 / 2, 0, 1 / 2, 2 / 5], [-1 / 2, -1, 0, 1, 1 / 2], [-2 / 5, -1 / 2, 0, 1 / 2, 2 / 5], [-1 / 4, -1 / 5, 0, 1 / 5, 1 / 4]])}
class-attribute
instance-attribute
kernel = self.KERNELS['nabla_3x3']
instance-attribute
tc_threshold = 0.95
instance-attribute
__init__(phase_maps)
Initialize the ConvolutionDetection class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase_maps |
ndarray[T, N, M]
|
T phases maps with shape (N, M). |
required |
calc_rotors(topocharge, direction)
calc_topocharge()
Calculate topological charge via 2D matrix convolution with kernels.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray[T, N, M]: Topological charge array. |
convolve(x, kernel)
Compute convolution of data using a certain kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
ndarray
|
Input array to be convoluted with arbitrary ndim. |
required |
kernel |
ndarray
|
Convolution kernel with dimension ndim-1. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Convoluted array with same shape as input array. |
detect()
Calculate (t_ind, node_ind, direction) of rotor centers.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Dataframe containing ['t_ind', 'x_ind', 'y_ind', 'direction']. |
set_kernel(kernel_name)
Set convolution kernel. Kernel: 'nabla_3x3'
set_tc_threshold(tc_threshold)
Threshold value for detecting rotor. Default: 0.95
unwrap_period(phases)
Keep every phase difference in [-pi, pi] range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phases |
ndarray
|
Array of phases. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of phases in range [-pi, pi] where every phase is restricted to its 2pi counterpart where needed. |
PhaseJumpDetection2D
Bases: RotorDetection
Implements PhaseJump phase mapping algorithm based on doi: 10.1109/TBME.2016.2554660
Attributes:
| Name | Type | Description |
|---|---|---|
LOOPS |
dict
|
Dictionary of the loop types (single_2x2, single_4x4, double_4x4, 'triple_6x6'). Different locations on a loop must be formatted clockwise and seperated by 1 integer. Different loops must be seperated by 2 integers. |
LOOPS = {'single_2x2': np.array([[1, 2], [4, 3]]), 'single_4x4': np.array([[1, 2, 3, 4], [12, 0, 0, 5], [11, 0, 0, 6], [10, 9, 8, 7]]), 'double_4x4': np.array([[0, 6, 7, 0], [13, 1, 2, 8], [12, 4, 3, 9], [0, 11, 10, 0]]), 'triple_6x6': np.array([[0, 15, 16, 17, 18, 0], [30, 0, 6, 7, 0, 19], [29, 13, 1, 2, 8, 20], [28, 12, 4, 3, 9, 21], [27, 0, 11, 10, 0, 22], [0, 26, 25, 24, 23, 0]])}
class-attribute
instance-attribute
all_loops = False
instance-attribute
loop = self.LOOPS[self.loop_type]
instance-attribute
loop_type = 'double_4x4'
instance-attribute
monotonic = False
instance-attribute
phase_threshold = 1.5 * np.pi
instance-attribute
__init__(phase_maps)
calc_inner_mesh_indices(loop_radius)
Calculate the indices of the mesh inside the original mesh with a border of size=loop_radius removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loop_radius |
int
|
Radius of the largest loop. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[ndarray, ...]
|
Indices of the inner mesh inside the original mesh without the border of size=loop_radius. |
calc_loop_props()
Calculate loop properties of a specific loop type.
Returns:
| Name | Type | Description |
|---|---|---|
loop_properties |
dict
|
Dictionary of the loop properties. |
calc_loop_separation()
Calcuate the separation of the different loops.
Returns:
| Name | Type | Description |
|---|---|---|
loop_separation |
list
|
The pairs of start and end indices of each loop. |
calc_phase_jumps()
Calculate phase jumps defined as loops containing an odd number of positive or negative phase jumps.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray[n_loops, T, N, M]: Phasejump array containing + or -1 for positive/negative |
ndarray
|
rotations and 0 for no rotations. |
detect()
Calculate (x_index, y_index) of rotor centers.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Dataframe with columns ['t_ind', 'x_ind', 'y_ind', 'direction']. |
set_all_loops(all_loops=True)
Specifies if all loops must detect a phase singularity (True) or one loop minimally (False). Default: False
set_loop(loop_type)
Set loop type to be used by algorithm Default: 'double_4x4'
set_monotonic(monotonic=True)
Specifies if monotonicity of phases along rings is desired. Default: False
set_phase_threshold(phase_threshold)
Number in interval [-pi, pi] that phase differences must be exceeded to be classified as phase jump. Default: 1.5 * pi
PhaseJumpDetection3D
Bases: RotorDetection
Implements phase jump method of rotor detection on 3D irregular meshes.
Given sorted neighbor rings, calculates the amount of odd phasejumps in each ring and classifies these points as Phase Singularity points. Phasejumps are defined as differences in neighboring phases larger than a threshold. Based on: doi: 10.3414/me0427
include_nan = False
instance-attribute
neighbor_rings = None
instance-attribute
__init__(phases)
calc_neighbor_rings(coords, edges, radius)
Indices of clockwise sorted points on ring i < n_rings around node j < N. Shape of each array is (N, n_ring_points).
detect()
Calculate phase singularities defined as loops containing a summed phase difference between neighboring points, restricted to [-pi, pi], equal to ±2kpi where k != 0.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Dataframe with columns: - "t_ind": Time index. - "node_ind": Node index. - "direction": Singularity direction. - "ring_nodes": Nodes on the ring. - "ring_radius": Radius of the ring. - "phase_index": Index of phase singularity. |
set_include_nan(include_nan=True)
Include NaN phase differences in the calculation. Defaults to False.