Selectivity indices quantify how much a well defined electrostimulation setup (intended as the combination of and electrode geometry, electrode configuration and pulse shape) is able to recruit a specific (target) group of axons without recruiting the other axons in the system.
Each group could be a spinal cord root, a fascicle within a complex multi-fascicular nerve models, or a collection of axons based on population characteristics e.g. fiber type (myelinated or unmyelinated), distribution of axon diameters, etc.
A definition of selectivity indices can be found in this publication:
Raspopovic S, Capogrosso M, Micera S. A computational model for the stimulation of rat sciatic nerve using a transverse intrafascicular multichannel electrode. IEEE Trans Neural Syst Rehabil Eng. 2011 Aug;19(4):333-44
In Sim4life, the selectivity function is part of the Action Potential Sensor available as post-processing step in the Analysis Tab. In order to use it, the user must assign each axon/neuron in the simulation to a specific group. Groups are identified by numbers (group 1, group 2, etc.). This can be done using the GUI or using the Python API.
The following script permit to set up the groups based on the name of the axon and the folder in the Model panel they belong to (I suggest to create subfolders in the Model panel, each one containing only axons of the same group).
# -*- coding: utf-8 -*-
import numpy
import s4l_v1.analysis as analysis
import s4l_v1.document as document
import s4l_v1.model as model
import s4l_v1.units as units
from s4l_v1 import Unit
###################################################################################
# Author: Dr. Antonino M. Cassara'
# Date: 13/04/2021
###################################################################################
# Gets the Neuronal Simulation Name
neuronsimname="Neuron_Simulation"
# Adding a new SimulationExtractor
simulation = document.AllSimulations[neuronsimname]
simulation_extractor_2 = simulation.Results()
# Adding a new SensorExtractor
sensor_extractor = simulation_extractor_2["Action Potential Sensor"]
document.AllAlgorithms.Add(sensor_extractor)
# Adding a new SelectivityEvaluator
inputs = [sensor_extractor.Outputs["Action Potential"]]
selectivity_evaluator = analysis.neuron_evaluators.SelectivityEvaluator(inputs=inputs)
selectivity_evaluator.UpdateAttributes()
document.AllAlgorithms.Add(selectivity_evaluator)
## Gets the Group Names and assigns an ID - The group Names ares the Folder Names##
neurons=simulation.GetNeuronEntities()
groups=[]
for neuro in neurons:
name=neuro.ParentGroup().Name
if name not in groups:
groups.append(name)
## Associates Each Fiber to Its Own Group. A group is the folder it belongs
cnt=0
for group in groups:
for neuro in neurons:
if group==neuro.ParentGroup().Name:
name=neuro.Name+' ('+neuro.ParentGroup().Name+')'
selectivity_evaluator.SetNeuronAssignment(name,cnt)
cnt+=1
selectivity_evaluator.Update()
## Extracts The Selectivity Maps
select_map=selectivity_evaluator.SelectivityMap()
cnt=0
for key in select_map.keys():
print (key,groups[cnt],select_map[key])
cnt+=1
# Adding a new DataTableHTMLViewer
inputs = [selectivity_evaluator.Outputs["Selectivity score"]]
data_table_html_viewer = analysis.viewers.DataTableHTMLViewer(inputs=inputs)
data_table_html_viewer.Visible = False
data_table_html_viewer.UpdateAttributes()
document.AllAlgorithms.Add(data_table_html_viewer)