Overloaded functions in touchsim

The touchsim package overloads several functions to make it easy to create new Afferent, AfferentPopulation, Stimulus, and Response objects from existing ones.

In [ ]:
import touchsim as ts

Afferent and AfferentPopulation objects

Individual Afferent objects can be combined into an AfferentPopulation object using the + operator.

In [ ]:
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.

In [ ]:
len(a)

AfferentPopulation objects can be indexed to access individual Afferent objects or sub-populations.

In [ ]:
a[0]
In [ ]:
len(a[0])
In [ ]:
a[0:1]
In [ ]:
len(a[0:1])

Afferent objects can be added to an existing AfferentPopulation using the += operator.

In [ ]:
a += ts.Afferent('RA')
a.afferents
print(a)

Sub-populations can also be indexed by class.

In [ ]:
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.

In [ ]:
s = ts.stim_ramp(amp=0.1)
s2 = ts.stim_sine(loc=[1,1],freq=15,amp=0.1)
s.location
In [ ]:
s2.location
In [ ]:
s += s2
s.location

Response objects

Response objects can indexed using Afferent or AfferentPopulation objects to return a subset of responses.

In [ ]:
r = a5.response(s)
len(r)
In [ ]:
len(r[a5[0]])
In [ ]:
len(r[a6])