elasticai.preprocessor.waveform_generator#

Module Contents#

Classes#

WaveformSignal

Dataclass with waveform signal Attributes: time: Numpy array with timestamps signal: Numpy array with signal fs: Float with sampling rate rms: Float with root mean square value

WaveformGenerator

API#

class elasticai.preprocessor.waveform_generator.WaveformSignal[source]#

Dataclass with waveform signal Attributes: time: Numpy array with timestamps signal: Numpy array with signal fs: Float with sampling rate rms: Float with root mean square value

time: numpy.ndarray#

None

signal: numpy.ndarray#

None

fs: float#

None

rms: float#

None

class elasticai.preprocessor.waveform_generator.WaveformGenerator(sampling_rate: float)[source]#

Initialization

Class for generating the transient stimulation signal

Parameters:

sampling_rate – Sampling rate of the signal

check_charge_balancing(signal: numpy.ndarray) float[source]#

Checking if stimulation signal is charge balanced

get_dictionary_classes() list[source]#

Getting a list with class names / labels of waveforms

Returns:

List with class names

generate_waveform(time_points: list, time_duration: list, waveform_select: list, polarity_cathodic: list) elasticai.preprocessor.waveform_generator.WaveformSignal[source]#

Generating the signal with waveforms for stimulation

Parameters:
  • time_points – List of time points for applying a stimulation waveform

  • time_duration – List of stimulation waveform duration

  • waveform_select – List of selected waveforms

  • polarity_cathodic – List for performing cathodic-first generation

Returns:

Dataclass WaveformSignal with numpy arrays [‘time’, output_signal, true rms value)

generate_waveform_quant_fxp(time_points: list, time_duration: list, waveform_select: list, polarity_cathodic: list, bitwidth: int, bitfrac: int, signed: bool, do_opt: bool = False) elasticai.preprocessor.waveform_generator.WaveformSignal[source]#

Generating the signal with waveforms for stimulation in quantized matter

Parameters:
  • time_points – List of time points for applying a stimulation waveform

  • time_duration – List of stimulation waveform duration

  • waveform_select – List of selected waveforms

  • polarity_cathodic – List for performing cathodic-first generation

  • bitwidth – Integer with total bitwidth

  • bitfrac – Integer with fraction bitwidth

  • signed – If quantized output should be signed integer

  • do_opt – Boolean for taking quarter signal (optimized version for hardware implementation)

Returns:

Dataclass WaveformSignal with quantized signals [‘time’, ‘signal’, ‘fs’, ‘rms’]

generate_biphasic_waveform(anodic_wvf: str, anodic_duration: float, cathodic_wvf: str, cathodic_duration: float, intermediate_duration: float = 0.0, do_cathodic_first: bool = False, do_charge_balancing: bool = False) dict[source]#

Generating the waveform for stimulation Args: anodic_wvf: String with waveform type for anodic phase anodic_duration: Time window of the anodic phase cathodic_wvf: String with waveform type for cathodic phase cathodic_duration: Time window of the cathodic phase intermediate_duration: Time window for the intermediate idle time during anodic and cathodic phase do_cathodic_first: Starting with cathodic phase do_charge_balancing: Performing a charge balancing on second phase (same area) Returns: Two numpy arrays (time, output_signal)

static build_random_timestamps(count: int, min_gap: float = 0.002, max_gap: float = 0.01) list[source]#

Function for building random and sorted timestamps for generating waveforms

Parameters:
  • count – Number of timestamps to generate

  • min_gap – Minimum gap between timestamps [s]

  • max_gap – Maximum gap between timestamps [s]

create_design(waveform: str, num_params: int, is_signed: bool, target: str, bitwidth: int, id: str, path2save: pathlib.Path, use_bram: bool = False, do_opt: bool = False) list[int][source]#

Creating the hardware design for executing on specific target

Parameters:
  • waveform – String with waveform type for anodic phase

  • num_params – Number of params for the waveform

  • is_signed – Boolean indicating whether to use signed or not

  • target – String with target name [“mcu”, “pc”, “fpga”]

  • bitwidth – Integer with total bitwidth

  • id – String with unique identifier of device (appended to the name)

  • path2save – Path to save the hardware files

  • use_bram – Boolean indicating whether to use bram or not

  • do_opt – Boolean indicating whether to do opt or not

Returns:

None