Phase Encoding Algorithm
- phase_encoding(signal: ndarray, num_bits: int) ndarray[source]¶
Perform phase encoding on the input signal based on the given settings.
This function encodes the input signal by calculating the phase angles of the normalized signal and quantizing these angles into a binary spike train representation. The encoding process uses a specified number of bits to determine the level of quantization.
Refer to the Phase Encoding for a detailed explanation of the Phase Encoding Algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.global_referenced import phase_encoding signal = np.array([0.1, 0.2, 0.3, 1.0, 0.5, 0.3, 0.1, 0.2]) num_bits = 4 encoded_signal = phase_encoding(signal, num_bits)
- Parameters:
signal (numpy.ndarray) – The input signal to be encoded. This should be a numpy ndarray.
num_bits (int) – The number of bits to use for encoding.
- Returns:
A 1D numpy array representing the phase-encoded spike train.
- Return type:
- Raises:
ValueError – If the input signal is empty or if the number of bits is not appropriate for the signal length.