better figures
This commit is contained in:
parent
a8ce30d92b
commit
68e7b75768
@ -7,10 +7,11 @@ import matplotlib.pyplot as plt
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import models.smallModels as sM
|
import models.smallModels as sM
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# stimulus_development()
|
# stimulus_development()
|
||||||
# model_adaption_example()
|
model_adaption_example()
|
||||||
model_comparison()
|
# model_comparison()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -81,18 +82,19 @@ def model_comparison():
|
|||||||
|
|
||||||
|
|
||||||
def stimulus_development():
|
def stimulus_development():
|
||||||
time_start = 0
|
time_start = -0.020
|
||||||
time_duration = 0.025
|
time_duration = 0.080
|
||||||
|
|
||||||
stimulus = SinusoidalStepStimulus(745, 0.2, 0.1, 0.1)
|
stimulus = SinusoidalStepStimulus(745, 0.2, 0.1, 0.1)
|
||||||
step_size = 0.00005
|
step_size = 0.000005
|
||||||
stim_array = stimulus.as_array(time_start, time_duration, step_size)
|
stim_array = stimulus.as_array(time_start, time_duration, step_size)
|
||||||
|
|
||||||
rectified = hF.rectify_stimulus_array(stim_array)
|
rectified = hF.rectify_stimulus_array(stim_array)
|
||||||
filtered = dendritic_lowpass(rectified, 0.0014, step_size)
|
filtered = dendritic_lowpass(rectified, 0.001, step_size)
|
||||||
|
|
||||||
fig, axes = plt.subplots(3, 1, figsize=(6, 6), sharex="col")
|
fig, axes = plt.subplots(3, 1, figsize=(6, 6), sharex="col")
|
||||||
time = np.arange(time_start, time_duration, step_size)
|
time = np.arange(time_start, time_start+time_duration, step_size)
|
||||||
|
|
||||||
axes[0].plot(time, stim_array)
|
axes[0].plot(time, stim_array)
|
||||||
axes[0].set_title("stimulus")
|
axes[0].set_title("stimulus")
|
||||||
|
|
||||||
@ -102,13 +104,14 @@ def stimulus_development():
|
|||||||
axes[2].plot(time, filtered)
|
axes[2].plot(time, filtered)
|
||||||
axes[2].set_title("rectified with dendritic filter")
|
axes[2].set_title("rectified with dendritic filter")
|
||||||
|
|
||||||
axes[0].set_ylim((-1.05, 1.05))
|
axes[0].set_ylim((-1.15, 1.15))
|
||||||
axes[1].set_ylim((-1.05, 1.05))
|
axes[1].set_ylim((-1.15, 1.15))
|
||||||
|
axes[2].set_ylim((-1.15, 1.15))
|
||||||
|
|
||||||
for ax in axes:
|
for ax in axes:
|
||||||
ax.set_ylabel("Amplitude [mV]")
|
ax.set_ylabel("Amplitude [mV]")
|
||||||
axes[2].set_xlabel("Time [s]")
|
axes[2].set_xlabel("Time [s]")
|
||||||
axes[0].set_xlim((time_start-0.0005, time_duration))
|
axes[0].set_xlim((0, 0.05))
|
||||||
# axes[2].set_ylim((0, 1.05))
|
# axes[2].set_ylim((0, 1.05))
|
||||||
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
@ -162,7 +165,7 @@ def model_adaption_example():
|
|||||||
axes[0].plot(time_part, v1[start_idx:end_idx])
|
axes[0].plot(time_part, v1[start_idx:end_idx])
|
||||||
axes[0].set_ylabel("Membrane voltage [mV]")
|
axes[0].set_ylabel("Membrane voltage [mV]")
|
||||||
# axes[1].plot(time[start_idx:end_idx], adaption[start_idx:end_idx])
|
# axes[1].plot(time[start_idx:end_idx], adaption[start_idx:end_idx])
|
||||||
axes[1].plot(time_part, adaption[start_idx:end_idx])
|
axes[1].plot(time_part, -1*np.array(adaption[start_idx:end_idx]))
|
||||||
axes[1].set_ylabel("Adaption current [mV]")
|
axes[1].set_ylabel("Adaption current [mV]")
|
||||||
axes[1].set_xlabel("Time [ms]")
|
axes[1].set_xlabel("Time [ms]")
|
||||||
axes[1].set_xlim((start, end))
|
axes[1].set_xlim((start, end))
|
||||||
|
@ -6,12 +6,14 @@ import matplotlib.pyplot as plt
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
plot_step_stimulus()
|
stimuli_protocol_examples()
|
||||||
plot_sam_stimulus()
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def plot_step_stimulus():
|
def stimuli_protocol_examples():
|
||||||
|
|
||||||
|
fig, axes = plt.subplots(2, 1)
|
||||||
|
|
||||||
start = 0
|
start = 0
|
||||||
end = 1
|
end = 1
|
||||||
|
|
||||||
@ -19,47 +21,35 @@ def plot_step_stimulus():
|
|||||||
time_end = 1.2
|
time_end = 1.2
|
||||||
step_size = 0.00005
|
step_size = 0.00005
|
||||||
|
|
||||||
frequency = 20
|
frequency = 55
|
||||||
contrast = 0.5
|
contrast = 0.5
|
||||||
|
|
||||||
|
# Sinusoidal STEP stimulus
|
||||||
# frequency, contrast, start_time=0, duration=np.inf, amplitude=1
|
# frequency, contrast, start_time=0, duration=np.inf, amplitude=1
|
||||||
step_stim= SinusoidalStepStimulus(frequency, contrast, start, end-start)
|
step_stim = SinusoidalStepStimulus(frequency, contrast, start, end - start)
|
||||||
|
|
||||||
values = step_stim.as_array(time_start, time_end-time_start, step_size)
|
values = step_stim.as_array(time_start, time_end - time_start, step_size)
|
||||||
time = np.arange(time_start, time_end, step_size)
|
time = np.arange(time_start, time_end, step_size)
|
||||||
|
|
||||||
plt.plot(time, values)
|
axes[0].plot(time, values)
|
||||||
plt.xlabel("Time [s]")
|
axes[0].set_ylabel("Voltage [mV]")
|
||||||
plt.ylabel("Voltage [mV]")
|
|
||||||
plt.savefig("thesis/figures/sin_step_stim_example.pdf")
|
|
||||||
plt.close()
|
|
||||||
|
|
||||||
|
|
||||||
def plot_sam_stimulus():
|
|
||||||
start = 0
|
|
||||||
end = 1
|
|
||||||
|
|
||||||
time_start = -0.2
|
|
||||||
time_end = 1.2
|
|
||||||
step_size = 0.00005
|
|
||||||
|
|
||||||
contrast = 0.5
|
# SAM Stimulus:
|
||||||
mod_freq = 10
|
mod_freq = 10
|
||||||
carrier_freq = 53
|
step_stim = SinusAmplitudeModulationStimulus(frequency, contrast, mod_freq, start, end - start)
|
||||||
# carrier_frequency, contrast, modulation_frequency, start_time=0, duration=np.inf, amplitude=1
|
|
||||||
step_stim = SinusAmplitudeModulationStimulus(carrier_freq, contrast, mod_freq, start, end - start)
|
|
||||||
|
|
||||||
values = step_stim.as_array(time_start, time_end - time_start, step_size)
|
values = step_stim.as_array(time_start, time_end - time_start, step_size)
|
||||||
time = np.arange(time_start, time_end, step_size)
|
time = np.arange(time_start, time_end, step_size)
|
||||||
plt.plot(time, values)
|
plt.plot(time, values)
|
||||||
|
|
||||||
beat_time = np.arange(start, end, step_size)
|
beat_time = np.arange(start, end, step_size)
|
||||||
beat_values = np.sin(beat_time*2*np.pi*mod_freq) * contrast + 1
|
beat_values = np.sin(beat_time * 2 * np.pi * mod_freq) * contrast + 1
|
||||||
plt.plot(beat_time, beat_values)
|
axes[1].plot(beat_time, beat_values)
|
||||||
|
|
||||||
|
axes[1].set_xlabel("Time [s]")
|
||||||
|
axes[1].set_ylabel("Voltage [mV]")
|
||||||
|
|
||||||
plt.xlabel("Time [s]")
|
plt.savefig("thesis/figures/stimuliExamples.pdf")
|
||||||
plt.ylabel("Voltage [mV]")
|
|
||||||
# plt.show()
|
|
||||||
plt.savefig("thesis/figures/sam_stim_example.pdf")
|
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user