Sim4Life T-Neuro provides pre-defined, parametrized monopolar, bipolar and sinusoidal pulse waveforms. However there is often the need to use complex, customized waveforms. The user can use the the 'user defined' option to import text files defining the waveform profile.
The following Matlab/Octave code illustrates how such a waveform text file can be created e.g. to define an amplitude-modulate sinusoidal signal with a 1kHz carrier frequency and a 10Hz modulation frequency.
clear all; close all;
% Waveform Parameters
t=linspace(0,1,60000); % Creates Time Vector
f=1000; % Frequency Carrier [Hz]
df=10; % Frequency Modulation [Hz]
% Create the Waveform
% Visualize the Waveform
xlabel('Time (ms)'); ylabel('Waveform [AU]')
data=[t*1000 ; v];
% Write as txt file to be imported in Sim4Life
Thanks! This is really what I want to know. This should be included in HTML manual.
@kj Here there is the equivalent Python code. Sometimes it is easier to have all code produced within Sim4Life.
import numpy as np
## Waveform Parameters
t=np.linspace(0,1,60000); # Creates Time Vector
f=1000 # Frequency Carrier [Hz]
df=10; # Frequency Modulation [Hz]
## Create the Waveform
# Creates The Data Structure
## Write as txt file to be imported in Sim4Life
np.savetxt(filename, data, delimiter=' ',fmt='%1.4f')