admin管理员组文章数量:1290179
How can I modify my code to get biphasic pulses with 1 us long pulses and 1 us long pauses between each pulse. What ever I try, I am not able to generate such short pulses.. I managed to make it in Matlab but in Python I can't seem to make it work. Can someone help please?
MAIN PROBLEM: I need to have code where I can set my own duration of pulse and pause (which are 1 us - 0.1 ms). Right now my code is giving me too long pulses and I can't directly set for instance pulse_width=0.001 and break_width=0.001.
pointCount = 5000
voltages = np.empty(pointCount)
times = np.arange(pointCount) * 0.05
# Stimulus:
stim = np.zeros(pointCount)
amplitude = 1 # Pulse amplitude
num_pulses = 400 # Number of biphasic pulses
pulse_width = 2 # Width of each pulse (samples)
break_width = 2 # Break duration (samples)
start_index = 1200 # Start of first pulse
# Generate 50 biphasic pulses
for i in range(num_pulses):
index = start_index + i * (2 * pulse_width + 2 * break_width) # Calculate start index for each pulse pair
stim[index:index + pulse_width] = amplitude # Positive pulse
stim[index + pulse_width + break_width:index + 2 * pulse_width + break_width] = -amplitude # Negative pulse
plt.figure()
plt.plot(times, stim, 'r')
plt.xlabel('Time (ms)')
plt.ylabel('Amplitude (mV)')
plt.show()
本文标签: Biphasic pulses in PythonStack Overflow
版权声明:本文标题:Biphasic pulses in Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741471809a2380651.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论