The touchsim module uses the holoviews module for plotting.
import touchsim as ts
from touchsim.plotting import plot
import numpy as np
import holoviews as hv
hv.notebook_extension()
%output holomap='scrubber' # animate holomaps
plot() # short for plot(ts.hand_surface)
Regions labels and the coordinate system can be overlaid on the plot.
%%output size=250
plot(labels=True,coord=10) # coord sets the lengths of the coordinate axes in mm
a = ts.affpop_hand(region='D2d')
plot(a)
Plots can be overlaid using the * operator.
Plots are holoviews objects and can be indexed to only show, say, a specific afferent population.
plot(region='D2d') * plot(a)['PC']
New subpanels can be added using the + operator.
(plot(region='D2d') * plot(a)['SA1']) + (plot(region='D2d') * plot(a)['RA']) + (plot(region='D2d') * plot(a)['PC'])
The first index of an AfferentPopulation plot object is the afferent type, while the next two indices are pixel coordinates.
# zoom into fingertip
plot(a)[:,120:140,450:475]
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)
Pins can be shown in a grid view.
plot(s,grid=True)
Plotting a Response objects shows the spike trains of all included neurons
a = ts.affpop_hand(region='D2')
s = ts.stim_sine(freq=50.,amp=0.1)
r = a.response(s)
plot(r)
The second index is the time index.
plot(r)[:,0:0.2]
Responses can also be plotted spatially, in which case the size of each dot scaled with the neuron's firing rate.
%%output size=150 # increase size of plot by 150%
plot(region='D2') * plot(r,spatial=True)
Responses in spatial view can also be shown animated if a bin size (in ms) is given.
plot(region='D2') * plot(r,spatial=True,bin=10)
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)
plot() * plot(r,spatial=True,bin=10)