touchsim
¶The touchsim
package uses holoviews
for plotting.
import touchsim as ts
from touchsim.plotting import plot
import matplotlib.pyplot as plt
import numpy as np
plot() # short for plot(ts.hand_surface)
Regions labels and the coordinate system can be overlaid on the plot.
plot(tags=True,coord=10) # coord sets the lengths of the coordinate axes in mm
AfferentPopulation
objects¶a = ts.affpop_hand(region='D2d')
plot(a,size=10)
Spatial plots can be overlaid on the hand outline or individual parts of it
_,(ax1,ax2,ax3) = plt.subplots(1,3)
plt.sca(ax1)
plot(region='D2d')
plot(a['SA1'],size=10)
plt.sca(ax2)
plot(region='D2d')
plot(a['RA'],size=10)
plt.sca(ax3)
plot(region='D2d')
plot(a['PC'],size=10)
Stimulus
objects¶Plotting a Stimulus
object shows the trace of all pins by default.
s = ts.stim_ramp(len=0.25,amp=.1,ramp_len=0.05)
plot(s)
s += ts.stim_sine(freq=25.,len=.25,loc=[1.,1.])
plot(s)
Pin positions can also be shown spatially.
s = ts.stim_indent_shape(ts.shape_circle(hdiff=0.5,pins_per_mm=2,radius=3),ts.stim_ramp(len=0.1))
plot(region='D2d')
plot(s,spatial=True)
Response
objects¶Plotting a Response
object shows the spike trains of all included neurons
a = ts.affpop_hand(region='D2')
s = ts.stim_sine(freq=50.,amp=0.1,len=0.5)
r = a.response(s)
plot(r)
Responses can be shown within a certain time window.
plot(r,bin=[0,0.2])
Responses can also be plotted spatially, in which case the size of each dot scaled with the neuron's firing rate.
plot(region='D2')
plot(r,spatial=True,scaling_factor=.25)
Alternatively, firing rate can be indicated by color instead:
_,(ax1,ax2) = plt.subplots(1,2)
plt.sca(ax1)
plot(region='D2')
plot(r[r.aff['RA']],spatial=True,scale=False)
plt.sca(ax2)
plot(region='D2')
plot(r[r.aff['PC']],spatial=True,scale=False)
contact_locs = np.zeros((2,2))
contact_locs[0] = np.array([0.,0.])
contact_locs[1] = np.array([150.,0])
a = ts.affpop_hand(noisy=False)
s = ts.stim_indent_shape(contact_locs,ts.stim_ramp(amp=0.75,len=.2,ramp_len=0.05,ramp_type='lin',pin_radius=5.,pad_len=0.025))
r = a.response(s)
plot(r)