// spikeplot.g - plots data only when a spike occurs // include this file after loading tutorial3.g // Create a blue xplot for plotting spikes to go with the /data/voltage graph // This will also be used to clear the spike plot on reset function reset_spikeplot if ({exists /data/voltage/spikes}) delete /data/voltage/spikes end create xplot /data/voltage/spikes setfield /data/voltage/spikes fg blue linewidth 2 reset end // change the script field of the /control/RESET button to perform // this new reset function setfield /control/RESET script reset_spikeplot // Now add a spikegen to the soma to make spikes from the action potentials create spikegen /cell/soma/spike setfield /cell/soma/spike thresh 0 abs_refract 0.010 output_amp 1 addmsg /cell/soma /cell/soma/spike INPUT Vm // Function to plot a spike of height "amp" function plotspike(plotpath, amp) str plotpath float amp call {plotpath} ADDPTS {getstat -time} 0 call {plotpath} ADDPTS {getstat -time} {amp} call {plotpath} ADDPTS {getstat -time} 0 end // The script_out element checks for a spike at every simulation step create script_out /catchspike setfield /catchspike command "checkspike" useclock /catchspike 0 function checkspike if ({getfield /cell/soma/spike state} != 0) plotspike /data/voltage/spikes {0.04} end end reset_spikeplot