"""Test realistic sensory transduction models."""
import matplotlib.pyplot as plt
import numpy as np
from mercurial.simulation.engine import SimulationEngine
engine = SimulationEngine(dim=10)
# Visual: step change in intensity
[docs]
def step_intensity(t):
return 1000.0 if t > 0.5 else 100.0
res_vis = engine.run_visual_transduction((0.0, 2.0), dt=0.001, intensity_func=step_intensity)
plt.figure(figsize=(12, 4))
plt.subplot(1, 2, 1)
plt.plot(res_vis["t"], res_vis["photoreceptor"], label="Photoreceptor")
plt.plot(res_vis["t"], res_vis["bipolar"], label="Bipolar")
plt.xlabel("Time (s)")
plt.ylabel("Normalised activity")
plt.legend()
plt.title("Visual Transduction (Step Intensity)")
plt.grid(True)
# Auditory: tone burst
[docs]
def tone_burst(t, freq=1000.0):
if 0.5 < t < 1.0:
return 0.1 * np.sin(2 * np.pi * freq * t)
return 0.0
res_aud = engine.run_auditory_transduction((0.0, 2.0), dt=0.0001, displacement_func=tone_burst)
plt.subplot(1, 2, 2)
plt.plot(res_aud["t"], res_aud["current"])
plt.xlabel("Time (s)")
plt.ylabel("Transduction current (nA)")
plt.title("Hair Cell Response to Tone Burst")
plt.grid(True)
plt.tight_layout()
plt.show()