touchsim
¶The touchsim
package overloads several functions to make it easy to create new Afferent
, AfferentPopulation
, Stimulus
, and Response
objects from existing ones.
import touchsim as ts
Afferent
and AfferentPopulation
objects¶Individual Afferent
objects can be combined into an AfferentPopulation
object using the +
operator.
a1 = ts.Afferent('SA1')
a2 = ts.Afferent('PC')
a = a1 + a2
print(a)
The len
function can be used to determine the number of afferents in a given AfferentPopulation
object.
len(a)
AfferentPopulation
objects can be indexed to access individual Afferent
objects or sub-populations.
a[0]
len(a[0])
a[0:1]
len(a[0:1])
Afferent
objects can be added to an existing AfferentPopulation
using the +=
operator.
a += ts.Afferent('RA')
a.afferents
print(a)
Sub-populations can also be indexed by class.
a5 = ts.affpop_single_models()
a6 = a5['SA1']
a6.affclass
Stimulus
objects¶Pin locations and indentation traces of a Stimulus
object can be added to those of another one using the +=
operator. Note that the pin size of the initial Stimulus
will take precedent and that the Stimulus
durations and sampling frequencies for both Stimulus
objects must be the same.
s = ts.stim_ramp(amp=0.1)
s2 = ts.stim_sine(loc=[1,1],freq=15,amp=0.1)
s.location
s2.location
s += s2
s.location
Response
objects¶Response
objects can indexed using Afferent
or AfferentPopulation
objects to return a subset of responses.
r = a5.response(s)
len(r)
len(r[a5[0]])
len(r[a6])